Skip to content

Commit 7fbd3a6

Browse files
runer112Matt Waltz
authored andcommitted
Optimize cstartup.asm (#64)
* Optimize cstartup.asm * Fix some pops
1 parent 2ecf60b commit 7fbd3a6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/asm/cstartup.asm

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ _init:
4242
;-------------------------------------------------------------------------------
4343
segment .startup
4444

45-
call 0020848h ; _RunInicOff
45+
call 0020848h ; _RunInicOff, assumes iy=flags
4646
di
4747
ld hl,__low_bss
4848
ld bc,010DE2h ; maximum size of BSS+Heap
@@ -57,31 +57,31 @@ _init:
5757
ld (__errsp+1),sp ; save the stack from death
5858
call _main
5959
__exit:
60-
ex de,hl
6160
__errsp:
6261
ld sp,0
6362
pop af
64-
pop hl
65-
ld (hl),a ; restore flash wait states
66-
push de
63+
pop de
64+
ld (de),a ; restore flash wait states
65+
pop iy ; restore iy for OS
66+
push hl ; exit code
6767
call 0004F0h ; usb_ResetTimers
6868

6969
ifdef PRGM_CLEANUP
70-
ld iy,%D00080
7170
res 4,(iy+9) ; onInterrupt,(iy+onFlags)
7271
set 0,(iy+3) ; graphDraw,(iy+graphFlags)
7372
call %0020808 ; _ClrLCDFull
7473
call %0020828 ; _HomeUp
7574
call %0021A3C ; _DrawStatusBar
7675
endif
7776

78-
pop hl ; program return value in hl
79-
pop iy ; restore previous iy
77+
pop hl ; exit code
8078
ret
79+
8180
_exit:
82-
pop de
83-
pop de
81+
pop hl
82+
pop hl
8483
jr __errsp
84+
8585
;-------------------------------------------------------------------------------
8686
segment code
8787
;-------------------------------------------------------------------------------

0 commit comments

Comments
 (0)