A tiny asm-like language for playing around with integers
See examples for syntax examples
Every command takes one or two arguments.
- To access a register, use
A-H
- To reference a location in RAM, use
&N
whereN
is the address. Default address space is 0 - 1023 - To access a location in RAM who's address is stored in a register use
&A
. ReplaceA
with any register name. - Line comments start with
;
- Labels must be alpha characters and end with
:
. They must be on their own line. - To reference a label, just use the label name (
jp
andjnz
)
Key:
reg
: registeradr
: addressloc
: location namelit
: integer literal
Commands:
- ld
adr1 adr2
copy the int stored inadr2
intoadr1
- ld
reg1 reg2
copy the value stored inreg2
intoreg1
- ld
adr lit
load the value oflit
intoadr
- ld
reg lit
load the value oflit
intoreg
- ld
reg adr
copy the int atadr
intoreg
- ld
® adr
copy the int stored atadr
into the address stored inreg
- ld
®1 reg2
copy the int stored atreg2
into the address stored inreg1
- ld
reg1 ®2
copy the value stored in RAM at the address stored in the location in registerreg2
toreg1
- prt
reg
print the value stored inreg
to the console - prtch
reg
convert the value stored inreg
to an ASCII character and print the character to the console - jp
loc
jump to a label in the code - jnz
reg loc
if the value inreg
is not zero, jump to loc - add
reg1 reg2
add the value stored inreg2
to the value inreg1
- sub
reg1 reg2
subtract the value stored inreg2
from the value inreg1
- mul
reg1 reg2
multiply the value stored inreg2
with the value inreg1
- div
reg1 reg2
divide the value stored inreg2
from the value inreg1
- rem
reg1 reg2
divide the value stored inreg2
to the value inreg1
and store the remainder inreg1
- and
reg1 reg2
bitwise and the value stored inreg2
with the value inreg1
- or
reg1 reg2
bitwise or the value stored inreg2
with the value inreg1
- inc
reg
increment the value inreg
- dec
reg
decrement the value inreg
- str
adr
string_lit
store the string at the given address
The str
command takes an address and a string literal as arguments. String literals begin with a "
and end with a newline Strings are stored in memory as
addr addr+1 addr+2 ... addr+N
... | N | char1 | char2 | ... | charN | ...
For example,
ld A 100
str &A "ABC
would result in
addr: 100 101 102 103 ...
... | 3 | 65 | 66 | 67 | ...