Update examples for change in memory allocation operations

This commit is contained in:
2024-07-07 19:32:21 +01:00
parent c4489af073
commit 1ad3fdadb4
2 changed files with 21 additions and 23 deletions

View File

@@ -22,24 +22,15 @@ main:
dup.byte 1
dup.hword 2
dup.word 3
malloc.byte 1
malloc.hword 2
malloc.word 3
malloc.stack.byte
malloc.stack.hword
malloc.stack.word
mset.byte 1
mset.hword 2
mset.word 3
mset.stack.byte
mset.stack.hword
mset.stack.word
mget.byte 1
mget.hword 2
mget.word 3
mget.stack.byte
mget.stack.hword
mget.stack.word
malloc.byte
malloc.hword
malloc.word
mset.byte
mset.hword
mset.word
mget.byte
mget.hword
mget.word
not.byte
not.hword
not.word

View File

@@ -5,18 +5,25 @@
global main
main:
;; Allocate a buffer of 3 characters
malloc.byte 3
push.word 3
malloc.byte
mov.word 0
;; Setup the buffer to be equivalent to "abc"
push.reg.word 0
push.byte 'a'
mset.byte 0
push.word 0
;; mset 0 'a'
mset.byte
push.reg.word 0
push.byte 'b'
mset.byte 1
push.word 1
;; mset 1 'b'
mset.byte
push.reg.word 0
push.byte 'c'
mset.byte 2
push.word 2
;; mset 2 'c'
mset.byte
;; Save buffer to W[8] because the first 8 registers should be
;; reserved for library routines as it may be overwritten
@@ -41,7 +48,7 @@ print_cptr:
loopback:
push.reg.word 0
push.reg.word 1
mget.stack.byte
mget.byte
print.char
;; I += 1