1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-09-29 09:20:55 +10:00

avra: add IF, .. THEN,

I decided to keep SKIP, .. TO, (renamed from AT,) around and limit
IF, .. THEN, to the simple BRNE case.
This commit is contained in:
Virgil Dupras 2020-05-19 10:26:57 -04:00
parent 8bbd29d37d
commit 7a41c5c6f9
2 changed files with 6 additions and 5 deletions

View File

@ -2,13 +2,14 @@
: LBL! ( l -- ) PC SWAP ! ; : LBL! ( l -- ) PC SWAP ! ;
: LBL, ( l op -- ) SWAP @ 1- SWAP EXECUTE A,, ; : LBL, ( l op -- ) SWAP @ 1- SWAP EXECUTE A,, ;
: SKIP, PC 0 A,, ; : SKIP, PC 0 A,, ;
: AT, ( opw pc ) : TO, ( opw pc )
( warning: pc is a PC offset, not a mem addr! ) ( warning: pc is a PC offset, not a mem addr! )
2 * ORG @ + PC 1- H@ ( opw addr tgt hbkp ) 2 * ORG @ + PC 1- H@ ( opw addr tgt hbkp )
ROT HERE ! ( opw tgt hbkp ) SWAP ROT EXECUTE H@ ! ( hbkp ) ROT HERE ! ( opw tgt hbkp ) SWAP ROT EXECUTE H@ ! ( hbkp )
HERE ! ; HERE ! ;
( L1 FLBL, .. L1 ' RJMP FLBL! ) ( L1 FLBL, .. L1 ' RJMP FLBL! )
: FLBL, ( l -- ) LBL! 0 A,, ; : FLBL, ( l -- ) LBL! 0 A,, ;
: FLBL! ( l opw -- ) SWAP @ AT, ; : FLBL! ( l opw -- ) SWAP @ TO, ;
: BEGIN, PC ; : BEGIN, PC ;
: AGAIN, ( op ) SWAP 1- SWAP EXECUTE A,, ; : AGAIN, ( op ) SWAP 1- SWAP EXECUTE A,, ;
: IF, ['] BREQ SKIP, ; : THEN, TO, ;

View File

@ -297,7 +297,7 @@ RET,
L8 ' RCALL FLBL! ( checkBoundsY ) L8 ' RCALL FLBL! ( checkBoundsY )
( Check that Y is within bounds, reset to SRAM_START if not. ) ( Check that Y is within bounds, reset to SRAM_START if not. )
28 ( YL ) TST, 28 ( YL ) TST,
' BREQ SKIP, RET, ( not zero, nothing to do ) AT, IF, RET, ( not zero, nothing to do ) THEN,
( YL is zero. Reset Z ) ( YL is zero. Reset Z )
29 ( YH ) CLR, 29 ( YH ) CLR,
28 ( YL ) SRAM_START 0xff AND LDI, 28 ( YL ) SRAM_START 0xff AND LDI,
@ -306,7 +306,7 @@ RET,
L3 ' RCALL FLBL! ( checkBoundsZ ) L3 ' RCALL FLBL! ( checkBoundsZ )
( Check that Z is within bounds, reset to SRAM_START if not. ) ( Check that Z is within bounds, reset to SRAM_START if not. )
30 ( ZL ) TST, 30 ( ZL ) TST,
' BREQ SKIP, RET, ( not zero, nothing to do ) AT, IF, RET, ( not zero, nothing to do ) THEN,
( ZL is zero. Reset Z ) ( ZL is zero. Reset Z )
31 ( ZH ) CLR, 31 ( ZH ) CLR,
30 ( ZL ) SRAM_START 0xff AND LDI, 30 ( ZL ) SRAM_START 0xff AND LDI,
@ -318,7 +318,7 @@ L5 ' RCALL FLBL! L6 ' RCALL FLBL! ( checkParity )
16 1 LDI, 16 1 LDI,
BEGIN, BEGIN,
19 LSR, 19 LSR,
' BRCC SKIP, 16 INC, ( carry set? we had a 1 ) AT, ' BRCC SKIP, 16 INC, ( carry set? we had a 1 ) TO,
19 TST, ( is r19 zero yet? ) 19 TST, ( is r19 zero yet? )
' BRNE AGAIN, ( no? loop ) ' BRNE AGAIN, ( no? loop )
16 0x1 ANDI, 16 0x1 ANDI,