This commit is contained in:
Dominic Grimm 2022-06-17 13:38:12 +02:00
commit 6ef300f402
25 changed files with 2280 additions and 0 deletions

44
examples/add.asm Normal file
View file

@ -0,0 +1,44 @@
PROGRAM_SIZE = (32 * 1024)
INSTRUCTION_SIZE = 3
main_jump = (PROGRAM_SIZE - INSTRUCTION_SIZE - INSTRUCTION_SIZE)
.org 0x0000
push main_jump
jmp
data:
answer:
ANSWER_SIZE = 52
.bw "The answer to life, the universe, and everything is ", 0, ANSWER_SIZE
main:
push answer
loop:
dup
load
emit
inc
dup
push (answer + ANSWER_SIZE)
neq
push loop
jif
drop
push 40
push 2
add
print
push "!"
emit
push "\n"
emit
stp
.org main_jump
push main
jmp

41
examples/hello_world.asm Normal file
View file

@ -0,0 +1,41 @@
; Constants
PROGRAM_SIZE = (32 * 1024)
INSTRUCTION_SIZE = 3
main_jump = (PROGRAM_SIZE - INSTRUCTION_SIZE - INSTRUCTION_SIZE)
; Base organisation / offset
.org 0x0000
; Static data
push main_jump
jmp ; Skip data section as following data is not program code
data:
; Message data
msg:
MSG_SIZE = 12 ; Define size of message
.bw "Hello World!", 0, MSG_SIZE ; Embed byte words in binary
; Main label
main:
push msg
loop:
dup
load
emit
inc
dup
push (msg + MSG_SIZE)
neq
push loop
jif
push "\n"
emit
stp
; Jump to main label
.org main_jump
push main
jmp