diff --git a/cli/opctest/opctest.tal b/cli/opctest/opctest.tal index fe6dacb..5e78eb9 100644 --- a/cli/opctest/opctest.tal +++ b/cli/opctest/opctest.tal @@ -6,19 +6,34 @@ |0100 - ( part 1 requirements: + ( part 1 > LIT2: Puts a short on the stack > #18 DEO: Write a letter in terminal ) LIT2 "kO #18 DEO #18 DEO #0a18 DEO - ( part 2 requirements: + ( part 2 + > LITr: Put a byte on return stack + > LIT: Puts a byte on the stack + > STH: Move a byte from working stack to return stack + > STH2r: Move a short from return stack to working stack ) + + LITr "k LIT "O STH STH2r #18 DEO #18 DEO #0a18 DEO + + ( part 3 + > LIT2r: Put a short on return stack + > DUP: Duplicate byte + > ADDr: Add bytes on return stack ) + + LIT2r "k 4d #01 DUP STH ADDr STH ADDr STH2r #18 DEO #18 DEO #0a18 DEO + + ( part 4 > JSI: Subroutine to relative absolute address > JMP2r: Jumps to absolute address on return stack ) subroutine - ( part 3 requirements: + ( part 5 > POP2: Removes a short from the stack > INC2: Increments short on stack > LDAk: Non-destructive load byte from absolute address @@ -26,18 +41,9 @@ ;Dict/ok pstr #0a18 DEO - ( part 4 requirements: - > LIT2r: Put a short on return stack - > STH: Move a byte from working stack to return stack - > STH2r: Move a short from return stack to working stack ) - - LITr "k LIT "O STH STH2r #18 DEO #18 DEO #0a18 DEO - - ( part 5 requirements: + ( part 6 > GTH2k: Non-destructive greater-than short > LDA2k: Non-destructive load short from absolute address - > ADDr: Add bytes on return stack - > DUP: Duplicate byte > STA2: Store short at absolute address ) LIT2r 0000 diff --git a/cli/stdlib/stdlib.tal b/cli/stdlib/stdlib.tal index 9114df3..fa7559a 100644 --- a/cli/stdlib/stdlib.tal +++ b/cli/stdlib/stdlib.tal @@ -35,6 +35,15 @@ JMP2r ( @|stdlib ) +@pstr ( str* -- ) LDAk ?&w POP2 JMP2r &w LDAk #18 DEO INC2 LDAk ?&w POP2 JMP2r +@scap ( str* -- end* ) LDAk ?&w JMP2r &w INC2 LDAk ?&w JMP2r +@sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r +@slen ( str* -- len* ) DUP2 scap SWP2 SUB2 JMP2r +@scat ( src* dst* -- ) scap +@scpy ( src* dst* -- ) OVR2 LDA ?&e POP2 POP2 JMP2r &e STH2 &w LDAk STH2kr STA INC2r INC2 LDAk ?&w POP2 #00 STH2r STA JMP2r +@sclr ( str* -- ) LDAk ?&w POP2 JMP2r &w STH2k #00 STH2r STA INC2 LDAk ?&w POP2 JMP2r +@scmp ( a* b* -- f ) STH2 &l LDAk LDAkr STHr ANDk #00 EQU ?&e NEQk ?&e POP2 INC2 INC2r !&l &e NIP2 POP2r EQU JMP2r + @sdec ( str* -- val* ) LIT2r 0000 @@ -69,6 +78,9 @@ JMP2r JMP2r +( +@|assets ) + @dict [ &dec1 "4660 $1 &dec2 "291 $1