-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathto_xfloat.z80
145 lines (134 loc) · 2.13 KB
/
to_xfloat.z80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
to_xfloat_LUT:
.db (+_-$-1)/2
.dw ui8_convert_to_xfloat
.dw ui16_convert_to_xfloat
.dw ui32_convert_to_xfloat
.dw fixed88_convert_to_xfloat
.dw fixed1616_convert_to_xfloat
.dw var_convert_to_xfloat
.dw true_convert_to_xfloat
.dw false_convert_to_xfloat
.dw tstr_ref_convert_to_xfloat
.dw raw_convert_to_xfloat
.dw str_convert_to_xfloat
.dw str_ref_convert_to_xfloat
.dw single_convert_to_xfloat
.dw xfloat_convert_to_xfloat
.dw err_syntax
.dw err_syntax
.dw char_convert_to_xfloat
_:
char_convert_to_xfloat:
ui8_convert_to_xfloat:
ld bc,$4007
ld a,(de)
or a
jp z,false_convert_to_xfloat
jr ui8_to_xfloat_begin
_:
dec c
add a,a
ui8_to_xfloat_begin:
jp p,-_
;BC is the exponent
;A is the top byte
ld (OP1+8),bc
ld hl,OP1+7
ld (hl),a
ld bc,$700
_:
dec hl
ld (hl),c
djnz -_
ret
fixed88_convert_to_xfloat:
ld bc,$4007
jr +_
ui16_convert_to_xfloat:
ld bc,$400F
_:
ex de,hl
ld e,(hl)
inc hl
ld d,(hl)
ex de,hl
ld a,h
or l
jr z,false_convert_to_xfloat
ld a,h
jr ui16_to_xfloat_begin
_:
dec bc
add hl,hl
ui16_to_xfloat_begin:
or h
jp p,-_
;BC is the exponent
;HL is the top bytes
ld (OP1+8),bc
ld (OP1+6),hl
ld hl,OP1+6
ld bc,$600
_:
dec hl
ld (hl),c
djnz -_
ret
fixed1616_convert_to_xfloat:
ld bc,$400F
jr +_
ui32_convert_to_xfloat:
ld bc,$401F
_:
ex de,hl
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
ex de,hl
;DEHL is the uint32
or h
or l
or d
jr z,false_convert_to_xfloat
ld a,d
jr ui32_to_xfloat_begin
_:
dec bc
add hl,hl
rl e
rl d
ui32_to_xfloat_begin:
or d
jp p,-_
;BC is the exponent
;DEHL are the top bytes
ld (OP1+8),bc
ld (OP1+6),de
ld (OP1+4),hl
ld hl,0
ld (OP1+2),hl
ld (OP1),hl
ld hl,OP1
ret
var_convert_to_xfloat:
jp err_bad_type
true_convert_to_xfloat:
ld a,X_CONST_1
jp xconst_to_xOP1_p0
false_convert_to_xfloat:
ld a,X_CONST_0
jp xconst_to_xOP1_p0
tstr_ref_convert_to_xfloat:
raw_convert_to_xfloat:
str_convert_to_xfloat:
str_ref_convert_to_xfloat:
single_convert_to_xfloat:
jp err_bad_type
xfloat_convert_to_xfloat:
ex de,hl
ret