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.byte 1
dup.hword 2 dup.hword 2
dup.word 3 dup.word 3
malloc.byte 1 malloc.byte
malloc.hword 2 malloc.hword
malloc.word 3 malloc.word
malloc.stack.byte mset.byte
malloc.stack.hword mset.hword
malloc.stack.word mset.word
mset.byte 1 mget.byte
mset.hword 2 mget.hword
mset.word 3 mget.word
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
not.byte not.byte
not.hword not.hword
not.word not.word

View File

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