mirror of
https://github.com/pnx/m16vm
synced 2026-06-16 03:44:55 +02:00
asm: adding example files
This commit is contained in:
parent
3528c467ac
commit
0f41fc0870
2 changed files with 48 additions and 0 deletions
33
asm/hello_world.as
Normal file
33
asm/hello_world.as
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
; -- Store "Hello World" string in memory.
|
||||
movl $1, 72 ; H
|
||||
sw $0, $1, 0
|
||||
movl $1, 69 ; E
|
||||
sw $0, $1, 1
|
||||
movl $1, 76 ; L
|
||||
sw $0, $1, 2
|
||||
sw $0, $1, 3
|
||||
movl $1, 79 ; O
|
||||
sw $0, $1, 4
|
||||
movl $1, 32 ; Space
|
||||
sw $0, $1, 5
|
||||
movl $1, 87 ; W
|
||||
sw $0, $1, 6
|
||||
movl $1, 79 ; O
|
||||
sw $0, $1, 7
|
||||
movl $1, 82 ; R
|
||||
sw $0, $1, 8
|
||||
movl $1, 76 ; L
|
||||
sw $0, $1, 9
|
||||
movl $1, 68 ; D
|
||||
sw $0, $1, 10
|
||||
|
||||
; -- setup print loop.
|
||||
movl $1, 1 ; Load 1 in R1 (used for increment the counter)
|
||||
_start:
|
||||
ld $15, $0, 0 ; Load memory address stored in R0 into R15
|
||||
int $10, 2 ; Print character
|
||||
add $0, $0, $1 ; Add 1 (R1) to counter (R0)
|
||||
beq $15, $2, 1 ; Branch to "noop" (skipping next instruction) if R15 = 0 (R2 holds 0)
|
||||
jmp 22 ; jump back to "_start" label (not implemented atm)
|
||||
noop
|
||||
15
asm/test.as
Normal file
15
asm/test.as
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
; NOTE: This is just to check the syntax.
|
||||
; No logic behind any of the instructions (will prob crash)
|
||||
movl $0, 3
|
||||
movl $5, 6500
|
||||
; Comment
|
||||
noop ; Comment
|
||||
start0: add $3, $0, $1
|
||||
sw $2, $3, $2
|
||||
ld $5, $0, $3
|
||||
beq $0, $1, 1
|
||||
beq $0, $1, -25
|
||||
beq $0, $1, -4000
|
||||
jr $5, 0
|
||||
int $0, 1
|
||||
jmp 5
|
||||
Loading…
Add table
Add a link
Reference in a new issue