Skip to content

Commit 21a2f5e

Browse files
committed
make <math.h> functions wrap ez80sf
1 parent 79ec0ac commit 21a2f5e

13 files changed

Lines changed: 171 additions & 201 deletions

File tree

src/libc/cbrtf.c

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/libc/cbrtf.src

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.assume adl=1
2+
3+
.section .text
4+
.global _cbrtf
5+
.type _cbrtf, @function
6+
.global _cbrt
7+
.type _cbrt, @function
8+
9+
_cbrt:
10+
_cbrtf:
11+
pop de
12+
pop bc
13+
ex (sp), hl
14+
ld a, l
15+
call __fpcbrt
16+
push bc
17+
ex (sp), hl
18+
push de
19+
ld e, a
20+
ret
21+
22+
.extern __fpcbrt

src/libc/ceilf.src

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.assume adl=1
22

33
.section .text
4-
.global _ceil
54
.global _ceilf
6-
.type _ceil, @function
75
.type _ceilf, @function
6+
.global _ceil
7+
.type _ceil, @function
88

99
.ifdef PREFER_OS_LIBC
1010

@@ -15,29 +15,18 @@
1515

1616
_ceil:
1717
_ceilf:
18-
call __frameset0
19-
ld bc, (ix+6)
20-
ld a, (ix+9)
21-
call __fneg
22-
ld l, a
23-
ld h, 0
24-
push hl
25-
push bc
26-
call _floor
18+
pop de
2719
pop bc
28-
pop bc
29-
push hl
30-
pop bc
31-
ld a, e
32-
call __fneg
33-
ld e, a
20+
ex (sp), hl
21+
ld a, l
22+
push bc
23+
push de
24+
call __fpceil
3425
push bc
3526
pop hl
36-
pop ix
27+
ld e, a
3728
ret
3829

39-
.extern __frameset0
40-
.extern __fneg
41-
.extern _floor
30+
.extern __fpceil
4231

4332
.endif

src/libc/float32_div4.src

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/libc/floorf.c

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/libc/floorf.src

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.assume adl=1
2+
3+
.section .text
4+
.global _floorf
5+
.type _floorf, @function
6+
.global _floor
7+
.type _floor, @function
8+
9+
.ifdef PREFER_OS_LIBC
10+
11+
.set _floorf, 0x0220F4
12+
.set _floor, _floorf
13+
14+
.else
15+
16+
_floor:
17+
_floorf:
18+
pop de
19+
pop bc
20+
ex (sp), hl
21+
ld a, l
22+
call __fpfloor
23+
push bc
24+
ex (sp), hl
25+
push de
26+
ld e, a
27+
ret
28+
29+
.extern __fpfloor
30+
31+
.endif

src/libc/fmodf.c

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/libc/fmodf.src

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.assume adl=1
2+
3+
.section .text
4+
.global _fmodf
5+
.type _fmodf, @function
6+
.global _fmod
7+
.type _fmod, @function
8+
9+
.ifdef PREFER_OS_LIBC
10+
11+
.set _fmodf, 0x0220FC
12+
.set _fmod, _fmodf
13+
14+
.else
15+
16+
_fmod:
17+
_fmodf:
18+
pop de
19+
pop bc
20+
ex (sp), hl
21+
ld a, l
22+
call __fprem
23+
push bc
24+
ex (sp), hl
25+
push de
26+
ld e, a
27+
ret
28+
29+
.extern __fprem
30+
31+
.endif

src/libc/roundf.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/libc/roundf.src

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.assume adl=1
2+
3+
.section .text
4+
.global _roundf
5+
.type _roundf, @function
6+
.global _round
7+
.type _round, @function
8+
9+
_round:
10+
_roundf:
11+
pop de
12+
pop bc
13+
ex (sp), hl
14+
ld a, l
15+
call __fpround
16+
push bc
17+
ex (sp), hl
18+
push de
19+
ld e, a
20+
ret
21+
22+
.extern __fpround

0 commit comments

Comments
 (0)