mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 21:38:05 +11:00
avra: generalize arg swapping behavior
This commit is contained in:
parent
14fbfa2967
commit
20861767e6
@ -121,7 +121,14 @@ instrNames:
|
|||||||
; index (1-based, 0 means no arg) in the argSpecs table. High nibble is for
|
; index (1-based, 0 means no arg) in the argSpecs table. High nibble is for
|
||||||
; flags. Meaning:
|
; flags. Meaning:
|
||||||
;
|
;
|
||||||
; (None for now)
|
; Bit 7: Arguments swapped. For example, if we have this bit set on the argspec
|
||||||
|
; row 'A', 'R', then what will actually be read is 'R', 'A'. The
|
||||||
|
; arguments destination will be, hum, de-swapped, that is, 'A' is going
|
||||||
|
; in H and 'R' is going in L. This is used, for example, with IN and OUT.
|
||||||
|
; IN has a Rd(5), A(6) signature. OUT could have the same signature, but
|
||||||
|
; AVR's mnemonics has those args reversed for more consistency
|
||||||
|
; (destination is always the first arg). The goal of this flag is to
|
||||||
|
; allow this kind of syntactic sugar with minimal complexity.
|
||||||
|
|
||||||
; In the same order as in instrNames
|
; In the same order as in instrNames
|
||||||
instrTbl:
|
instrTbl:
|
||||||
@ -157,8 +164,8 @@ instrTbl:
|
|||||||
.db 0x00, 0b11010000, 0x00 ; RCALL
|
.db 0x00, 0b11010000, 0x00 ; RCALL
|
||||||
.db 0x00, 0b11000000, 0x00 ; RJMP
|
.db 0x00, 0b11000000, 0x00 ; RJMP
|
||||||
; IN and OUT
|
; IN and OUT
|
||||||
.db 0x08, 0b10110000, 0x00 ; IN
|
.db 0x07, 0b10110000, 0x00 ; IN
|
||||||
.db 0x07, 0b10111000, 0x00 ; OUT
|
.db 0x87, 0b10111000, 0x00 ; OUT (args reversed)
|
||||||
; no arg
|
; no arg
|
||||||
.db 0x00, 0b10010101, 0b10011000 ; BREAK
|
.db 0x00, 0b10010101, 0b10011000 ; BREAK
|
||||||
.db 0x00, 0b10010100, 0b10001000 ; CLC
|
.db 0x00, 0b10010100, 0b10001000 ; CLC
|
||||||
@ -273,6 +280,8 @@ parseInstruction:
|
|||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
ld h, d
|
ld h, d
|
||||||
ld l, a ; H and L contain specs now
|
ld l, a ; H and L contain specs now
|
||||||
|
bit 7, (ix)
|
||||||
|
call nz, .swapHL ; Bit 7 set, swap H and L
|
||||||
call _parseArgs
|
call _parseArgs
|
||||||
ret nz
|
ret nz
|
||||||
.noarg:
|
.noarg:
|
||||||
@ -280,6 +289,8 @@ parseInstruction:
|
|||||||
; (IX) is table row
|
; (IX) is table row
|
||||||
; Parse arg values now in H and L
|
; Parse arg values now in H and L
|
||||||
; InstrID is E
|
; InstrID is E
|
||||||
|
bit 7, (ix)
|
||||||
|
call nz, .swapHL ; Bit 7 set, swap H and L again!
|
||||||
ld a, e ; InstrID
|
ld a, e ; InstrID
|
||||||
cp I_ANDI
|
cp I_ANDI
|
||||||
jr c, .spitRd5Rr5
|
jr c, .spitRd5Rr5
|
||||||
@ -289,9 +300,8 @@ parseInstruction:
|
|||||||
jr c, .spitRdBit
|
jr c, .spitRdBit
|
||||||
cp I_IN
|
cp I_IN
|
||||||
jr c, .spitK12
|
jr c, .spitK12
|
||||||
jp z, .spitIN
|
cp I_BREAK
|
||||||
cp I_OUT
|
jp c, .spitINOUT
|
||||||
jp z, .spitOUT
|
|
||||||
cp I_ASR
|
cp I_ASR
|
||||||
jp c, .spit ; no arg
|
jp c, .spit ; no arg
|
||||||
; spitRd5
|
; spitRd5
|
||||||
@ -368,12 +378,7 @@ parseInstruction:
|
|||||||
or b
|
or b
|
||||||
jp ioPutB
|
jp ioPutB
|
||||||
|
|
||||||
.spitOUT:
|
.spitINOUT:
|
||||||
ld a, h
|
|
||||||
ld h, l
|
|
||||||
ld l, a
|
|
||||||
; Continue to spitIN
|
|
||||||
.spitIN:
|
|
||||||
; Rd in H, A in L
|
; Rd in H, A in L
|
||||||
ld a, h
|
ld a, h
|
||||||
call .placeRd
|
call .placeRd
|
||||||
@ -463,6 +468,12 @@ parseInstruction:
|
|||||||
ld c, a
|
ld c, a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.swapHL:
|
||||||
|
ld a, h
|
||||||
|
ld h, l
|
||||||
|
ld l, a
|
||||||
|
ret
|
||||||
|
|
||||||
; Argspecs: two bytes describing the arguments that are accepted. Possible
|
; Argspecs: two bytes describing the arguments that are accepted. Possible
|
||||||
; values:
|
; values:
|
||||||
;
|
;
|
||||||
@ -486,7 +497,6 @@ argSpecs:
|
|||||||
.db 'r', 8 ; Rd(4) + K(8)
|
.db 'r', 8 ; Rd(4) + K(8)
|
||||||
.db 'R', 'b' ; Rd(5) + bit
|
.db 'R', 'b' ; Rd(5) + bit
|
||||||
.db 'b', 7 ; bit + k(7)
|
.db 'b', 7 ; bit + k(7)
|
||||||
.db 'A', 'R' ; A(6) + Rr(5)
|
|
||||||
.db 'R', 'A' ; Rd(5) + A(6)
|
.db 'R', 'A' ; Rd(5) + A(6)
|
||||||
|
|
||||||
; Parse arguments from I/O according to specs in HL
|
; Parse arguments from I/O according to specs in HL
|
||||||
|
Loading…
Reference in New Issue
Block a user