zasm: little drive-by optimization
Use IX directly for argspec rows instead of going through DE. It saves a bit of processing. The code was this way because I initially didn't use IX at all, so as code evolved, that DE translation stayed as an artifact.
This commit is contained in:
parent
0d7693a163
commit
e691dab070
@ -417,26 +417,6 @@ matchArg:
|
|||||||
dec hl
|
dec hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Compare primary row at (DE) with ID in A. Sets Z flag if there's a match.
|
|
||||||
matchPrimaryRow:
|
|
||||||
push hl
|
|
||||||
push ix
|
|
||||||
push de \ pop ix
|
|
||||||
cp (ix)
|
|
||||||
jr nz, .end
|
|
||||||
; name matches, let's see the rest
|
|
||||||
ld hl, INS_CURARG1
|
|
||||||
ld a, (ix+1)
|
|
||||||
call matchArg
|
|
||||||
jr nz, .end
|
|
||||||
ld hl, INS_CURARG2
|
|
||||||
ld a, (ix+2)
|
|
||||||
call matchArg
|
|
||||||
.end:
|
|
||||||
pop ix
|
|
||||||
pop hl
|
|
||||||
ret
|
|
||||||
|
|
||||||
; *** Special opcodes ***
|
; *** Special opcodes ***
|
||||||
; The special upcode handling routines below all have the same signature.
|
; The special upcode handling routines below all have the same signature.
|
||||||
; Instruction row is at IX and we're expected to perform the same task as
|
; Instruction row is at IX and we're expected to perform the same task as
|
||||||
@ -574,16 +554,13 @@ handleRST:
|
|||||||
ld c, 0
|
ld c, 0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Compute the upcode for argspec row at (DE) and arguments in curArg{1,2} and
|
; Compute the upcode for argspec row at (IX) and arguments in curArg{1,2} and
|
||||||
; writes the resulting upcode to IO.
|
; writes the resulting upcode to IO.
|
||||||
; A is zero, with Z set, on success. A is non-zero, with Z unset, on error.
|
; A is zero, with Z set, on success. A is non-zero, with Z unset, on error.
|
||||||
spitUpcode:
|
spitUpcode:
|
||||||
push ix
|
|
||||||
push de
|
push de
|
||||||
push hl
|
push hl
|
||||||
push bc
|
push bc
|
||||||
; First, let's go in IX mode. It's easier to deal with offsets here.
|
|
||||||
push de \ pop ix
|
|
||||||
|
|
||||||
; before we begin, are we in a 'l' argspec? Is it flagged for IX/IY
|
; before we begin, are we in a 'l' argspec? Is it flagged for IX/IY
|
||||||
; acceptance? If yes, a 'x' or 'y' instruction? Check this on both
|
; acceptance? If yes, a 'x' or 'y' instruction? Check this on both
|
||||||
@ -823,7 +800,6 @@ spitUpcode:
|
|||||||
pop bc
|
pop bc
|
||||||
pop hl
|
pop hl
|
||||||
pop de
|
pop de
|
||||||
pop ix
|
|
||||||
ret
|
ret
|
||||||
.checkCB:
|
.checkCB:
|
||||||
ld a, (INS_UPCODE)
|
ld a, (INS_UPCODE)
|
||||||
@ -876,7 +852,7 @@ parseInstruction:
|
|||||||
push bc
|
push bc
|
||||||
push hl
|
push hl
|
||||||
push de
|
push de
|
||||||
; A is reused in matchPrimaryRow but that register is way too changing.
|
; A is reused in .matchPrimaryRow but that register is way too changing.
|
||||||
; Let's keep a copy in a more cosy register.
|
; Let's keep a copy in a more cosy register.
|
||||||
ld c, a
|
ld c, a
|
||||||
xor a
|
xor a
|
||||||
@ -899,24 +875,24 @@ parseInstruction:
|
|||||||
; To speed up things a little, we use a poor man's indexing. Full
|
; To speed up things a little, we use a poor man's indexing. Full
|
||||||
; bisecting would involve too much complexity.
|
; bisecting would involve too much complexity.
|
||||||
ld a, c ; recall A param
|
ld a, c ; recall A param
|
||||||
ld de, instrTBl
|
ld ix, instrTBl
|
||||||
cp I_EX
|
cp I_EX
|
||||||
jr c, .loop
|
jr c, .loop
|
||||||
ld de, instrTBlEX
|
ld ix, instrTBlEX
|
||||||
cp I_LD
|
cp I_LD
|
||||||
jr c, .loop
|
jr c, .loop
|
||||||
ld de, instrTBlLD
|
ld ix, instrTBlLD
|
||||||
cp I_RET
|
cp I_RET
|
||||||
jr c, .loop
|
jr c, .loop
|
||||||
ld de, instrTBlRET
|
ld ix, instrTBlRET
|
||||||
.loop:
|
.loop:
|
||||||
ld a, c ; recall A param
|
ld a, c ; recall A param
|
||||||
call matchPrimaryRow
|
call .matchPrimaryRow
|
||||||
jr z, .match
|
jr z, .match
|
||||||
ld a, INSTR_TBL_ROWSIZE
|
ld de, INSTR_TBL_ROWSIZE
|
||||||
call addDE
|
add ix, de
|
||||||
ld a, (de)
|
ld a, 0xff
|
||||||
cp 0xff
|
cp (ix)
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
; No signature match
|
; No signature match
|
||||||
ld a, ERR_BAD_ARG
|
ld a, ERR_BAD_ARG
|
||||||
@ -936,6 +912,19 @@ parseInstruction:
|
|||||||
pop bc
|
pop bc
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Compare primary row at (IX) with ID in A. Sets Z flag if there's a match.
|
||||||
|
.matchPrimaryRow:
|
||||||
|
cp (ix)
|
||||||
|
ret nz
|
||||||
|
; name matches, let's see the rest
|
||||||
|
ld hl, INS_CURARG1
|
||||||
|
ld a, (ix+1)
|
||||||
|
call matchArg
|
||||||
|
ret nz
|
||||||
|
ld hl, INS_CURARG2
|
||||||
|
ld a, (ix+2)
|
||||||
|
jp matchArg
|
||||||
|
|
||||||
|
|
||||||
; In instruction metadata below, argument types arge indicated with a single
|
; In instruction metadata below, argument types arge indicated with a single
|
||||||
; char mnemonic that is called "argspec". This is the table of correspondence.
|
; char mnemonic that is called "argspec". This is the table of correspondence.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#!/bin/sh -e
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
# TODO: find POSIX substitute to that PIPESTATUS thing
|
||||||
|
|
||||||
BASE=../../..
|
BASE=../../..
|
||||||
TOOLS=../..
|
TOOLS=../..
|
||||||
|
@ -46,15 +46,15 @@ runTests:
|
|||||||
halt
|
halt
|
||||||
|
|
||||||
testSpitUpcode:
|
testSpitUpcode:
|
||||||
ld ix, .t1
|
ld iy, .t1
|
||||||
call .test
|
call .test
|
||||||
ld ix, .t2
|
ld iy, .t2
|
||||||
call .test
|
call .test
|
||||||
ld ix, .t3
|
ld iy, .t3
|
||||||
call .test
|
call .test
|
||||||
ld ix, .t4
|
ld iy, .t4
|
||||||
call .test
|
call .test
|
||||||
ld ix, .t5
|
ld iy, .t5
|
||||||
call .test
|
call .test
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -66,36 +66,36 @@ testSpitUpcode:
|
|||||||
ld (SPITBOWL+1), a
|
ld (SPITBOWL+1), a
|
||||||
ld (SPITBOWL+2), a
|
ld (SPITBOWL+2), a
|
||||||
ld (SPITBOWL+3), a
|
ld (SPITBOWL+3), a
|
||||||
push ix \ pop de
|
push iy \ pop ix
|
||||||
call intoDE
|
call intoIX
|
||||||
ld a, (ix+2)
|
ld a, (iy+2)
|
||||||
ld (INS_CURARG1), a
|
ld (INS_CURARG1), a
|
||||||
ld a, (ix+3)
|
ld a, (iy+3)
|
||||||
ld (INS_CURARG1+1), a
|
ld (INS_CURARG1+1), a
|
||||||
ld a, (ix+4)
|
ld a, (iy+4)
|
||||||
ld (INS_CURARG1+2), a
|
ld (INS_CURARG1+2), a
|
||||||
ld a, (ix+5)
|
ld a, (iy+5)
|
||||||
ld (INS_CURARG2), a
|
ld (INS_CURARG2), a
|
||||||
ld a, (ix+6)
|
ld a, (iy+6)
|
||||||
ld (INS_CURARG2+1), a
|
ld (INS_CURARG2+1), a
|
||||||
ld a, (ix+7)
|
ld a, (iy+7)
|
||||||
ld (INS_CURARG2+2), a
|
ld (INS_CURARG2+2), a
|
||||||
call spitUpcode
|
call spitUpcode
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
ld a, (SPITCNT)
|
ld a, (SPITCNT)
|
||||||
cp (ix+8)
|
cp (iy+8)
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
ld a, (SPITBOWL)
|
ld a, (SPITBOWL)
|
||||||
cp (ix+9)
|
cp (iy+9)
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
ld a, (SPITBOWL+1)
|
ld a, (SPITBOWL+1)
|
||||||
cp (ix+10)
|
cp (iy+10)
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
ld a, (SPITBOWL+2)
|
ld a, (SPITBOWL+2)
|
||||||
cp (ix+11)
|
cp (iy+11)
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
ld a, (SPITBOWL+3)
|
ld a, (SPITBOWL+3)
|
||||||
cp (ix+12)
|
cp (iy+12)
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
jp nexttest
|
jp nexttest
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user