Every register is followed in memory. Exemple: acc
is after ip
ect.
Order of register is as following: ip
, acc
, ax
, bx
, cx
, dx
, ex
, fx
, gx
, hx
, sp
, fp
.
ip
: instruction pointer (16bits) don't touch pleaseacc
: accumulator, stored results of mathematical operations (add, sub, mul ...)sp
: stack pointer (handle subroutines)fp
: frame pointer (pointer inside stack frame)
a
:ax
: main register (16bits) can be separated in two 8bits registerah
: 8bits register, upper byte ofax
al
: 8bits register, lower byte ofax
b
: same handling asa
with registersbh
,bl
andbx
c
: same handling asa
with registersch
,cl
andcx
d
: same handling asa
with registersdh
,dl
anddx
ex
: 16bits registerfx
: 16bits registergx
: 16bits registerhx
: 16bits register
mov
x
y
(movex
iny
):x
= register, memory (as u8 or u16), literal, register pointer (as u8 or u16), literal + register (as an offset)y
= register, memory (as u8 or u16), register pointer (as u8 or u16)
add
x
y
(addx
andy
in register acc):x
= registery
= literal, registerx
+y
> 65535 -> flag Carry == 0100
sub
x
y
(subx
andy
in register acc):x
= literal, registery
= literal, registerx
-y
< 0 -> flag Carry == 0100x
andy
can't be both literal
mult
x
y
(mulx
andy
in register acc):x
= registery
= literal, registerx
*y
> 65535 -> flag Carry == 0100
cmp
x
y
(update flag by comparingx
andy
):x
= registery
= literal, registerx
==y
-> flag Zero == 0001x
>y
-> flag Pos == 0000x
<y
-> flag Neg == 0010
inc
reg
(increment value inreg
)dec
rec
(decrement value inreg
)jmp
label
(jmp to label unconditionnaly):jmp
=jne
(jmp if flag Zero is not set)jmp
=jeq
(jmp if flag Zero is set)jmp
=jgt
(jmp if flag Zero is not set AND flag Neg is not set)jmp
=jge
(jmp if flag Neg is not set)jmp
=jlt
(jmp if flag Neg is set)jmp
=jle
(jmp if flag Neg is set OR if flag Zero is set)
psh
val
(push val on stack):val
= register, register pointer (as u8 or u16), literal, memory (as u8 or u16)
pop
val
(pop stack in val):val
= register, register pointer (as u8 or u16), memory (as u8 or u16)
cal
val
(call subroutine, setting up stackframe):val
= label or register
ret
(return from subroutine, restoring stackframe)xor
x
y
(xorx
andy
and store result inx
):x
= registery
= literal or register
end
(end of program)
0x3000-0x4000 -> screen