reading input
This commit is contained in:
parent
98ce1e0ed6
commit
c1a11c0522
62
hoax.tal
62
hoax.tal
|
@ -70,7 +70,7 @@
|
|||
( #f 2 bytes )
|
||||
( 0 2 bytes )
|
||||
( 16383 2 bytes )
|
||||
( 16384 7 bytes )
|
||||
( -16384 2 bytes )
|
||||
( 16384 7 bytes )
|
||||
( 4294967295 7 bytes )
|
||||
( 4294967296 12 bytes )
|
||||
|
@ -107,6 +107,22 @@
|
|||
|
||||
|0100
|
||||
;init-hoax JSR2
|
||||
;on-char #10 DEO2
|
||||
;demo JSR2
|
||||
( DEBUG EXIT )
|
||||
BRK
|
||||
|
||||
@on-char ( -> )
|
||||
#12 DEI #0a EQU ,&newline JCN
|
||||
#12 DEI ;buffer/pos LDA2 STAk ( c pos ; addr<-c )
|
||||
INC2 ;buffer/pos STA2 POP BRK ( )
|
||||
&newline
|
||||
#00 ;buffer/pos LDA2 STA ( ; addr<-00 )
|
||||
;buffer/input DUP2 ;buffer/pos STA2
|
||||
;echo JSR2 "read: 20 00 ;print JSR2 #0a18 DEO
|
||||
BRK
|
||||
|
||||
@demo
|
||||
null ;null? JSR2 D
|
||||
null ;list? JSR2 D
|
||||
null ;number? JSR2 D
|
||||
|
@ -126,7 +142,7 @@
|
|||
#13 LIT2 "ab LIT2 "c 00 ;make-obj JSR2 D
|
||||
#23 LIT2 "ab LIT2 "c 00 ;make-obj JSR2 D
|
||||
#24 LIT2 "ab LIT2 "c 00 ;make-obj JSR2 D
|
||||
DEBUG EXIT
|
||||
JMP2r
|
||||
|
||||
@emit
|
||||
&short SWP ,&byte JSR
|
||||
|
@ -134,10 +150,14 @@
|
|||
&char #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
||||
JMP2r
|
||||
|
||||
( usage: ;print JSR2 "literal-string 00 <rest-of-code> )
|
||||
@print ( -- )
|
||||
@print ( addr -> )
|
||||
LDAk ,&ok JCN POP2 JMP2r
|
||||
&ok LDAk #18 DEO INC2 ,print JMP
|
||||
|
||||
( usage: ;echo JSR2 "literal-string 00 <rest-of-code> )
|
||||
@echo ( -> )
|
||||
LDArk STHr DUP #18 DEO
|
||||
INC2r ,print JCN JMP2r
|
||||
INC2r ,echo JCN JMP2r
|
||||
|
||||
@init-hoax ( -> )
|
||||
( need to ensure that ;arenas is )
|
||||
|
@ -145,17 +165,23 @@
|
|||
( obj = (addr - arenas) / 5 )
|
||||
( addr = (obj * 5) + arenas )
|
||||
;arenas #0005 DIV2 #0005 MUL2 ;arenas EQU2 ,&ok JCN
|
||||
;print JSR2 "invalid 20 "arenas 20 "( 00
|
||||
;echo JSR2 "invalid 20 "arenas 20 "( 00
|
||||
;arenas ;emit/short JSR2
|
||||
;print JSR2 ") 20 "not 20 "divisible 20 "by 20 "5 0a 00
|
||||
;echo JSR2 ") 20 "not 20 "divisible 20 "by 20 "5 0a 00
|
||||
EXIT
|
||||
&ok
|
||||
( allocate 8192 5-byte object slots )
|
||||
#2000 #0005 ;init-arena JSR2 ;objects STA2
|
||||
|
||||
( set up buffers )
|
||||
;buffer/input ;buffer/pos STA2
|
||||
JMP2r
|
||||
|
||||
@buffers
|
||||
&x $64 &y $64 &z $64
|
||||
@buffer
|
||||
&pos $2 &input $80
|
||||
( &x-pos $2 &x $40
|
||||
&y-pos $2 &y $40
|
||||
&z-pos $2 &z $40 )
|
||||
|
||||
@error ( -> )
|
||||
#0000 DIV ( TODO )
|
||||
|
@ -175,14 +201,14 @@
|
|||
DUP2 #5fff GTH2 ,&builtin JCN
|
||||
DUP2 #3fff GTH2 ,&const JCN
|
||||
;display0-object JMP2
|
||||
&litnum #8000 EOR2 ;print JSR2 "0x 00 ;emit/short JMP2
|
||||
&builtin ;print JSR2 "builtin< 00 ;emit/short JSR2 LIT "> #18 DEO JMP2r
|
||||
&const DUP2 false NEQ2 ,¬-false JCN POP2 ;print JSR2 "#f 00 JMP2r
|
||||
¬-false DUP2 true NEQ2 ,¬-true JCN POP2 ;print JSR2 "#t 00 JMP2r
|
||||
¬-true ;print JSR2 "const< 00 ;emit/short JSR2 LIT "> #18 DEO JMP2r
|
||||
&litnum #8000 EOR2 ;echo JSR2 "0x 00 ;emit/short JMP2
|
||||
&builtin ;echo JSR2 "builtin< 00 ;emit/short JSR2 LIT "> #18 DEO JMP2r
|
||||
&const DUP2 false NEQ2 ,¬-false JCN POP2 ;echo JSR2 "#f 00 JMP2r
|
||||
¬-false DUP2 true NEQ2 ,¬-true JCN POP2 ;echo JSR2 "#t 00 JMP2r
|
||||
¬-true ;echo JSR2 "const< 00 ;emit/short JSR2 LIT "> #18 DEO JMP2r
|
||||
|
||||
@display0-object ( ref$ -> )
|
||||
DUP2 #0000 NEQ2 ,¬-null JCN POP2 ;print JSR2 "null 00 JMP2r
|
||||
DUP2 #0000 NEQ2 ,¬-null JCN POP2 ;echo JSR2 "null 00 JMP2r
|
||||
¬-null ;obj-to-addr JSR2 ( addr* )
|
||||
LDAk #50 LTH ,¬-unk JCN ;display0-unk JMP2
|
||||
¬-unk LDAk #40 LTH ,¬-rat JCN ;display0-rat JMP2
|
||||
|
@ -192,7 +218,7 @@
|
|||
¬-sym ;display0-lst JMP2
|
||||
|
||||
@display0-unk ( addr* -> )
|
||||
;print JSR "unknown< 00 ;emit/short JSR2 LIT "> #18 DEO JMP2r
|
||||
;echo JSR "unknown< 00 ;emit/short JSR2 LIT "> #18 DEO JMP2r
|
||||
@display0-rat ( addr* -> )
|
||||
INC2 LDA2k ;display0 JSR2
|
||||
LIT "/ #18 DEO
|
||||
|
@ -200,7 +226,7 @@
|
|||
@display0-int ( addr* -> )
|
||||
LDAk #80 LTH ,&non-neg JCN LIT "- #18 DEO
|
||||
&non-neg
|
||||
;print JSR2 "0x 00
|
||||
;echo JSR2 "0x 00
|
||||
&loop
|
||||
LDAk #04 AND ,&is-long JCN
|
||||
INC2 LDA2k ;emit/short JSR2
|
||||
|
@ -243,7 +269,7 @@
|
|||
LDA2 SWP2 ( tail$ head$ )
|
||||
LIT "( #18 DEO ( tail$ head$ )
|
||||
;display0 JSR2 ( tail$ )
|
||||
;print JSR2 20 ". 20 00
|
||||
;echo JSR2 20 ". 20 00
|
||||
;display0 JSR2
|
||||
LIT ") #18 DEO JMP2r
|
||||
|
||||
|
|
Loading…
Reference in New Issue