Skip to content

Conversation

ZERICO2005
Copy link
Contributor

Applied some optimizations to libload to reduce size.

@ZERICO2005 ZERICO2005 marked this pull request as ready for review October 11, 2025 01:07
@ZERICO2005 ZERICO2005 marked this pull request as draft October 11, 2025 01:10
Comment on lines 216 to 226
.no_match:
pop de
ld hl, (end_arc_lib_locs)
call ti.CpHLDE ; have we reached the end of the table?
or a, a
sbc hl, de ; have we reached the end of the table?

push af
ex de, hl
ld de, 15 ; size of search entry (9=name, 3=ram ptr, 3=arc vec ptr)
ld hl, 15 ; size of search entry (9=name, 3=ram ptr, 3=arc vec ptr)
add hl, de
ex de, hl ; end of the extraction table?
pop af
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proof that this transformation is valid

        ; Original
        ld      de, Y
        ld      hl, X
        or      a, a
        sbc     hl, de  ; HL = X -  Y, DE = Y
        add     hl, de  ; HL = X     , DE = Y

        ex      de, hl  ; HL = Y     , DE = X
        ld      de, 15  ; HL = Y     , DE =     15
        add     hl, de  ; HL = Y + 15, DE =     15
        ex      de, hl  ; HL =     15, DE = Y + 15
        pop     hl      ; HL =      ?, DE = Y + 15

        ; Optimized
        ld      de, Y
        ld      hl, X
        or      a, a
        sbc     hl, de  ; HL = X -  Y, DE = Y

        ld      hl, 15  ; HL =     15, DE = Y
        add     hl, de  ; HL = Y + 15, DE = Y
        ex      de, hl  ; HL =      Y, DE = Y + 15
        pop     hl      ; HL =      ?, DE = Y + 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant