Skip to content

Commit d190d55

Browse files
committed
optimized call/load relative
1 parent c00ccad commit d190d55

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/libload/libload.asm

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ end macro
145145
relocate helpers, buf + 900
146146
call_relative:
147147
pop ix
148-
lea ix, ix + 3
149-
push ix
150-
lea ix, ix - 3
148+
pea ix + 3
151149
push de
152150
ld de, (ix)
153151
add ix, de
@@ -161,14 +159,14 @@ jump_relative:
161159
pop de
162160
jp (ix)
163161
ld_relative:
164-
pop ix
165-
ld de, (ix)
166-
push ix
167-
add ix, de
168-
lea hl, ix
169-
pop ix
170-
lea ix, ix + 3
171-
jp (ix)
162+
pop hl
163+
ld de, (hl)
164+
inc hl
165+
inc hl
166+
inc hl
167+
push hl
168+
add hl, de ; add hl, relative - 3
169+
ret
172170
end relocate
173171

174172
macro rcall? name
@@ -183,7 +181,7 @@ end macro
183181

184182
macro rload? name
185183
call ld_relative
186-
dl name - $
184+
dl name - $ - 3
187185
end macro
188186

189187
start:

0 commit comments

Comments
 (0)