diff --git a/apps/zasm/avr.asm b/apps/zasm/avr.asm index 883b813..326a4a3 100644 --- a/apps/zasm/avr.asm +++ b/apps/zasm/avr.asm @@ -628,19 +628,19 @@ _parseArgs: _readBit: ld a, 7 - jr _readExpr + jp _readExpr _readA6: ld a, 0x3f - jr _readExpr + jp _readExpr _readA5: ld a, 0x1f - jr _readExpr + jp _readExpr _readK8: ld a, 0xff - jr _readExpr + jp _readExpr _readDouble: push de @@ -707,6 +707,12 @@ _readR5: push de ld a, (hl) call upcase + cp 'X' + jr z, .rdXYZ + cp 'Y' + jr z, .rdXYZ + cp 'Z' + jr z, .rdXYZ cp 'R' jr nz, .end ; not a register inc hl @@ -717,6 +723,34 @@ _readR5: .end: pop de ret +.rdXYZ: + ; First, let's get a base value, that is, (A-'X'+26)*2, because XL, our + ; lowest register, is equivalent to r26. + sub 'X' + rla ; no carry from sub + add a, 26 + ld d, a ; store that + inc hl + ld a, (hl) + call upcase + cp 'H' + jr nz, .skip1 + ; second char is 'H'? our value is +1 + inc d + jr .skip2 +.skip1: + cp 'L' + jr nz, .end ; not L either? then it's not good +.skip2: + ; Good, we have our final value in D and we're almost sure it's a valid + ; register. Our only check left is that the 3rd char is a null. + inc hl + ld a, (hl) + or a + jr nz, .end + ; we're good + ld a, d + jr .end ; Put DE's LSB into A and, additionally, ensure that the new value is <= ; than what was previously in A. diff --git a/avr/avr.h b/avr/avr.h index c90a804..552a0ee 100644 --- a/avr/avr.h +++ b/avr/avr.h @@ -1,12 +1,5 @@ ; *** CPU registers aliases *** -.equ XH 27 -.equ XL 26 -.equ YH 29 -.equ YL 28 -.equ ZH 31 -.equ ZL 30 - .equ SREG_C 0 ; Carry Flag .equ SREG_Z 1 ; Zero Flag .equ SREG_N 2 ; Negative Flag diff --git a/recipes/sms/kbd/Makefile b/recipes/sms/kbd/Makefile index b7298de..fd85f08 100644 --- a/recipes/sms/kbd/Makefile +++ b/recipes/sms/kbd/Makefile @@ -1,11 +1,13 @@ PROGNAME = ps2ctl AVRDUDEMCU ?= t45 AVRDUDEARGS ?= -c usbtiny -P usb -TARGETS = $(PROGNAME).hex os.sms +TARGETS = $(PROGNAME).bin os.sms BASEDIR = ../../.. ZASM = $(BASEDIR)/emul/zasm/zasm KERNEL = $(BASEDIR)/kernel APPS = $(BASEDIR)/apps +AVRA = $(BASEDIR)/emul/zasm/avra +AVRINC = $(BASEDIR)/avr # Rules @@ -14,14 +16,14 @@ APPS = $(BASEDIR)/apps all: $(TARGETS) @echo Done! -send: $(PROGNAME).hex - avrdude $(AVRDUDEARGS) -p $(AVRDUDEMCU) -U flash:w:$(PROGNAME).hex +send: $(PROGNAME).bin + avrdude $(AVRDUDEARGS) -p $(AVRDUDEMCU) -U flash:w:$(PROGNAME).bin -$(PROGNAME).hex: $(PROGNAME).asm - avra -o $@ $(PROGNAME).asm +$(PROGNAME).bin: $(PROGNAME).asm + $(AVRA) $(AVRINC) < $(PROGNAME).asm > $@ os.sms: glue.asm $(ZASM) $(KERNEL) $(APPS) < glue.asm > $@ clean: - rm -f $(TARGETS) *.eep.hex *.obj os.bin + rm -f $(TARGETS) diff --git a/recipes/sms/kbd/README.md b/recipes/sms/kbd/README.md index def5047..a9b4627 100644 --- a/recipes/sms/kbd/README.md +++ b/recipes/sms/kbd/README.md @@ -55,7 +55,6 @@ either the low or high bits. * 74xx157 (multiplexer) * A NOR SR-latch. I used a 4043. * Proto board, wires, IC sockets, etc. -* [AVRA][avra] ## Historical note @@ -114,4 +113,3 @@ Just hook it on. I've tried it, it works. Did you get there? Feels pretty cool huh? [rc2014-ps2]: ../../rc2014/ps2 -[avra]: https://github.com/hsoft/avra diff --git a/recipes/sms/kbd/ps2ctl.asm b/recipes/sms/kbd/ps2ctl.asm index 9ba62b2..08c5807 100644 --- a/recipes/sms/kbd/ps2ctl.asm +++ b/recipes/sms/kbd/ps2ctl.asm @@ -1,5 +1,3 @@ -.include "tn45def.inc" - ; 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 @@ -30,17 +28,22 @@ ; written. ; Z: pointer to the next scan code to push to the 595 ; + +.inc "avr.h" +.inc "tn254585.h" +.inc "tn45.h" + ; *** Constants *** -.equ CLK = PINB2 -.equ DATA = PINB1 -.equ CP = PINB3 +.equ CLK 2 ; Port B +.equ DATA 1 ; Port B +.equ CP 3 ; Port B ; SR-Latch's Q pin -.equ LQ = PINB0 +.equ LQ 0 ; Port B ; SR-Latch's R pin -.equ LR = PINB4 +.equ LR 4 ; Port B ; init value for TCNT0 so that overflow occurs in 100us -.equ TIMER_INITVAL = 0x100-100 +.equ TIMER_INITVAL 0x100-100 ; *** Code *** @@ -56,9 +59,9 @@ hdlINT0: reti main: - ldi r16, low(RAMEND) + ldi r16, RAMEND&0xff out SPL, r16 - ldi r16, high(RAMEND) + ldi r16, RAMEND}8 out SPH, r16 ; init variables @@ -67,23 +70,23 @@ main: ; Setup int0 ; INT0, falling edge - ldi r16, (1<