use inline strings
This commit is contained in:
parent
fa800fcfba
commit
b770055b1b
|
@ -15,7 +15,6 @@
|
|||
|
||||
%NL { #0a18 DEO }
|
||||
%SP { #2018 DEO }
|
||||
%WR { #18 DEO }
|
||||
%HX { ;emit/short JSR2 }
|
||||
|
||||
|0000
|
||||
|
@ -24,59 +23,59 @@
|
|||
|
||||
|0100
|
||||
( initialize arena: 16 cells x 4 bytes each )
|
||||
LIT "i WR LIT "n WR LIT "i WR LIT "t WR
|
||||
;print JSR2 "init 20 00
|
||||
#0040 #0004 ;init-arena JSR2 .arena STZ2
|
||||
SP ;arenas HX SP ;arena-pos LDA2 HX NL
|
||||
;arenas HX SP ;arena-pos LDA2 HX NL
|
||||
|
||||
( display the metadata about the arena )
|
||||
LIT "h WR LIT "e WR LIT "a WR LIT "d WR LIT "e WR LIT "r WR LIT "s WR SP
|
||||
;print JSR2 "headers 20 00
|
||||
.arena LDZ2 ;arena-item JSR2 HX SP
|
||||
.arena LDZ2 ;arena-next JSR2 HX SP
|
||||
.arena LDZ2 ;arena-data JSR2 HX SP
|
||||
.arena LDZ2 ;arena-header JSR2 HX NL
|
||||
|
||||
( start allocating, addresses should increase in steps of 4 )
|
||||
LIT "a WR LIT "l WR LIT "l WR LIT "o WR LIT "c WR SP
|
||||
;print JSR2 "alloc 20 00
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX NL
|
||||
|
||||
( clear the arena )
|
||||
LIT "c WR LIT "l WR LIT "e WR LIT "a WR LIT "r WR NL
|
||||
;print JSR2 "clear 0a 00
|
||||
.arena LDZ2 ;clear-arena JSR2
|
||||
|
||||
( allocate again, addresses should be the same as before )
|
||||
LIT "a WR LIT "l WR LIT "l WR LIT "o WR LIT "c WR SP
|
||||
;print JSR2 "alloc 20 00
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX NL
|
||||
|
||||
( clear again )
|
||||
LIT "c WR LIT "l WR LIT "e WR LIT "a WR LIT "r WR NL
|
||||
;print JSR2 "clear 0a 00
|
||||
.arena LDZ2 ;clear-arena JSR2
|
||||
|
||||
( use alloc-of, addresses should be the same as above )
|
||||
LIT "a WR LIT "l WR LIT "l WR LIT "o WR LIT "c WR LIT "- WR LIT "o WR LIT "f WR SP
|
||||
;print JSR2 "alloc-of 20 00
|
||||
#0004 ;alloc-of JSR2 HX SP
|
||||
#0004 ;alloc-of JSR2 HX SP
|
||||
#0004 ;alloc-of JSR2 HX SP
|
||||
#0004 ;alloc-of JSR2 HX NL
|
||||
|
||||
( keep allocating, save one allocated address to use later )
|
||||
LIT "a WR LIT "l WR LIT "l WR LIT "o WR LIT "c WR SP
|
||||
;print JSR2 "alloc 20 00
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 DUP2 .saved STZ2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX NL
|
||||
|
||||
( free the saved address )
|
||||
LIT "f WR LIT "r WR LIT "e WR LIT "e WR NL
|
||||
;print JSR2 "free 0a 00
|
||||
.saved LDZ2 ;free JSR2
|
||||
|
||||
( continue allocating, should see free address and then unused one )
|
||||
LIT "a WR LIT "l WR LIT "l WR LIT "o WR LIT "c WR SP
|
||||
;print JSR2 "alloc 20 00
|
||||
.arena LDZ2 ;alloc JSR2 HX SP
|
||||
.arena LDZ2 ;alloc JSR2 HX NL
|
||||
|
||||
|
@ -89,4 +88,9 @@
|
|||
&char #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
||||
JMP2r
|
||||
|
||||
( usage: ;print JSR2 "literal-string 00 <rest-of-code> )
|
||||
@print ( -- )
|
||||
LDArk STHr DUP #18 DEO
|
||||
INC2r ,print JCN JMP2r
|
||||
|
||||
~alloc.tal
|
||||
|
|
Loading…
Reference in New Issue