Skip to content

Commit 454b406

Browse files
calc84maniacmateoconlechuga
authored andcommitted
Optimize simple_malloc
1 parent b5e6b8d commit 454b406

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/libc/allocator_simple.src

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,17 @@
55
public __simple_malloc
66
__simple_malloc:
77
pop bc
8-
ex (sp),de
8+
ex (sp),hl
99
push bc
10-
ld bc,(_heap_ptr)
11-
push bc
12-
pop iy
13-
add iy,de
14-
lea hl,iy
15-
or a,a
16-
sbc hl,bc
10+
ld de,(_heap_ptr)
11+
add hl,de
1712
jr c,.null
18-
ld de,___heaptop
19-
lea hl,iy
20-
or a,a
21-
sbc hl,de
13+
ld bc,___heaptop
14+
sbc hl,bc
2215
jr nc,.null
23-
ld (_heap_ptr),iy
24-
push bc
25-
pop hl
16+
add hl,bc
17+
ld (_heap_ptr),hl
18+
ex de,hl
2619
ret
2720
.null:
2821
or a,a

0 commit comments

Comments
 (0)