arsm
| Paradigm(s) | Imperative |
|---|---|
| Designed by | User:ZippyMagician |
| Appeared in | 2020 |
| Memory system | Registry, Stack, Cells |
| Computational class | Turing-complete |
| Reference implementation | arsm |
| Influenced by | Assembly_code |
| File extension(s) | .asm |
arsm is an esolang inspired by various versions of Assembly, designed by User:ZippyMagician.
About
This page will not be kept up to date. Rather, what follows is a description of the language as of version 0.2.4. To see the current documentation, click here.
General Structure
Labels
Labels are used when you want to pass a branch as an argument. They are defined as:
:name
Branches
Branches can be jumped to by certain commands. They are defined as follows:
.name
...
.
A branch will be executed on the programs first run-through. For example:
.main
mov eax 13
out eax
Will print 13, even though no specific call to .main was made
Memory
See: https://raw.githubusercontent.com/ZippyMagician/arsm/master/etc/arsm_memory.png
Registry
There are 5 16-bit registries: a, b, c, d, and e. To call a single registry, attach an x onto the end. To join two registries together (making 32-bits of data), simply put two separate registry names before the x. To only access half of the 16-bit registries, use h or l (upper or lower respectively).
Cells
Memory is accessed by placing some expression that evaluates down to a number inside []. Memory is seperated into 8-bit cells, which similar to the registry can be joined together. To accomplish this, you prefix the [] with an identifier. # marks a single cell (8-bits), $ marks two cells (16-bits), and @ marks four cells (32-bits).
Characters
A character literal is denoted by a ' followed by any ascii character. This will yield the integer value of that character, for use in the program.
Commands
mov <A> <B>-> Move B into Ainc <A>-> Increment Adec <A>-> Decrement Aout <A>-> Print A with no newlinejmp <A>-> Goto the branch entitled A (note: A is a label, not a branch)mul <A> <B>-> Multiply A by B, store in Adiv <A> <B>-> Divide A by B, store in Aadd <A> <B>-> Add A and B, store in Asub <A> <B>-> Subtract B from A, store in Alsh <A> <B>-> A << B, store in Arsh <A> <B>-> A >> B, store in Aor <A> <B>-> A | B, store in Axor <A> <B>-> A ^ B, store in Aand <A> <B>-> A & B, store in Anot <A>-> ~Astr <A> <B>-> Place string A in memory, with final character Bdb <A> <B>-> Get length of data, starting at point A in memory and ending when the point in memory equals Bin-> Get next byte of STDIN or a null-byte (0) if none leftchr <A>-> Print A as a character instead of numberhlt <A>-> Terminates program with exit code Aret-> Return to the point at which this jump was called fromstk <A>-> Resizes stack to size A. Defaults to 0psh <A> <B>-> Pushes A byte number B to stackpop <A>-> Pops N bytes (enough to fill A) and move to A.ceq <A> <B>-> Sets conditional flag if A == Bcz <A>-> Sets conditional flag if A is 0cne <A> <B>-> Sets conditional flag if A != Bcg <A> <B>-> Sets conditional flag if A > Bcge <A> <B>-> Sets conditional flag if A >= Bcl <A> <B>-> Sets conditional flag if A < Bcle <A> <B>-> Sets conditional flag if A <= B
Additionally, there are conditional versions of the following: jmp, mov, inc, dec, out, mul, div, add, sub, lsh, rsh, or, and, xor, not, chr, hlt, ret, psh, pop (remove the last letter, put a c in the front)
Inline Python
Inline Python supports a few custom functions + variables to manipulate and make use of
| Name | Type | Description |
|---|---|---|
fromBytes
|
func | Converts list $1 u8 bytes to single, signed integer. Useful for joining sections of the stack
|
stk
|
var | The current stack stored in memory. Can be modified. WARNING: EXCEEDING THE BOUNDS OF THE STACK WILL NOT ERROR, AND MAY LEAD TO SOME DATA BEING LOST |
popN
|
func | Pops the top $2 items from the list $1 |
In addition, you can access any register (for example eax) by prefixing it with an @. For instance:
mov ex 14
mov ah 56
ceq { @ex + @ah } 70
chl 1