hence/examples/add.asm
2022-06-17 13:38:12 +02:00

45 lines
521 B
NASM

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