1
0
Fork 0
mirror of https://github.com/pnx/m16vm synced 2026-06-16 03:44:55 +02:00
m16vm/asm/hello_world.as

33 lines
806 B
ActionScript

; -- Store "Hello World" string in memory.
movl $0x1, 72 ; H
sw $0x0, $0x1, 0
movl $0x1, 69 ; E
sw $0x0, $0x1, 1
movl $0x1, 76 ; L
sw $0x0, $0x1, 2
sw $0x0, $0x1, 3
movl $0x1, 79 ; O
sw $0x0, $0x1, 4
movl $0x1, 32 ; Space
sw $0x0, $0x1, 5
movl $0x1, 87 ; W
sw $0x0, $0x1, 6
movl $0x1, 79 ; O
sw $0x0, $0x1, 7
movl $0x1, 82 ; R
sw $0x0, $0x1, 8
movl $0x1, 76 ; L
sw $0x0, $0x1, 9
movl $0x1, 68 ; D
sw $0x0, $0x1, 10
; -- setup print loop.
movl $0x1, 1 ; Load 1 in R1 (used for increment the counter)
_start:
ld $0xF, $0x0, 0 ; Load memory address stored in R0 into R15
int $0xA, 2 ; Print character
add $0x0, $0x0, $0x1 ; Add 1 (R1) to counter (R0)
beq $0xF, $0x2, 1 ; Branch to "noop" (skipping next instruction) if R15 = 0 (R2 holds 0)
jmp _start ; jump back to "_start" label
noop