vars:
video int 5120
inst_len int 16
main:
add #3840 $video
mov $video %z
mov #128 %x
mov %inst %y
mov8 #2 [%z]
mov8 #3 [%z+128]
mov8 #4 [%z-128]
add #1 %z
sub #1 %x
cmp #0 %x
jlt %y
x
y
z
stack
: points to end of used stack memorybase
: points to start of current stack frameheap
: points to end of used heap memoryinst
: points to the next instruction in the CODE
segment
lt: true if src was smaller than dest
gt: true if src was smaller than dest
zf: true if result of mathematical operation was zero
Type | Specifier | Desc | type | formats | e.g. |
---|---|---|---|---|---|
Address | @ |
address of location | src, dest | uint16 | @1200 |
Register | % |
value in register | src, dest | text | %stack |
Variable | $ |
value of variable | src, dest | text | $age |
Pointer | * |
address of variable | src | text | *age |
Immediate | # |
number | src | uint32 | #100 |
Name | Form | Desc |
---|---|---|
Add |
add src dest
|
add src to dest, set zf flag accordingly |
Sub |
sub src dest
|
subtract dest from src, set zf flag accordingly |
Move |
mov src dest
|
dest becomes source (32 bit) |
Move8 |
mov8 src dest
|
dest becomes source (8 bit) |
Move16 |
mov16 src dest
|
dest becomes source (16 bit) |
Push |
pus src
|
increment %stack, store src at new address |
Pop |
pop dest
|
store value at %stack address in dest, decrement %stack |
Jump |
jmp src
|
jump (set inst pointer) to src address |
Jump Equal |
jeq src
|
jump (set inst pointer) to src address if lt & gt flags are false |
Jump Less |
jlt src
|
jump (set inst pointer) to src address if lt flag is true |
Jump Greater |
jgt src
|
jump (set inst pointer) to src address if gt flag is true |
Compare |
cmp src dest
|
compare value in src to value in dest, set lt & gt flags accordingly |
Uses the value at the adress equal to the value in operand
Type | Format |
---|---|
Address | [@20] |
Register | [%x] |
Register+offset |
[%x+20]
|
Variable | [$age] |
Name | Required | Purpose |
---|---|---|
vars | No | Define global variables |
main | Yes | Main function source code |
Video memory starts at 5120 and is 8k of memory, one for every pixel in the 128x64 screen. Write a byte to an address to change the corresponding pixel’s color.
These are the color values available currently:
Color | Value |
---|---|
white | 0 |
black | 1 |
red | 2 |
green | 3 |
blue | 4 |
vars:
video int 5120
main:
mov $video %z
mov8 #4 [%z]
mov8 #2 [%z+1000]
mov8 #3 [%z+2000]
mov8 #1 [%z+5000]