mirror of
https://github.com/hsoft/collapseos.git
synced 2025-04-11 07:58:16 +10:00
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.
This commit is contained in:
parent
83b314c450
commit
5f02f07c76
@ -12,7 +12,6 @@
|
|||||||
; *** DATA ***
|
; *** DATA ***
|
||||||
; Useful data to point to, when a pointer is needed.
|
; Useful data to point to, when a pointer is needed.
|
||||||
P_NULL: .db 0
|
P_NULL: .db 0
|
||||||
|
|
||||||
; *** REGISTER FIDDLING ***
|
; *** REGISTER FIDDLING ***
|
||||||
|
|
||||||
; add the value of A into DE
|
; add the value of A into DE
|
||||||
@ -27,34 +26,28 @@ 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 HL, utilising the optimised HL instructions. The first ld
|
||||||
; their LSB before their MSB)
|
; edits the address of the second ld to now be HL.
|
||||||
intoDE:
|
intoHL:
|
||||||
push af
|
ld (.load+1), hl
|
||||||
ld a, (de)
|
.load:
|
||||||
inc de
|
ld hl, (.load) ; (.load) is just a placeholder so the
|
||||||
ex af, af'
|
; assembler will assemble the correct opcode
|
||||||
ld a, (de)
|
|
||||||
ld d, a
|
|
||||||
ex af, af'
|
|
||||||
ld e, a
|
|
||||||
pop af
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
intoHL:
|
intoDE:
|
||||||
push de
|
|
||||||
ex de, hl
|
ex de, hl
|
||||||
call intoDE
|
call intoHL
|
||||||
ex de, hl
|
ex de, hl ; de not affected by intoHL, so no push/pop
|
||||||
pop de
|
; is necessary
|
||||||
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