mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-28 08:08: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:
parent
cdddfdefae
commit
e0bc14e55c
3
blk/668
3
blk/668
@ -4,5 +4,4 @@
|
||||
PC - DUP 0< IF 0x800 + _r7ffc 0x800 OR ELSE _r7ffc THEN ;
|
||||
: RJMP _raddr12 0xc000 OR ;
|
||||
: RCALL _raddr12 0xd000 OR ;
|
||||
: RJMP, RJMP A,, ;
|
||||
: RCALL, RCALL A,, ;
|
||||
: RJMP, RJMP A,, ; : RCALL, RCALL A,, ;
|
||||
|
22
blk/669
22
blk/669
@ -1,12 +1,12 @@
|
||||
( L1 LBL! .. L1 @ RJMP, )
|
||||
: LBL! ( l -- ) PC SWAP ! ;
|
||||
( L1 FLBL, .. RJMPOP L1 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 ! ;
|
||||
: FRJMP! ( l -- ) ['] RJMP FLBL! ;
|
||||
: FRCALL! ( l -- ) ['] RCALL FLBL! ;
|
||||
( a -- k7, absolute addr a, relative to PC in a k7 addr )
|
||||
: _r3fc DUP 0x3f > IF _oor THEN ;
|
||||
: _raddr7
|
||||
PC - DUP 0< IF 0x40 + _r3fc 0x40 OR ELSE _r3fc THEN ;
|
||||
: _brbx ( a b op -- a ) OR SWAP _raddr7 3 LSHIFT OR ;
|
||||
: BRBC 0xf400 _brbx ; : BRBS 0xf000 _brbx ; : BRCC 0 BRBC ;
|
||||
: BRCS 0 BRBS ; : BREQ 1 BRBS ; : BRNE 1 BRBC ; : BRGE 4 BRBC ;
|
||||
: BRHC 5 BRBC ; : BRHS 5 BRBS ; : BRID 7 BRBC ; : BRIE 7 BRBS ;
|
||||
: BRLO BRCS ; : BRLT 4 BRBS ; : BRMI 2 BRBS ; : BRPL 2 BRBC ;
|
||||
: BRSH BRCC ; : BRTC 6 BRBC ; : BRTS 6 BRBS ; : BRVC 3 BRBC ;
|
||||
: BRVS 3 BRBS ;
|
||||
|
||||
|
11
blk/670
Normal file
11
blk/670
Normal 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 ! ;
|
||||
|
@ -40,6 +40,7 @@ Z: pointer to the next scan code to push to the 595 )
|
||||
0x35 CONSTANT MCUCR
|
||||
0x33 CONSTANT TCCR0B
|
||||
0x3b CONSTANT GIMSK
|
||||
0x38 CONSTANT TIFR
|
||||
0x16 CONSTANT PINB
|
||||
0x17 CONSTANT DDRB
|
||||
0x18 CONSTANT PORTB
|
||||
@ -56,13 +57,13 @@ L2 FLBL, ( hdlINT0 )
|
||||
|
||||
( Read DATA and set GPIOR0/0 if high. Then, set flag T.
|
||||
no SREG fiddling because no SREG-modifying instruction )
|
||||
L2 FRJMP! ( hdlINT0 )
|
||||
L2 ' RJMP FLBL! ( hdlINT0 )
|
||||
PINB DATA SBIC,
|
||||
GPIOR0 0 SBI,
|
||||
SET,
|
||||
RETI,
|
||||
|
||||
L1 FRJMP! ( main )
|
||||
L1 ' RJMP FLBL! ( main )
|
||||
16 RAMEND 0xff AND LDI,
|
||||
SPL 16 OUT,
|
||||
16 RAMEND 8 RSHIFT LDI,
|
||||
@ -95,4 +96,21 @@ DDRB LR SBI,
|
||||
SEI,
|
||||
|
||||
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 )
|
||||
|
Loading…
Reference in New Issue
Block a user