aboutsummaryrefslogtreecommitdiff
path: root/test.asm
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-02 23:29:50 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-02 23:29:50 +0000
commit07f64b796d3aa2ca33496df019148d4d9f18eb3e (patch)
tree9f00aeaefd659387eaf6ea6949ae40ad7c4fd8b4 /test.asm
parent6dfc4ceaeb4090edc199ec894aab4cf6233ce130 (diff)
downloadovm-07f64b796d3aa2ca33496df019148d4d9f18eb3e.tar.gz
ovm-07f64b796d3aa2ca33496df019148d4d9f18eb3e.tar.bz2
ovm-07f64b796d3aa2ca33496df019148d4d9f18eb3e.zip
Implemented a routine which prints out a buffer of characters and use it
All in my assembly/virtual machine!
Diffstat (limited to 'test.asm')
-rw-r--r--test.asm41
1 files changed, 22 insertions, 19 deletions
diff --git a/test.asm b/test.asm
index 0962956..6f857b8 100644
--- a/test.asm
+++ b/test.asm
@@ -11,32 +11,35 @@
mset.byte 2
push.reg.word 0
- msize
- malloc.stack.byte
- mov.word 1
- push.word 0
- mov.word 2
+ mov.word 8
push.reg.word 0
- push.reg.word 2
- push.word 1
+ call print_cptr
+ push.reg.word 8
+ mdelete
+
+ push.byte '\n'
+ print.char
+
+ halt
+
+;;; print_cptr: Prints pointer to a buffer of characters. Pointer
+;;; should be on the stack as a word.
+print_cptr:
+ mov.word 0
+ push.word 0
+ mov.word 1
push.reg.word 0
- msize
- sub.word
- sub.word
+ push.reg.word 1
mget.stack.byte
- mov.byte 24
+ print.char
push.reg.word 1
- push.reg.byte 24
- push.reg.word 2
- mset.stack.byte
- push.reg.word 2
push.word 1
plus.word
- mov.word 2
- push.reg.word 2
+ mov.word 1
+ push.reg.word 1
push.reg.word 0
msize
eq.word
not.byte
- jump.if.byte 17
- halt
+ jump.if.byte *-13
+ ret