1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 12:38:05 +11:00

avra: implement BR*

Getting good! still advancing on ps2ctl in sms/kbd and still
matching reference binary.
This commit is contained in:
Virgil Dupras 2020-05-18 20:34:06 -04:00
parent cdddfdefae
commit e0bc14e55c
5 changed files with 44 additions and 16 deletions

View File

@ -1 +1 @@
1 9 LOADR+ 1 10 LOADR+

View File

@ -4,5 +4,4 @@
PC - DUP 0< IF 0x800 + _r7ffc 0x800 OR ELSE _r7ffc THEN ; PC - DUP 0< IF 0x800 + _r7ffc 0x800 OR ELSE _r7ffc THEN ;
: RJMP _raddr12 0xc000 OR ; : RJMP _raddr12 0xc000 OR ;
: RCALL _raddr12 0xd000 OR ; : RCALL _raddr12 0xd000 OR ;
: RJMP, RJMP A,, ; : RJMP, RJMP A,, ; : RCALL, RCALL A,, ;
: RCALL, RCALL A,, ;

22
blk/669
View File

@ -1,12 +1,12 @@
( L1 LBL! .. L1 @ RJMP, ) ( a -- k7, absolute addr a, relative to PC in a k7 addr )
: LBL! ( l -- ) PC SWAP ! ; : _r3fc DUP 0x3f > IF _oor THEN ;
( L1 FLBL, .. RJMPOP L1 FLBL! ) : _raddr7
: FLBL, ( l -- ) LBL! 0 A,, ; PC - DUP 0< IF 0x40 + _r3fc 0x40 OR ELSE _r3fc THEN ;
: FLBL! ( l opw -- ) : _brbx ( a b op -- a ) OR SWAP _raddr7 3 LSHIFT OR ;
( warning: l is a PC offset, not a mem addr! ) : BRBC 0xf400 _brbx ; : BRBS 0xf000 _brbx ; : BRCC 0 BRBC ;
SWAP @ 2 * ORG @ + PC 1- H@ ( opw addr tgt hbkp ) : BRCS 0 BRBS ; : BREQ 1 BRBS ; : BRNE 1 BRBC ; : BRGE 4 BRBC ;
ROT HERE ! ( opw tgt hbkp ) SWAP ROT EXECUTE H@ ! ( hbkp ) : BRHC 5 BRBC ; : BRHS 5 BRBS ; : BRID 7 BRBC ; : BRIE 7 BRBS ;
HERE ! ; : BRLO BRCS ; : BRLT 4 BRBS ; : BRMI 2 BRBS ; : BRPL 2 BRBC ;
: FRJMP! ( l -- ) ['] RJMP FLBL! ; : BRSH BRCC ; : BRTC 6 BRBC ; : BRTS 6 BRBS ; : BRVC 3 BRBC ;
: FRCALL! ( l -- ) ['] RCALL FLBL! ; : BRVS 3 BRBS ;

11
blk/670 Normal file
View File

@ -0,0 +1,11 @@
( L1 LBL! .. L1 ' RJMP LBL, )
: LBL! ( l -- ) PC SWAP ! ;
: LBL, ( l op -- ) SWAP @ 1- SWAP EXECUTE A,, ;
( L1 FLBL, .. L1 ' RJMP FLBL! )
: FLBL, ( l -- ) LBL! 0 A,, ;
: FLBL! ( l opw -- )
( warning: l is a PC offset, not a mem addr! )
SWAP @ 2 * ORG @ + PC 1- H@ ( opw addr tgt hbkp )
ROT HERE ! ( opw tgt hbkp ) SWAP ROT EXECUTE H@ ! ( hbkp )
HERE ! ;

View File

@ -40,6 +40,7 @@ Z: pointer to the next scan code to push to the 595 )
0x35 CONSTANT MCUCR 0x35 CONSTANT MCUCR
0x33 CONSTANT TCCR0B 0x33 CONSTANT TCCR0B
0x3b CONSTANT GIMSK 0x3b CONSTANT GIMSK
0x38 CONSTANT TIFR
0x16 CONSTANT PINB 0x16 CONSTANT PINB
0x17 CONSTANT DDRB 0x17 CONSTANT DDRB
0x18 CONSTANT PORTB 0x18 CONSTANT PORTB
@ -56,13 +57,13 @@ L2 FLBL, ( hdlINT0 )
( Read DATA and set GPIOR0/0 if high. Then, set flag T. ( Read DATA and set GPIOR0/0 if high. Then, set flag T.
no SREG fiddling because no SREG-modifying instruction ) no SREG fiddling because no SREG-modifying instruction )
L2 FRJMP! ( hdlINT0 ) L2 ' RJMP FLBL! ( hdlINT0 )
PINB DATA SBIC, PINB DATA SBIC,
GPIOR0 0 SBI, GPIOR0 0 SBI,
SET, SET,
RETI, RETI,
L1 FRJMP! ( main ) L1 ' RJMP FLBL! ( main )
16 RAMEND 0xff AND LDI, 16 RAMEND 0xff AND LDI,
SPL 16 OUT, SPL 16 OUT,
16 RAMEND 8 RSHIFT LDI, 16 RAMEND 8 RSHIFT LDI,
@ -95,4 +96,21 @@ DDRB LR SBI,
SEI, SEI,
L1 LBL! ( loop ) L1 LBL! ( loop )
L2 FLBL, ( BRTS processbit. flag T set? we have a bit to
process )
28 ( YL ) 30 ( ZL ) CP, ( if YL == ZL, buf is empty )
L3 FLBL, ( BRNE sendTo164. YL != ZL? buf has data )
( nothing to do. Before looping, let's check if our
communication timer overflowed. )
16 TIFR IN,
16 1 ( TOV0 ) SBRC,
L4 FLBL, ( RJMP processbitReset, timer0 overflow? reset )
( Nothing to do for real. )
L1 ' RJMP LBL, ( loop )
( Process the data bit received in INT0 handler. )
L2 ' BRTS FLBL! ( processbit )
19 GPIOR0 IN, ( backup GPIOR0 before we reset T )
19 0x1 ANDI, ( only keep the first flag )
GPIOR0 0 CBI,
CLT, ( ready to receive another bit )