We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e3c6850 commit b452fd0Copy full SHA for b452fd0
1 file changed
src/libc/atexit.src
@@ -11,7 +11,7 @@ _on_exit:
11
ld hl, 3 * 3
12
push hl
13
call _malloc
14
- pop bc
+ pop de
15
ex de, hl
16
scf
17
sbc hl, hl
@@ -21,23 +21,19 @@ _on_exit:
21
22
ld (__atexit_functions), hl
23
ld (hl), de
24
- pop iy ; return address
25
- inc hl
26
27
28
- pop bc ; func pointer
29
- ld (hl), bc
30
31
32
33
- pop bc ; arg pointer (on_exit)
34
35
- push bc
36
+ ld de, 3
+ add hl, de
+ ex de, hl
+ add hl, sp ; clears carry
+ ld bc, 6
+ ; (SP + 3) = func pointer
+ ; (SP + 6) = arg pointer (on_exit)
+ ; HL = SP + 3
+ ; DE = (__atexit_functions) + 3
+ ldir
37
; return zero on success
38
- or a, a
39
40
- jp (iy)
+ ret
41
42
.section .bss
43
.global __atexit_functions
0 commit comments