mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 22:58:06 +11:00
cpHLDE and writeHLinDE improvements (#33)
Pretty major improvements to both of these, cpHLDE is now 5 bytes shorter and between 9 and 12 cycles faster due to branching, and writeHLinDE is now 2 bytes shorter and 21 cycles faster.
This commit is contained in:
parent
5460f28cfb
commit
9fb1467ee5
@ -79,33 +79,22 @@ subHL:
|
|||||||
|
|
||||||
; Compare HL with DE and sets Z and C in the same way as a regular cp X where
|
; Compare HL with DE and sets Z and C in the same way as a regular cp X where
|
||||||
; HL is A and DE is X.
|
; HL is A and DE is X.
|
||||||
; A is preserved through some register hocus pocus: having cpHLDE destroying
|
|
||||||
; A bit me too many times.
|
|
||||||
cpHLDE:
|
cpHLDE:
|
||||||
push bc
|
push hl
|
||||||
ld b, a ; preserve A
|
or a ;reset carry flag
|
||||||
ld a, h
|
sbc hl, de ;There is no 'sub hl, de', so we must use sbc
|
||||||
cp d
|
pop hl
|
||||||
jr nz, .end ; if not equal, flags are correct
|
|
||||||
ld a, l
|
|
||||||
cp e
|
|
||||||
; flags are correct
|
|
||||||
.end:
|
|
||||||
; restore A but don't touch flags
|
|
||||||
ld a, b
|
|
||||||
pop bc
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Write the contents of HL in (DE)
|
; Write the contents of HL in (DE)
|
||||||
|
; de and hl are preserved, so no pushing/popping necessary
|
||||||
writeHLinDE:
|
writeHLinDE:
|
||||||
push af
|
ex de, hl
|
||||||
ld a, l
|
ld (hl), e
|
||||||
ld (de), a
|
inc hl
|
||||||
inc de
|
ld (hl), d
|
||||||
ld a, h
|
dec hl
|
||||||
ld (de), a
|
ex de, hl
|
||||||
dec de
|
|
||||||
pop af
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Call the method (IX) is a pointer to. In other words, call intoIX before
|
; Call the method (IX) is a pointer to. In other words, call intoIX before
|
||||||
|
Loading…
Reference in New Issue
Block a user