Skip to content

Commit 2c0a5ca

Browse files
committed
applied some opts to resolve_entry_points (like unsigned division) and others
1 parent 585c17f commit 2c0a5ca

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/libload/libload.asm

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ optional_lib_clear:
298298
ld (hl), e ; mark optional library as not found
299299
pop hl
300300
inc hl ; skip version byte
301+
ld a, JP_OPCODE
301302
.loop:
302-
ld a, (hl)
303-
cp a, JP_OPCODE ; jp byte ($C3)
303+
cp a, (hl) ; jp byte ($C3)
304304
jr nz, .done
305305
inc hl
306306
ld (hl), de ; make the vector zero
@@ -423,15 +423,15 @@ resolve_entry_points:
423423
ld hl, (ramlocation)
424424
rcall enqueue_all_deps ; get all the dependency pointers that reside in the ram lib
425425
ld hl, (jump_tbl_ptr) ; hl->start of function jump table
426+
ld bc, 3
427+
ld a, JP_OPCODE
426428
.loop:
427-
ld a, (hl)
428-
cp a, JP_OPCODE ; jp byte ($C3)
429+
cp a, (hl) ; jp byte ($C3)
429430
jr nz, .done
430431
inc hl ; bypass jp byte ($C3)
431432
push hl
432433
ld hl, (hl) ; offset in vector table (0, 3, 6, etc.)
433-
ld bc, 3
434-
call ti._idivs ; originally the offset was just added because vectors were stored in three bytes, now it is just 2 to save space
434+
call ti._idivu ; originally the offset was just added because vectors were stored in three bytes, now it is just 2 to save space
435435
add hl, hl ; (offset/3) * 2
436436
ld de, (vector_tbl_ptr) ; hl->start of vector table
437437
add hl, de ; hl->correct vector entry
@@ -441,9 +441,7 @@ resolve_entry_points:
441441
ex de, hl ; de->function in ram
442442
pop hl ; restore jump offset
443443
ld (hl), de ; de=resolved address
444-
inc hl
445-
inc hl
446-
inc hl ; move to next jump
444+
add hl, bc ; move to next jump
447445
jr .loop
448446
.done: ; finished resolving entry points
449447
; now relocate absolutes in library
@@ -542,9 +540,9 @@ enqueue_all_deps: ; we don't need to store anything if we are here
542540
.skip:
543541
move_string_to_end
544542
inc hl ; move to start of dependency jump table
543+
ld a, JP_OPCODE
545544
.next:
546-
ld a, (hl)
547-
cp a, JP_OPCODE
545+
cp a, (hl) ; jp byte ($C3)
548546
jr nz, .loop
549547
inc hl
550548
inc hl

0 commit comments

Comments
 (0)