1
0
mirror of https://github.com/hsoft/collapseos.git synced 2025-04-05 06:38:40 +11:00

Reworked one use of addHL

By essentially inlining both addHL and cpHLDE, 100 cycles are saved, but due to the registers not needing preserving, a byte is saved too.
This commit is contained in:
Clanmaster21 2019-10-17 07:26:22 +01:00 committed by GitHub
parent e1c7269809
commit 9803b458f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,12 +110,14 @@ symRegister:
; Is our new name going to make us go out of bounds? ; Is our new name going to make us go out of bounds?
push hl ; --> lvl 2 push hl ; --> lvl 2
push de ; --> lvl 3 push de ; --> lvl 3
ld d, 0
ld e, c
add hl, de ; if carry set here, sbc will carry too
ld e, (ix+2) ; DE --> pointer to record list, which is also ld e, (ix+2) ; DE --> pointer to record list, which is also
ld d, (ix+3) ; the end of names pool ld d, (ix+3) ; the end of names pool
; DE --> names end ; DE --> names end
ld a, c
call addHL sbc hl, de ; compares hl and de destructively
call cpHLDE
pop de ; <-- lvl 3 pop de ; <-- lvl 3
pop hl ; <-- lvl 2 pop hl ; <-- lvl 2
jr nc, .outOfMemory ; HL >= DE jr nc, .outOfMemory ; HL >= DE