File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -23,22 +23,23 @@ _calloc:
2323 pop bc ; BC = size
2424 ; test for NULL
2525 add hl, bc
26- ; or a, a ; . assumes that ptr + size does not overflow
26+ ; or a, a ; assumes that ptr + size does not overflow
2727 sbc hl, bc
2828 ret z ; return NULL
2929 ; inlined bzero
30- push hl
31- ex de, hl ; DE = dest
32- ; test if the size is zero
33- scf
34- sbc hl, hl
35- add hl, bc
36- jr nc, .L.finish
37- ; large region of all zeros on the Ti84CE
38- ld hl, $E40000 ; HL = src
39- ldir
40- .L.finish:
41- pop hl ; return value
30+
31+ dec bc
32+ add hl, bc ; move to the end of dst
33+ ; non-zero + (size - 1) sets carry if size is zero
34+ jr c, .L.zero_size
35+ inc bc
36+ ex de, hl ; DE = dst
37+ ; uses the all zeros address range $E40000-$EFFFFF on the Ti84CE
38+ ld hl, $EFFFFF ; HL = src
39+ lddr
40+ ex de, hl
41+ .L.zero_size:
42+ inc hl
4243 ret
4344
4445.else
You can’t perform that action at this time.
0 commit comments