Optimised intoXX functions (#19)
* Optimised intoXX functions Rewrote intoXX functions to mainly rely on intoHL, as the HL instructions are smaller and faster. Also removed some redundant push and pop instructions. I edited the given unit tests to test these, and they seem to work as expected. * Doesn't use self-modifying code The number of bytes is the same as my previous attempt, with 11 more cycles in intoHL, so although I don't feel as clever this time it's still a good optimisation. I found an equivalent method for intoDE, however relying on intoHL still allows for `ex (sp), hl` to be used in intoIX, which is smaller and faster. * Update core.asm * Tried harder to follow coding convention Added tabs between mnemonics and operands, and replaced a new line I accidentally removed.
This commit is contained in:
parent
e259e3d02e
commit
6281e2036f
@ -27,34 +27,29 @@ addDE:
|
|||||||
noop: ; piggy backing on the first "ret" we have
|
noop: ; piggy backing on the first "ret" we have
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; copy (DE) into DE, little endian style (addresses in z80 are always have
|
; copy (HL) into DE, then exchange the two, utilising the optimised HL instructions.
|
||||||
; their LSB before their MSB)
|
; ld must be done little endian, so least significant byte first.
|
||||||
intoDE:
|
intoHL:
|
||||||
push af
|
push de
|
||||||
ld a, (de)
|
ld e, (hl)
|
||||||
inc de
|
inc hl
|
||||||
ex af, af'
|
ld d, (hl)
|
||||||
ld a, (de)
|
ex de, hl
|
||||||
ld d, a
|
pop de
|
||||||
ex af, af'
|
|
||||||
ld e, a
|
|
||||||
pop af
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
intoHL:
|
intoDE:
|
||||||
push de
|
ex de, hl
|
||||||
ex de, hl
|
call intoHL
|
||||||
call intoDE
|
ex de, hl ; de preserved by intoHL, so no push/pop needed
|
||||||
ex de, hl
|
|
||||||
pop de
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
intoIX:
|
intoIX:
|
||||||
push de
|
push ix
|
||||||
push ix \ pop de
|
ex (sp), hl ;swap hl with ix, on the stack
|
||||||
call intoDE
|
call intoHL
|
||||||
push de \ pop ix
|
ex (sp), hl ;restore hl from stack
|
||||||
pop de
|
pop ix
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; add the value of A into HL
|
; add the value of A into HL
|
||||||
|
Loading…
Reference in New Issue
Block a user