Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/crt/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ __start:
ld sp, (ti.onSP) ; reset stacks
call ti.ResetStacks
ld bc, ___data_len
or a, a
sbc hl, hl
adc hl, bc
jr z, .L.skip_data_copy
Expand All @@ -96,6 +95,7 @@ __start:
ldir
ld a, ti.kClear
jp ti.JForceCmd

.local ___app_start
___app_start:
#else
Expand Down Expand Up @@ -132,6 +132,7 @@ __start:
#if HAS_LIBLOAD
call ti.PushRealO1 ; save running program name
jr .L.tryfind

.L.inram:
call ti.Arc_Unarc
.L.tryfind:
Expand All @@ -150,6 +151,7 @@ __start:
pop hl ; start of loader (required to be in hl)
ld de, ___libload_libs ; start of relocation data
jp (hl) ; jump to the loader -- it should take care of everything else

.L.notfound:
call ti.PopRealO1 ; restore running program name
call ti.ClrScrn
Expand Down Expand Up @@ -217,6 +219,7 @@ ___libload_libs_ret:
inc hl
ld b, (hl)
jr .L.parse_ans_next

.L.parse_ans_loop:
inc hl
dec bc
Expand Down Expand Up @@ -283,18 +286,23 @@ ___libload_libs_ret:
res ti.bTmr1Enable, (hl)
set ti.bTmr1Crystal, (hl)
res ti.bTmr1Overflow, (hl)
ld l, (ti.mpTmr1Counter + 1) & 0xFF
ld de, 0 ; Set the counter to zero
ld (hl), de
dec hl
ld (hl), e

; Set the counter to zero
.errif (ti.mpTmr1Counter & 0xFFFF) != 0
ld l, (ti.mpTmr1Counter + 4) & 0xFF
.L.zeroize_counter:
dec l
ld (hl), h
jr nz, .L.zeroize_counter

ld l, ti.mpTmrCtrl & 0xFF
set ti.bTmr1Enable, (hl) ; Enable the timer
#endif

#if HAS_INIT_ARRAY
ld hl, __init_array_start
jr .L.init_array_start

.L.init_array_loop:
push hl
ld hl, (hl)
Expand Down Expand Up @@ -331,6 +339,7 @@ ___exithl:
_exit:
#if HAS_ATEXIT
jr .L.exit_function_start

.L.exit_function_loop:
ld hl, (ix + 1 + 0 * 3)
ld (__atexit_functions), hl
Expand All @@ -357,6 +366,7 @@ _exit:
#if HAS_FINI_ARRAY
ld hl, __fini_array_end
jr .L.fini_array_start

.L.fini_array_loop:
dec hl
dec hl
Expand All @@ -380,7 +390,9 @@ _exit:
pop hl
#endif
#if HAS_ABORT
jr .L.skip._abort
; jr .L.skip._abort
db $FD ; ld iy, *

Comment on lines +393 to +395
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this optimization was present in the non-binutils version of crt0.src

.global _abort
.type _abort, @function
_abort:
Expand Down
Loading