Skip to content

Commit 67d5cb5

Browse files
author
Zeda
committed
Fixed bug printing inf, moved LUT outside, documented input/output
1 parent d4563cd commit 67d5cb5

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

conversion/f32toa.z80

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef included_f32toa
22
#define included_f32toa
33
#include "pushpop.z80"
4+
#include "f32_pow10_LUT.z80"
5+
#include "f32mul.z80"
6+
#include "mov4.z80"
7+
#include "common_str.z80"
48

59
;#define EXTERNAL_FORMAT_LEN ;Uses an external reference to get the format length
610
;#define EXTERNAL_FORMAT_LEN fmtDigits ;Use for TI-OS
@@ -36,6 +40,9 @@
3640
#define f32toa_x scrap
3741

3842
f32toa:
43+
;Inputs:
44+
; HL points to the input float
45+
; BC points to where the string gets written.
3946
call pushpop
4047
ld e,(hl)
4148
inc hl
@@ -274,23 +281,6 @@ f32toa_pow10LUT_mul_sub:
274281
jp c,f32mul
275282
ret
276283

277-
f32_pown10_LUT:
278-
.db $CD,$CC,$CC,$3D ;1e-1
279-
.db $0A,$D7,$23,$3C ;1e-2
280-
.db $17,$B7,$D1,$38 ;1e-4
281-
.db $77,$CC,$2B,$32 ;1e-8
282-
.db $95,$95,$E6,$24 ;1e-16
283-
.db $1F,$B1,$4F,$0A ;1e-32
284-
285-
f32_pow10_LUT:
286-
.db $00,$00,$20,$41 ;1e1
287-
.db $00,$00,$C8,$42 ;1e2
288-
.db $00,$40,$1C,$46 ;1e4
289-
.db $20,$BC,$BE,$4C ;1e8
290-
.db $CA,$1B,$0E,$5A ;1e16
291-
.db $AE,$C5,$9D,$74 ;1e32
292-
293-
294284
f32toa_return_0:
295285
ld (hl),'0'
296286
inc hl
@@ -307,12 +297,12 @@ f32toa_return_infnan:
307297
ex de,hl
308298
ld hl,str_NaN
309299
jr nz,f32toa_return
300+
ld hl,str_inf
310301
rr b
311302
jr nc,f32toa_return
312303
ld a,'-'
313304
ld (de),a
314305
inc de
315-
ld hl,str_inf
316306
f32toa_return:
317307
jp mov4
318308

f32/f32_pow10_LUT.z80

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef included_f32_pow10_LUT
2+
#define included_f32_pow10_LUT
3+
f32_pown10_LUT:
4+
.db $CD,$CC,$CC,$3D ;1e-1
5+
.db $0A,$D7,$23,$3C ;1e-2
6+
.db $17,$B7,$D1,$38 ;1e-4
7+
.db $77,$CC,$2B,$32 ;1e-8
8+
.db $95,$95,$E6,$24 ;1e-16
9+
.db $1F,$B1,$4F,$0A ;1e-32
10+
11+
f32_pow10_LUT:
12+
.db $00,$00,$20,$41 ;1e1
13+
.db $00,$00,$C8,$42 ;1e2
14+
.db $00,$40,$1C,$46 ;1e4
15+
.db $20,$BC,$BE,$4C ;1e8
16+
.db $CA,$1B,$0E,$5A ;1e16
17+
.db $AE,$C5,$9D,$74 ;1e32
18+
#endif

0 commit comments

Comments
 (0)