Assembly language
Basics:
- all text is case insensitive (except for strings content of course)
- comments start with
#
and end with the line - each instruction must be written on a single line
- otherwise, blanks (spaces, tabs, newlines) are not significant
Literals:
- int values are expected in hexadecimal.
ex:
FF
is 255,10
is 16, etc. - other bases are written as
[DIGITS]BASE
. ex:[1111]2
is 15,[42]10
is 42, etc. - strings are written using the syntax of Python.
ex:
'hello'
or"world"
- registers are written as their name.
ex:
R0
,IP
, etc. - labels value are written as
@NAME
. ex:@mylabel
,@IRQ0
, etc.
Labels:
- a label is defined by writting its name followed by a colon
:
. ex:mylabel:
- it can be referenced to with
@mylabel
as explained above - special labels
IRQx
, wherex
is an interrupt number between0
andF
, are used to specify interrupt handlers - default handlers are automatically installed for those not specified
Instructions:
-
add left right target
settarget
toleft + right
-
and left right target
settarget
toleft AND right
-
bus command address data
activate the bus passing (and updating) the given registers -
call target
call a subroutine -
cp source target
copy registersource
totarget
-
dec accumulator
decrement a register by 1 -
div left right target
settarget
toleft / right
-
eq left right target
settarget
toleft == right
(1 is true, 0 is false) -
get address target
settarget
to the word ataddress
-
gt left right target
settarget
toleft > right
(1 is true, 0 is false) -
halt
power off the machine -
inc accumulator
increment a register by 1 -
iret
return from an interrupt -
jmp target
jump at the given address -
jnz test target
jump attarget
iftest
is not zero -
jz test target
jump attarget
iftest
is zero -
lshift left right target
settarget
toleft << right
(left-shift) -
mod left right target
settarget
toleft % right
(modulo) -
mul left right target
settarget
toleft * right
-
neg source target
settarget
to the two's complement ofsource
-
neq left right target
settarget
toleft != right
(1 is true, 0 is false) -
nintr number
raise an interrupt -
nop
keep the CPU idle for one cycle -
not source target
settarget
toNOT source
-
or left right target
settarget
toleft OR right
-
pop target
pop one word from the stack into a register -
push source
push a register onto the stack -
put source address
savesource
toaddress
-
rand target
assigns a register with a random value -
reset target
set a register to zero -
ret
return from a subroutine -
rget address target
settarget
to the word ataddress
(relatively toBP
) -
rintr register
raise an interrupt -
rput source address
savesource
toaddress
(relatively toBP
) -
rshift left right target
settarget
toleft << right
(right-shift) -
set target value
set a register to value (two words instruction) -
sub left right target
settarget
toleft - right
-
xor left right target
settarget
toleft XOR right