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

41 lines
639 B
NASM

; 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