mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-26 20:28:06 +11:00
Compare commits
No commits in common. "177e70580fcf57c7dba61aa0ea7d4f59220a58f6" and "2e23b84fc1dedd11453127e37922046042ec434c" have entirely different histories.
177e70580f
...
2e23b84fc1
4
blk/661
4
blk/661
@ -1,10 +1,8 @@
|
||||
VARIABLE ORG
|
||||
VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
|
||||
: SPLITB
|
||||
256 /MOD SWAP
|
||||
;
|
||||
( We divide by 2 because each PC represents a word. )
|
||||
: PC H@ ORG @ - 1 RSHIFT ;
|
||||
: PC H@ ORG @ ;
|
||||
( A, spits an assembled byte, A,, spits an assembled word
|
||||
Both increase PC. To debug, change C, to .X )
|
||||
: A, C, ; : A,, SPLITB A, A, ;
|
||||
|
18
blk/662
18
blk/662
@ -1,7 +1,11 @@
|
||||
: _oor ." arg out of range: " .X SPC ." PC: " PC .X NL ABORT ;
|
||||
: _r8c DUP 7 > IF _oor THEN ;
|
||||
: _r32c DUP 31 > IF _oor THEN ;
|
||||
: _r16+c _r32c DUP 16 < IF _oor THEN ;
|
||||
: _r256c DUP 255 > IF _oor THEN ;
|
||||
: _Rdp ( op rd -- op', place Rd ) 4 LSHIFT OR ;
|
||||
|
||||
( 0000 000d dddd 0000 )
|
||||
: _Rdp ( op rd -- op' place Rd ) 4 LSHIFT OR ;
|
||||
: OPRd CREATE , DOES> @ SWAP _Rdp A,, ;
|
||||
0b1001010000000101 OPRd ASR, 0b1001010000000000 OPRd COM,
|
||||
0b1001010000001010 OPRd DEC, 0b1001010000000011 OPRd INC,
|
||||
0b1001001000000110 OPRd LAC, 0b1001001000000101 OPRd LAS,
|
||||
0b1001001000000111 OPRd LAT,
|
||||
0b1001010000000110 OPRd LSR, 0b1001010000000001 OPRd NEG,
|
||||
0b1001000000001111 OPRd POP, 0b1001001000001111 OPRd PUSH,
|
||||
0b1001010000000111 OPRd ROR, 0b1001010000000010 OPRd SWAP,
|
||||
0b1001001000000100 OPRd XCH,
|
||||
|
19
blk/663
19
blk/663
@ -1,10 +1,9 @@
|
||||
( 0000 000d dddd 0000 )
|
||||
: OPRd CREATE , DOES> @ SWAP _r32c _Rdp A,, ;
|
||||
0b1001010000000101 OPRd ASR, 0b1001010000000000 OPRd COM,
|
||||
0b1001010000001010 OPRd DEC, 0b1001010000000011 OPRd INC,
|
||||
0b1001001000000110 OPRd LAC, 0b1001001000000101 OPRd LAS,
|
||||
0b1001001000000111 OPRd LAT,
|
||||
0b1001010000000110 OPRd LSR, 0b1001010000000001 OPRd NEG,
|
||||
0b1001000000001111 OPRd POP, 0b1001001000001111 OPRd PUSH,
|
||||
0b1001010000000111 OPRd ROR, 0b1001010000000010 OPRd SWAP,
|
||||
0b1001001000000100 OPRd XCH,
|
||||
( 0000 00rd dddd rrrr )
|
||||
: OPRdRr CREATE C, DOES> C@ ( rd rr op )
|
||||
OVER 0x10 AND 3 RSHIFT OR ( rd rr op' )
|
||||
8 LSHIFT OR 0xff0f AND ( rd op' )
|
||||
SWAP _Rdp A,, ;
|
||||
0x1c OPRdRr ADC, 0x0c OPRdRr ADD, 0x20 OPRdRr AND,
|
||||
0x14 OPRdRr CP, 0x04 OPRdRr CPC, 0x10 OPRdRr CPSE,
|
||||
0x24 OPRdRr EOR, 0x2c OPRdRr MOV, 0x9c OPRdRr MUL,
|
||||
0x28 OPRdRr OR, 0x08 OPRdRr SBC, 0x18 OPRdRr SUB,
|
||||
|
22
blk/664
22
blk/664
@ -1,9 +1,13 @@
|
||||
( 0000 00rd dddd rrrr )
|
||||
: OPRdRr CREATE C, DOES> C@ ( rd rr op )
|
||||
OVER _r32c 0x10 AND 3 RSHIFT OR ( rd rr op' )
|
||||
8 LSHIFT OR 0xff0f AND ( rd op' )
|
||||
SWAP _r32c _Rdp A,, ;
|
||||
0x1c OPRdRr ADC, 0x0c OPRdRr ADD, 0x20 OPRdRr AND,
|
||||
0x14 OPRdRr CP, 0x04 OPRdRr CPC, 0x10 OPRdRr CPSE,
|
||||
0x24 OPRdRr EOR, 0x2c OPRdRr MOV, 0x9c OPRdRr MUL,
|
||||
0x28 OPRdRr OR, 0x08 OPRdRr SBC, 0x18 OPRdRr SUB,
|
||||
( 0000 KKKK dddd KKKK )
|
||||
: OPRdK CREATE C, DOES> C@ ( rd K op )
|
||||
OVER 0xf0 AND 4 RSHIFT OR ( rd K op' )
|
||||
ROT 5 LSHIFT ROT 0x0f AND OR ( op' rdK ) A, A, ;
|
||||
0x70 OPRdK ANDI, 0x30 OPRdK CPI, 0x0e OPRdK LDI,
|
||||
0x60 OPRdK ORI, 0x40 OPRdK SBCI, 0x60 OPRdK SBR,
|
||||
0x50 OPRdK SUBI,
|
||||
|
||||
( 0000 0000 AAAA Abbb )
|
||||
: OPAb CREATE C, DOES> C@ ( A b op )
|
||||
ROT 3 LSHIFT ROT OR A, A, ;
|
||||
0x98 OPAb CBI, 0x9a OPAb SBI, 0x99 OPAb SBIC,
|
||||
0x9b OPAb SBIS,
|
||||
|
22
blk/665
22
blk/665
@ -1,13 +1,11 @@
|
||||
( 0000 KKKK dddd KKKK )
|
||||
: OPRdK CREATE C, DOES> C@ ( rd K op )
|
||||
OVER _r256c 0xf0 AND 4 RSHIFT OR ( rd K op' )
|
||||
ROT _r16+c 4 LSHIFT ROT 0x0f AND OR ( op' rdK ) A, A, ;
|
||||
0x70 OPRdK ANDI, 0x30 OPRdK CPI, 0xe0 OPRdK LDI,
|
||||
0x60 OPRdK ORI, 0x40 OPRdK SBCI, 0x60 OPRdK SBR,
|
||||
0x50 OPRdK SUBI,
|
||||
: OPNA CREATE , DOES> @ A,, ;
|
||||
0x9598 OPNA BREAK, 0x9488 OPNA CLC, 0x94d8 OPNA CLH,
|
||||
0x94f8 OPNA CLI, 0x94a8 OPNA CLN, 0x94c8 OPNA CLS,
|
||||
0x94e8 OPNA CLT, 0x94b8 OPNA CLV, 0x9498 OPNA CLZ,
|
||||
0x9419 OPNA EIJMP, 0x9509 OPNA ICALL, 0x9519 OPNA EICALL,
|
||||
0x9409 OPNA IJMP, 0x0000 OPNA NOP, 0x9508 OPNA RET,
|
||||
0x9518 OPNA RETI, 0x9408 OPNA SEC, 0x9458 OPNA SEH,
|
||||
0x9478 OPNA SEI, 0x9428 OPNA SEN, 0x9448 OPNA SES,
|
||||
0x9468 OPNA SET, 0x9438 OPNA SEV, 0x9418 OPNA SEZ,
|
||||
0x9588 OPNA SLEEP, 0x95a8 OPNA WDR,
|
||||
|
||||
( 0000 0000 AAAA Abbb )
|
||||
: OPAb CREATE C, DOES> C@ ( A b op )
|
||||
ROT _r32c 3 LSHIFT ROT _r8c OR A, A, ;
|
||||
0x98 OPAb CBI, 0x9a OPAb SBI, 0x99 OPAb SBIC,
|
||||
0x9b OPAb SBIS,
|
||||
|
11
blk/666
11
blk/666
@ -1,11 +0,0 @@
|
||||
: OPNA CREATE , DOES> @ A,, ;
|
||||
0x9598 OPNA BREAK, 0x9488 OPNA CLC, 0x94d8 OPNA CLH,
|
||||
0x94f8 OPNA CLI, 0x94a8 OPNA CLN, 0x94c8 OPNA CLS,
|
||||
0x94e8 OPNA CLT, 0x94b8 OPNA CLV, 0x9498 OPNA CLZ,
|
||||
0x9419 OPNA EIJMP, 0x9509 OPNA ICALL, 0x9519 OPNA EICALL,
|
||||
0x9409 OPNA IJMP, 0x0000 OPNA NOP, 0x9508 OPNA RET,
|
||||
0x9518 OPNA RETI, 0x9408 OPNA SEC, 0x9458 OPNA SEH,
|
||||
0x9478 OPNA SEI, 0x9428 OPNA SEN, 0x9448 OPNA SES,
|
||||
0x9468 OPNA SET, 0x9438 OPNA SEV, 0x9418 OPNA SEZ,
|
||||
0x9588 OPNA SLEEP, 0x95a8 OPNA WDR,
|
||||
|
10
blk/667
10
blk/667
@ -1,10 +0,0 @@
|
||||
( 0000 0000 0sss 0000 )
|
||||
: OPb CREATE , DOES> @ ( b op )
|
||||
SWAP _r8c _Rdp A,, ;
|
||||
0b1001010010001000 OPb BCLR, 0b1001010000001000 OPb BSET,
|
||||
|
||||
( 0000 000d dddd 0bbb )
|
||||
: OPRdb CREATE , DOES> @ ( rd b op )
|
||||
ROT _r32c _Rdp SWAP _r8c OR A,, ;
|
||||
0b1111100000000000 OPRdb BLD, 0b1111101000000000 OPRdb BST,
|
||||
0b1111110000000000 OPRdb SBRC, 0b1111111000000000 OPRdb SBRS,
|
8
blk/668
8
blk/668
@ -1,8 +0,0 @@
|
||||
( a -- k12, absolute addr a, relative to PC in a k12 addr )
|
||||
: _r7ffc DUP 0x7ff > IF _oor THEN ;
|
||||
: _raddr12
|
||||
PC - DUP 0< IF 0x800 + _r7ffc 0x800 OR ELSE _r7ffc THEN ;
|
||||
0xc0 CONSTANT RJMPOP
|
||||
0xd0 CONSTANT RCALLOP
|
||||
: RJMP, _raddr12 RJMPOP 8 LSHIFT OR A,, ;
|
||||
: RCALL, _raddr12 RCALLOP 8 LSHIFT OR A,, ;
|
10
blk/669
10
blk/669
@ -1,10 +0,0 @@
|
||||
( ex: L1 LBL! .. L1 @ RJMP, )
|
||||
: LBL! ( l -- ) PC SWAP ! ;
|
||||
( ex: L1 FLBL, .. RJMPOP L1 FLBL! )
|
||||
: FLBL, ( l -- ) LBL! 0 A,, ;
|
||||
: FLBL! ( op l -- )
|
||||
@ DUP PC -^ 1- ( op l off )
|
||||
ROT 8 LSHIFT OR ( l op' )
|
||||
( warning: l is a PC offset, not a mem addr! )
|
||||
SWAP 2 * ORG @ + ( op' addr ) ! ;
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
echo -e "660 LOAD H@ ORG !\n$(cat -)\nORG @ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC! " | ./stage
|
||||
echo -e "660 LOAD H@ 256 /MOD 2 PC! 2 PC! \n$(cat -)\nH@ 256 /MOD 2 PC! 2 PC! " | ./stage
|
||||
|
@ -1,9 +1,13 @@
|
||||
PROGNAME = ps2ctl
|
||||
AVRDUDEMCU ?= t45
|
||||
AVRDUDEARGS ?= -c usbtiny -P usb
|
||||
TARGETS = $(PROGNAME).bin
|
||||
TARGETS = $(PROGNAME).bin os.sms
|
||||
BASEDIR = ../../..
|
||||
EDIR = $(BASEDIR)/emul
|
||||
ZASM = $(BASEDIR)/emul/zasm/zasm
|
||||
KERNEL = $(BASEDIR)/kernel
|
||||
APPS = $(BASEDIR)/apps
|
||||
AVRA = $(BASEDIR)/emul/zasm/avra
|
||||
AVRINC = $(BASEDIR)/avr
|
||||
|
||||
# Rules
|
||||
|
||||
@ -15,8 +19,11 @@ all: $(TARGETS)
|
||||
send: $(PROGNAME).bin
|
||||
avrdude $(AVRDUDEARGS) -p $(AVRDUDEMCU) -U flash:w:$(PROGNAME).bin
|
||||
|
||||
$(PROGNAME).bin: $(PROGNAME).fs
|
||||
cd $(EDIR) && ./avra.sh < ../recipes/sms/kbd/$(PROGNAME).fs > ../recipes/sms/kbd/$@
|
||||
$(PROGNAME).bin: $(PROGNAME).asm
|
||||
$(AVRA) $(AVRINC) < $(PROGNAME).asm > $@
|
||||
|
||||
os.sms: glue.asm
|
||||
$(ZASM) $(KERNEL) $(APPS) < glue.asm > $@
|
||||
|
||||
clean:
|
||||
rm -f $(TARGETS)
|
||||
|
@ -1,53 +0,0 @@
|
||||
( Receives keystrokes from PS/2 keyboard and send them to the
|
||||
'164. On the PS/2 side, it works the same way as the controller
|
||||
in the rc2014/ps2 recipe. However, in this case, what we have
|
||||
on the other side isn't a z80 bus, it's the one of the two
|
||||
controller ports of the SMS through a DB9 connector.
|
||||
|
||||
The PS/2 related code is copied from rc2014/ps2 without much
|
||||
change. The only differences are that it pushes its data to a
|
||||
'164 instead of a '595 and that it synchronizes with the SMS
|
||||
with a SR latch, so we don't need PCINT. We can also afford to
|
||||
run at 1MHz instead of 8.
|
||||
|
||||
*** Register Usage ***
|
||||
|
||||
GPIOR0 flags:
|
||||
0 - when set, indicates that the DATA pin was high when we
|
||||
received a bit through INT0. When we receive a bit, we set
|
||||
flag T to indicate it.
|
||||
|
||||
R16: tmp stuff
|
||||
R17: recv buffer. Whenever we receive a bit, we push it in
|
||||
there.
|
||||
R18: recv step:
|
||||
- 0: idle
|
||||
- 1: receiving data
|
||||
- 2: awaiting parity bit
|
||||
- 3: awaiting stop bit
|
||||
R19: Register used for parity computations and tmp value in
|
||||
some other places
|
||||
R20: data being sent to the '164
|
||||
Y: pointer to the memory location where the next scan code from
|
||||
ps/2 will be written.
|
||||
Z: pointer to the next scan code to push to the 595 )
|
||||
|
||||
0x015f CONSTANT RAMEND
|
||||
0x11 CONSTANT GPIOR0
|
||||
0x16 CONSTANT PINB
|
||||
1 CONSTANT DATA
|
||||
|
||||
H@ ORG !
|
||||
L1 FLBL, ( main )
|
||||
L2 FLBL, ( hdlINT0 )
|
||||
|
||||
( Read DATA and set GPIOR0/0 if high. Then, set flag T.
|
||||
no SREG fiddling because no SREG-modifying instruction )
|
||||
RJMPOP L2 FLBL! ( hdlINT0 )
|
||||
PINB DATA SBIC,
|
||||
GPIOR0 0 SBI,
|
||||
SET,
|
||||
RETI,
|
||||
|
||||
RJMPOP L1 FLBL! ( main )
|
||||
16 RAMEND 0xff AND LDI,
|
Loading…
Reference in New Issue
Block a user