File tree Expand file tree Collapse file tree 13 files changed +3739
-38
lines changed Expand file tree Collapse file tree 13 files changed +3739
-38
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ _ceilf:
3030 ld e,a
3131 push bc
3232 pop hl
33- ld sp,ix
3433 pop ix
3534 ret
3635
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -11,10 +11,91 @@ _modf := _modff
1111
1212else
1313
14- _modff := __modff_c
15- _modf := __modf_c
14+ ; float modf(float x, float* iptr)
15+ _modff:
16+ _modf:
17+ call __frameset0
1618
17- extern __modff_c
18- extern __modf_c
19+ ; copy the mantissa into HL and BC
20+ sbc hl, hl
21+ ld bc, (ix + 6) ; mantissa
22+ add hl, bc
23+ adc hl, hl
24+ ld a, (ix + 9) ; exponent
25+ ld e, a
26+ rla
27+ ld d, a
28+ jr z, .maybe_inf
29+ inc a
30+ ld a, e
31+ jr z, .ret_nan
32+ .not_inf:
33+ ld a, d
34+ sub a, 127 ; |x| < 1.0f
35+ jr c, .less_than_one
36+ ; fintie and normal
37+ ld hl, (ix + 6) ; mantissa
38+ ; E has exponent
39+ push de
40+ push hl
41+ call _truncf
42+ pop af, af
43+
44+ ld a, e
45+ ex hl, de
46+ ld hl, (ix + 12) ; float *iptr
47+ ld (hl), de
48+ inc hl
49+ inc hl
50+ inc hl
51+ ld (hl), a
52+ ex hl, de
53+ ld e, a
54+ ld bc, (ix + 6)
55+ ld a, (ix + 9)
56+
57+ call __fsub
58+ push bc
59+ pop hl
60+ ld e, a
61+ pop ix
62+ ret
63+
64+ .maybe_inf:
65+ inc a
66+ jr nz, .not_inf
67+ ld a, e
68+ ld hl, (ix + 12) ; float *iptr
69+ ld (hl), bc
70+ inc hl
71+ inc hl
72+ inc hl
73+ ld (hl), a ; inf exp
74+ xor a, a
75+ ld e, a
76+ sbc hl, hl
77+ pop ix
78+ ret
79+
80+ .less_than_one:
81+ ld bc, 0
82+ ld a, e
83+ and a, $80
84+ ; A:UBC = copysignf(0.0f, x)
85+ .ret_nan:
86+ ld hl, (ix + 12) ; float *iptr
87+ ld (hl), bc
88+ inc hl
89+ inc hl
90+ inc hl
91+ ld (hl), a
92+ ld hl, (ix + 6) ; mantissa
93+ ; E has exponent
94+ pop ix
95+ ret
96+
97+ extern __frameset0
98+ extern _truncf
99+ extern __fsub
19100
20101end if
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ assume adl=1
2+
3+ section .text
4+
5+ public _truncf, _trunc
6+
7+ _trunc:
8+ _truncf:
9+ ld iy, 0
10+ add iy, sp
11+ ld e, (iy + 6)
12+ ld bc, (iy + 3)
13+ sbc hl, hl
14+ add hl, bc ; copy BC to HL
15+ add hl, hl
16+ ld a, e
17+ rla
18+
19+ sub a, 127 ; exponent bias
20+ jr c, .ret_zero
21+ sub a, 23 ; bits in the mantissa
22+ jr nc, .ret_self
23+ sbc hl, hl ; HL = 0xFFFFFF
24+ neg
25+ ld d, c ; store C
26+ ld c, a
27+ call __ishl
28+ ld c, d ; restore C
29+ jp __iand
30+
31+ .ret_self:
32+ ; already (large) integer, inf, or NaN
33+ sbc hl, hl
34+ add hl, bc
35+ ret
36+
37+ .ret_zero:
38+ ; return signed zero
39+ ld a, e
40+ and a, $80
41+ ld e, a
42+ sbc hl, hl
43+ ret
44+
45+ extern __ishl
46+ extern __iand
Original file line number Diff line number Diff line change 1+ {
2+ "transfer_files" : [
3+ " bin/DEMO.8xp"
4+ ],
5+ "target" : {
6+ "name" : " DEMO" ,
7+ "isASM" : true
8+ },
9+ "sequence" : [
10+ " action|launch" ,
11+ " delay|1000" ,
12+ " hashWait|1" ,
13+ " key|enter" ,
14+ " delay|300" ,
15+ " hashWait|2"
16+ ],
17+ "hashes" : {
18+ "1" : {
19+ "description" : " All tests passed or GDB1 error" ,
20+ "timeout" : 5000 ,
21+ "start" : " vram_start" ,
22+ "size" : " vram_16_size" ,
23+ "expected_CRCs" : [
24+ " 38E2AD5A" ,
25+ " 2C812DC2"
26+ ]
27+ },
28+ "2" : {
29+ "description" : " Exit or GDB1 error" ,
30+ "start" : " vram_start" ,
31+ "size" : " vram_16_size" ,
32+ "expected_CRCs" : [
33+ " FFAF89BA" ,
34+ " 101734A5" ,
35+ " 9DA19F44" ,
36+ " A32840C8" ,
37+ " 349F4775" ,
38+ " 271A9FBF" ,
39+ " 82FD0B1E"
40+ ]
41+ }
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ # ----------------------------
2+ # Makefile Options
3+ # ----------------------------
4+
5+ NAME = DEMO
6+ ICON = icon.png
7+ DESCRIPTION = "CE C Toolchain Demo"
8+ COMPRESSED = NO
9+
10+ CFLAGS = -Wall -Wextra -Wshadow -Wfloat-conversion -Wimplicit-float-conversion -Wimplicit-int-float-conversion -Oz -std=c11
11+ CXXFLAGS = -Wall -Wextra -Wshadow -Wfloat-conversion -Wimplicit-float-conversion -Wimplicit-int-float-conversion -Oz -std=c++11
12+
13+ PREFER_OS_LIBC = NO
14+
15+ # ----------------------------
16+
17+ include $(shell cedev-config --makefile)
You can’t perform that action at this time.
0 commit comments