Compare commits

..

2 Commits

Author SHA1 Message Date
Virgil Dupras
44b065ff99 ti84: unify drivers
No more low/high
2020-05-12 12:41:47 -04:00
Virgil Dupras
1094ec9c57 Make DO..LOOP stable
DO and LOOP now only compile words from stable ABI, which make them
suitable for xcomp. This will greatly simplify driver writing and
allow us to mostly avoid the low/high divide in drivers.

LEAVE is still xcomp-incompatible though.

This make us very very tight for "<0x100" limit for literal words.
Hopefully, we won't need more stuff in that area of the binary...
2020-05-12 10:40:59 -04:00
18 changed files with 53 additions and 70 deletions

View File

@ -8,9 +8,9 @@ LD [rr, rn, ddnn, (nn)HL, HL(nn), dd(nn), (nn)dd, rIXY, IXYr,
(DE)A, A(DE)]
ADD [r, n, HLss, IXss, IXIX, IYss, IYIY]
ADC [r, HLss]
CP [r, n]
CP [r, n, (IXY+)]
SBC [r, HLss]
SUB [r, n]
PUSH [qq] POP [qq]
INC [r, ss] DEC [r, ss]
INC [r, ss, (IXY+)] DEC [r, ss, (IXY+)]
AND [r, n] OR [r, n] XOR [r, n] (cont.)

View File

@ -8,3 +8,5 @@
OR A,
;
0x04 OP1r INCr, 0x05 OP1r DECr,
: INC(IXY+), INCr, A, ;
: DEC(IXY+), DECr, A, ;

View File

@ -11,3 +11,4 @@
0xa0 OP1r0 ANDr, 0xb8 OP1r0 CPr,
0xb0 OP1r0 ORr, 0x90 OP1r0 SUBr,
0x98 OP1r0 SBCr, 0xa8 OP1r0 XORr,
: CP(IXY+), CPr, A, ;

View File

@ -2,11 +2,15 @@
these words' offset need to be stable, so they're part of
the "stable ABI" )
'E' A, 'X' A, 'I' A, 'T' A,
0 A,, ( prev )
0 A,, ( prev )
4 A,
H@ XCURRENT ! ( set current tip of dict, 0x42 )
0x17 A, ( nativeWord )
0x14 BCALL, ( popRS )
HL PUSHqq, IY POPqq, ( --> IP )
JPNEXT,
CODE (br) ( 0x53 )
L2 BSET ( used in CBR )
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,
DE ADDIYss,
JPNEXT,

19
blk/285
View File

@ -1,6 +1,15 @@
CODE (br) ( 0x53 )
L2 BSET ( used in CBR )
E 0 IY+ LDrIXY,
D 1 IY+ LDrIXY,
DE ADDIYss,
CODE (?br) ( 0x67 )
HL POPqq, chkPS,
HLZ,
JRZ, L2 BWR ( BR + 2. False, branch )
L1 BSET ( loop will jump here )
( True, skip next 2 bytes and don't branch )
IY INCss, IY INCss,
JPNEXT,
CODE (loop) ( 0x77 )
0 IX+ INC(IXY+), IFZ, 1 IX+ INC(IXY+), THEN, ( I++ )
( Jump if I <> I' )
A 0 IX+ LDrIXY, 2 IX- CP(IXY+), JRNZ, L2 BWR ( branch )
A 1 IX+ LDrIXY, 1 IX- CP(IXY+), JRNZ, L2 BWR ( branch )
( don't branch )
IX DECss, IX DECss, IX DECss, IX DECss, JR, L1 BWR

28
blk/286
View File

@ -1,12 +1,16 @@
CODE (?br) ( 0x67 )
HL POPqq,
chkPS,
HLZ,
JRZ, L2 BWR ( BR + 2. False, branch )
( True, skip next 2 bytes and don't branch )
IY INCss,
IY INCss,
JPNEXT,
( END OF STABLE ABI )
CODE >R ( 0xa8 )
HL POPqq, chkPS,
17 BCALL, ( 17 == pushRS )
;CODE
CODE 2>R ( 0xb9 )
DE POPqq, HL POPqq, chkPS,
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
;CODE
CODE R> ( 0xce )
20 BCALL, ( 20 == popRS )
HL PUSHqq,
;CODE
CODE 2R> ( 0xdc )
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
HL PUSHqq, DE PUSHqq,
;CODE ( END OF STABLE ABI )

View File

@ -1,4 +1,4 @@
PC ORG @ 0x22 + ! ( litWord )
PC ORG @ 0x22 + ! ( litWord, 0xf7, very tight on the 0x100 limit )
( Like numberWord, but instead of being followed by a 2 bytes
number, it's followed by a null-terminated string. When
called, puts the string's address on PS )

17
blk/326
View File

@ -1,17 +0,0 @@
CODE >R
HL POPqq, chkPS,
17 BCALL, ( 17 == pushRS )
;CODE
CODE 2>R
DE POPqq, HL POPqq, chkPS,
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
;CODE
CODE R>
20 BCALL, ( 20 == popRS )
HL PUSHqq,
;CODE
CODE 2R>
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
HL PUSHqq, DE PUSHqq,
;CODE

View File

@ -11,6 +11,6 @@ system. More details in B260.
These rules result in some practicals do's and dont's:
1. IF, UNTIL, AGAIN are fine, but *not* LOOP.
1. No LEAVE in DO..LOOP
(cont.)

View File

@ -4,5 +4,5 @@
( In addition to pushing H@ this compiles 2>R so that loop
variables are sent to PS at runtime )
: DO COMPILE 2>R H@ ; IMMEDIATE
: LOOP COMPILE (loop) H@ - , ; IMMEDIATE
: LEAVE R> R> DROP I 1- >R >R ;

16
blk/432
View File

@ -1,16 +0,0 @@
( Increase loop counter and returns whether we should loop. )
: _
R> ( IP, keep for later )
R> 1+ ( ip i+1 )
DUP >R ( ip i )
I' = ( ip f )
SWAP >R ( f )
;
( One could think that we should have a sub word to avoid all
these COMPILE, but we can't because otherwise it messes with
the RS )
: LOOP
COMPILE _ COMPILE (?br)
H@ - ,
COMPILE 2R> COMPILE 2DROP
; IMMEDIATE

View File

@ -1,5 +1,3 @@
: LEAVE R> R> DROP I 1- >R >R ;
: ROLL
DUP NOT IF EXIT THEN
1+ DUP PICK ( n val )

View File

@ -1,7 +1,7 @@
TI-84+ LCD driver
Implement (emit) on TI-84+ (for now)'s LCD screen. The low
level part are blocks 555-557 and high level ones are 558-560.
Implement (emit) on TI-84+ (for now)'s LCD screen.
Load range: 555-560
The screen is 96x64 pixels. The 64 rows are addressed directly
with CMD_ROW but columns are addressed in chunks of 6 or 8 bits

View File

@ -12,5 +12,5 @@
LCD_CURY C@ _row! LCD_CURX C@ 8 / 1+ _col!
FNTH 0 DO LCD_BUF FNTH + I + C@ _data! LOOP
LCD_CURX C@ FNTW + 1+ DUP LCD_CURX C! ( x )
[ 96 FNTW - LITN ] > IF _lf THEN ;
96 FNTW - > IF _lf THEN ;

View File

@ -1,4 +1,4 @@
: (emit)
DUP 0xd = IF DROP _lf EXIT THEN
DUP 0x20 0x7e =><= NOT IF DROP EXIT THEN
0x20 - FNTH * ['] ~FNT + _glyph> ;
0x20 - FNTH * ~FNT + _glyph> ;

View File

@ -1,6 +1,6 @@
Keyboard driver
Low layer range: 566-570
Load range: 566-570
Implement a (key) word that interpret keystrokes from the
builtin keyboard. The word waits for a digit to be pressed and

Binary file not shown.

View File

@ -65,16 +65,14 @@ CURRENT @ XCURRENT !
0x100 BIN( !
282 LOAD ( boot.z80 )
393 LOAD ( icore low )
555 557 LOADR ( LCD low )
CREATE ~FNT CPFNT3x5
555 560 LOADR ( LCD low )
566 570 LOADR ( KBD low )
415 LOAD ( icore high )
(entry) ~FNT CPFNT3x5
(entry) _
( Update LATEST )
PC ORG @ 8 + !
422 437 XPACKR ( core )
558 560 XPACKR ( LCD high )
438 451 XPACKR ( print fmt readln )
422 451 XPACKR ( core print fmt readln )
," : _ LCD$ KBD$ (ok) RDLN$ ; _ "
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
H@ 256 /MOD 2 PC! 2 PC!