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

move program/ and asm/ directories to examples/

This commit is contained in:
Henrik Hautakoski 2018-12-18 13:31:07 +01:00
parent d73e2ab710
commit 04689fc69a
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA
8 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,33 @@
; -- 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

15
examples/asm/mov_test.as Normal file
View file

@ -0,0 +1,15 @@
; mov h/l test.
; Using 2 instructions to store a 16-bit words is abit tricky to write code for
; Storing 32767 = (2^15) - 1 (highest value in 2's complement 16-bit).
; MSB (signed flag) = 0, rest 1.
; H [0111 1111] L [1111 1111]
movl $0x0, -1
movh $0x0, 127
; Storing -32768 = (2^15) (highest value in 2's complement 16-bit).
; MSB (signed flag) = 1, rest 0.
; H [1000 0000] L [0000 0000]
movl $0x1, 0
movh $0x1, -128

15
examples/asm/test.as Normal file
View 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

View file

@ -0,0 +1 @@
/H<>/E<>/L<><02>/O<>/ <20>/W<>/O<>/R<>/L<>/D<>

BIN
examples/bin/jr.m16 Normal file

Binary file not shown.

BIN
examples/bin/jump.m16 Normal file

Binary file not shown.

BIN
examples/bin/test.m16 Normal file

Binary file not shown.

BIN
examples/bin/write_mem.m16 Normal file

Binary file not shown.