zasm: simplify code
This commit is contained in:
parent
93eb262083
commit
8594084b06
@ -391,7 +391,8 @@ findInGroup:
|
|||||||
; For constant args, it's easy: if A == (HL), it's a success.
|
; For constant args, it's easy: if A == (HL), it's a success.
|
||||||
; If it's not this, then we check if it's a numerical arg.
|
; If it's not this, then we check if it's a numerical arg.
|
||||||
; If A is a group ID, we do something else: we check that (HL) exists in the
|
; If A is a group ID, we do something else: we check that (HL) exists in the
|
||||||
; groupspec (argGrpTbl).
|
; groupspec (argGrpTbl). Moreover, we go and write the group's "value" (index)
|
||||||
|
; in (HL+1). This will save us significant processing later in getUpcode.
|
||||||
; Set Z according to whether we match or not.
|
; Set Z according to whether we match or not.
|
||||||
matchArg:
|
matchArg:
|
||||||
cp a, (hl)
|
cp a, (hl)
|
||||||
@ -430,6 +431,12 @@ matchArg:
|
|||||||
pop hl
|
pop hl
|
||||||
call findInGroup
|
call findInGroup
|
||||||
pop hl
|
pop hl
|
||||||
|
ret nz
|
||||||
|
; we found our group? let's write down its "value" in (HL+1). We hold
|
||||||
|
; this value in A at the moment.
|
||||||
|
inc hl
|
||||||
|
ld (hl), a
|
||||||
|
dec hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Compare primary row at (DE) with string at tokInstr. Sets Z flag if there's a
|
; Compare primary row at (DE) with string at tokInstr. Sets Z flag if there's a
|
||||||
@ -535,11 +542,8 @@ handleBITR:
|
|||||||
call handleBIT
|
call handleBIT
|
||||||
ret nz ; error
|
ret nz ; error
|
||||||
; get group value
|
; get group value
|
||||||
ld a, (curArg2)
|
ld a, (curArg2+1) ; group value
|
||||||
ld h, 0xb
|
ld c, a
|
||||||
call findInGroup
|
|
||||||
ret nz ; error
|
|
||||||
push af ; push group value
|
|
||||||
; write first upcode
|
; write first upcode
|
||||||
ld a, 0xcb ; first upcode
|
ld a, 0xcb ; first upcode
|
||||||
ld (curUpcode), a
|
ld (curUpcode), a
|
||||||
@ -549,8 +553,7 @@ handleBITR:
|
|||||||
call rlaX
|
call rlaX
|
||||||
; Now we have group value in stack, bit value in A (properly shifted)
|
; Now we have group value in stack, bit value in A (properly shifted)
|
||||||
; and we want to OR them together
|
; and we want to OR them together
|
||||||
pop bc ; from push af earlier
|
or c ; Now we have our ORed value
|
||||||
or b ; Now we have our ORed value
|
|
||||||
or 0b01000000 ; and with the constant value for that byte...
|
or 0b01000000 ; and with the constant value for that byte...
|
||||||
; we're good!
|
; we're good!
|
||||||
ld (curUpcode+1), a
|
ld (curUpcode+1), a
|
||||||
@ -609,11 +612,7 @@ handleLDIYr:
|
|||||||
ld a, 0xfd
|
ld a, 0xfd
|
||||||
handleLDIXYr:
|
handleLDIXYr:
|
||||||
ld (curUpcode), a
|
ld (curUpcode), a
|
||||||
; get group value
|
ld a, (curArg2+1) ; group value
|
||||||
ld a, (curArg2)
|
|
||||||
ld h, 0xb
|
|
||||||
call findInGroup
|
|
||||||
ret nz ; error
|
|
||||||
or 0b01110000 ; second upcode
|
or 0b01110000 ; second upcode
|
||||||
ld (curUpcode+1), a
|
ld (curUpcode+1), a
|
||||||
ld a, (curArg1+1) ; IXY displacement
|
ld a, (curArg1+1) ; IXY displacement
|
||||||
@ -676,14 +675,9 @@ getUpcode:
|
|||||||
ld hl, curArg1
|
ld hl, curArg1
|
||||||
.isGroup:
|
.isGroup:
|
||||||
; A is a group, good, now let's get its value. HL is pointing to
|
; A is a group, good, now let's get its value. HL is pointing to
|
||||||
; the argument. A little bit of stack gymnastic is necessary to put
|
; the argument. Our group value is at (HL+1).
|
||||||
; A into H and (HL) into A.
|
inc hl
|
||||||
push af
|
|
||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
pop hl ; from push af 2 lines above
|
|
||||||
call findInGroup ; we don't check for match, it's supposed to
|
|
||||||
; always match. Something is very wrong if it
|
|
||||||
; doesn't
|
|
||||||
; Now, we have our arg "group value" in A. Were going to need to
|
; Now, we have our arg "group value" in A. Were going to need to
|
||||||
; displace it left by the number of steps specified in the table.
|
; displace it left by the number of steps specified in the table.
|
||||||
push af
|
push af
|
||||||
|
Loading…
Reference in New Issue
Block a user