Skip to content

Commit 457dd04

Browse files
committed
Restored FASMG require keyword (commented out for now)
1 parent ea7a461 commit 457dd04

13 files changed

Lines changed: 187 additions & 54 deletions

File tree

src/crt/and.src

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
.section .text
44
.global __land
55
.type __land, @function
6-
.section .text
7-
.global __iand
8-
.type __iand, @function
96

107
.ifdef PREFER_OS_CRT
118

129
.set __land, 0x0001A4
13-
.set __iand, 0x000134
1410

1511
.else
1612

@@ -21,6 +17,21 @@ __land:
2117
ld e, a
2218
; jr .L.hijack_land
2319
.db 0x3E ; ld a, *
20+
21+
; REQUIRE require __iand
22+
23+
.endif
24+
25+
; REQUIRE .section .text
26+
.global __iand
27+
.type __iand, @function
28+
29+
.ifdef PREFER_OS_CRT
30+
31+
.set __iand, 0x000134
32+
33+
.else
34+
2435
__iand:
2536
; CC: 24*r(PC)+11*r(SPL)+10*w(SPL)+1
2637
push af

src/crt/and_fast.src

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
.section .text
44
.global __land_fast
55
.type __land_fast, @function
6-
.global __iand_fast
7-
.type __iand_fast, @function
8-
.global __sand_fast
9-
.type __sand_fast, @function
106

117
__land_fast:
128
; CC: 24*r(PC)+8*r(SPL)+7*w(SPL)+1
139
and a, e
1410
ld e, a
11+
; REQUIRE require __iand_fast
12+
13+
; REQUIRE .section .text
14+
.global __iand_fast
15+
.type __iand_fast, @function
16+
1517
__iand_fast:
1618
; CC: 22*r(PC)+8*r(SPL)+7*w(SPL)+1
1719
push hl
@@ -27,6 +29,12 @@ __iand_fast:
2729
and a, (hl)
2830
ld (hl), a
2931
pop hl
32+
; REQUIRE require __sand_fast
33+
34+
; REQUIRE .section .text
35+
.global __sand_fast
36+
.type __sand_fast, @function
37+
3038
__sand_fast:
3139
; CC: 8*r(PC)+3*r(SPL)+1
3240
ld a, h

src/crt/ctlz.src

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ __sctlz:
4040
or a, a
4141
jr nz, __bctlz
4242
ld a, l
43+
; REQUIRE require __sctlz.hijack
44+
45+
; REQUIRE .section .text.__sctlz.hijack
4346
.local __sctlz.hijack
4447
__sctlz.hijack:
4548
call __bctlz

src/crt/cttz.src

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
__bcttz:
88
cp a, 1
9+
; REQUIRE require __cttz_common
910

11+
; REQUIRE .section .text.__cttz_common
1012
.local __cttz_common
1113
; Input: A=byte, CF=(A==0)
1214
; Output: A=cttz(A)
@@ -45,6 +47,9 @@ __scttz:
4547
jr nz, __cttz_common
4648
sub a, h
4749
ccf
50+
; REQUIRE require __scttz.hijack
51+
52+
; REQUIRE .section .text.__scttz.hijack
4853
.local __scttz.hijack
4954
__scttz.hijack:
5055
call __cttz_common
@@ -56,6 +61,9 @@ __scttz.hijack:
5661
.type __icttz, @function
5762
__icttz:
5863
xor a, a
64+
; REQUIRE require __icttz.hijack
65+
66+
; REQUIRE .section .text.__icttz.hijack
5967
.local __icttz.hijack
6068
__icttz.hijack:
6169
or a, l
@@ -116,6 +124,9 @@ __i48cttz:
116124
sbc hl, de
117125
jr nz, __icttz.hijack
118126
ex de, hl
127+
; REQUIRE require __i48cttz.hijack
128+
129+
; REQUIRE .section .text.__i48cttz.hijack
119130
.local __i48cttz.hijack
120131
__i48cttz.hijack:
121132
call __icttz.hijack

src/crt/i48shr.src

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
.section .text
99
.global __i48shrs
1010
.type __i48shrs, @function
11-
.global __i48shru
12-
.type __i48shru, @function
1311

1412
__i48shrs:
1513
inc c
1614
dec c
1715
ret z
1816
cp a, a ; Set Z flag
1917
db $C2 ; inc c \ dec c \ ret z -> jp nz, *
18+
; REQUIRE require __i48shru
19+
20+
; REQUIRE .section .text
21+
.global __i48shru
22+
.type __i48shru, @function
2023
__i48shru:
2124
inc c
2225
dec c

src/crt/ltod.src

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
11
.assume adl=1
22

3+
;-------------------------------------------------------------------------------
4+
35
.section .text
46

57
.global __ulltod
68
.type __ulltod, @function
7-
.global __lltod
8-
.type __lltod, @function
9-
.global __ultod
10-
.type __ultod, @function
11-
.global __ltod
12-
.type __ltod, @function
13-
149
__ulltod:
1510
; (long double)unsigned long long
1611
cp a, a ; set Z flag
1712
push af
18-
jr .L.lltod_common
13+
jr __lltod_common
14+
; REQUIRE jq __lltod_common
15+
16+
;-------------------------------------------------------------------------------
17+
18+
; REQUIRE .section .text
19+
20+
.global __lltod
21+
.type __lltod, @function
1922
__lltod:
2023
; (long double)long long
2124
bit 7, b
2225
push af
2326
call nz, __llneg ; abs(BC:UDE:UHL)
24-
.L.lltod_common:
27+
28+
; REQUIRE require __lltod_common
29+
30+
;-------------------------------------------------------------------------------
31+
32+
; REQUIRE .section .text
33+
34+
.local __lltod_common
35+
__lltod_common:
2536
call __llctlz
2637
sub a, 63 ; normalize clz_result
2738
; filter out exponent of $000 (zero) and $3FF (one)
28-
jr nc, .L.int_to_f64_zero_or_one
39+
jr nc, __int_to_f64_zero_or_one
2940
; A is [-63, -1]
3041
add a, 52
3142
; A is [-11, 51]
32-
jr c, .L.int_to_f64_shl
43+
jr c, __int_to_f64_shl
3344
; __int_to_f64_shr:
3445
; exponent = (1023 or $3FF or f64_bias) + base2_logarithm
3546
; Minimum exponent: $434 (2^53)
@@ -89,25 +100,30 @@ __lltod:
89100
or a, a ; NZ = round-up, Z = no-round
90101
ld b, $43
91102
.if 0
92-
jr z, .L.int_to_f64_shl.no_round
103+
jr z, __int_to_f64_shl.no_round
93104
; inlined __lladd_1
94105
inc hl
95106
add hl, de
96107
or a, a
97108
sbc hl, de
98-
jr nz, .L.int_to_f64_shl.finish
109+
jr nz, __int_to_f64_shl.finish
99110
inc de
100111
sbc hl, de
101112
add hl, de
102-
jr nz, .L.int_to_f64_shl.finish
113+
jr nz, __int_to_f64_shl.finish
103114
inc bc
104-
jr .L.int_to_f64_shl.finish
115+
jr __int_to_f64_shl.finish
105116
.else
106117
call nz, __lladd_1 ; round up to even
107-
jr .L.int_to_f64_shl.finish
118+
jr __int_to_f64_shl.finish
108119
.endif
109120

110-
.L.int_to_f64_zero_or_one:
121+
;-------------------------------------------------------------------------------
122+
123+
; REQUIRE .section .text
124+
125+
.local __int_to_f64_zero_or_one
126+
__int_to_f64_zero_or_one:
111127
; carry is cleared here
112128
; UHL is either one or zero
113129
ld b, h
@@ -118,29 +134,58 @@ __lltod:
118134
.L.ret_zero:
119135
ex de, hl
120136
sbc hl, hl
121-
jr .L.int_to_f64_shl.finish
137+
jr __int_to_f64_shl.finish
138+
139+
;-------------------------------------------------------------------------------
122140

141+
; REQUIRE .section .text
142+
143+
.global __ultod
144+
.type __ultod, @function
123145
__ultod:
124146
; (long double)unsigned long
125147
cp a, a ; set Z flag
126148
push af
127-
jr .L.ltod_common
149+
jr __ltod_common
150+
; REQUIRE jq __ltod_common
151+
152+
;-------------------------------------------------------------------------------
153+
154+
; REQUIRE .section .text
155+
156+
.global __ltod
157+
.type __ltod, @function
128158
__ltod:
129159
; (long double)long
130160
bit 7, e
131161
push af
132162
call nz, __lneg ; abs(E:UHL)
133-
.L.ltod_common:
163+
164+
; REQUIRE require __ltod_common
165+
166+
;-------------------------------------------------------------------------------
167+
168+
; REQUIRE .section .text
169+
170+
.local __ltod_common
171+
__ltod_common:
134172
call __lctlz
135173
sub a, 31 ; normalize clz_result
136174

137175
; filter out exponent of $000 (zero) and $3FF (one)
138-
jr nc, .L.int_to_f64_zero_or_one
176+
jr nc, __int_to_f64_zero_or_one
139177
; A is [-31, -1]
140178
add a, 52
141179
; A is [21, 51]
142180

143-
.L.int_to_f64_shl:
181+
; REQUIRE require __int_to_f64_shl
182+
183+
;-------------------------------------------------------------------------------
184+
185+
; REQUIRE .section .text
186+
187+
.local __int_to_f64_shl
188+
__int_to_f64_shl:
144189
; exponent = (1023 or $3FF or f64_bias) + base2_logarithm
145190
; Minimum exponent: $400 (2^1)
146191
; Maximum exponent: $434 (2^52)
@@ -169,8 +214,10 @@ __ltod:
169214
ld c, a
170215
ld b, h
171216
pop hl ; restore shifted HL
172-
.L.int_to_f64_shl.no_round:
173-
.L.int_to_f64_shl.finish:
217+
.local __int_to_f64_shl.no_round
218+
__int_to_f64_shl.no_round:
219+
.local __int_to_f64_shl.finish
220+
__int_to_f64_shl.finish:
174221
pop af
175222
ret z
176223
set 7, b

src/crt/or.src

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
.section .text
44
.global __lor
55
.type __lor, @function
6-
.global __ior
7-
.type __ior, @function
86

97
.ifdef PREFER_OS_CRT
108

119
.set __lor, 0x0001D8
12-
.set __ior, 0x000168
1310

1411
.else
1512

@@ -20,6 +17,21 @@ __lor:
2017
ld e, a
2118
; jr .L.hijack_lor
2219
.db 0x3E ; ld a, *
20+
21+
; REQUIRE require __ior
22+
23+
.endif
24+
25+
; REQUIRE .section .text
26+
.global __ior
27+
.type __ior, @function
28+
29+
.ifdef PREFER_OS_CRT
30+
31+
.set __ior, 0x000168
32+
33+
.else
34+
2335
__ior:
2436
; CC: 24*r(PC)+11*r(SPL)+10*w(SPL)+1
2537
push af

src/crt/or_fast.src

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
.section .text
44
.global __lor_fast
55
.type __lor_fast, @function
6-
.global __ior_fast
7-
.type __ior_fast, @function
8-
.global __sor_fast
9-
.type __sor_fast, @function
106

117
__lor_fast:
128
; CC: 24*r(PC)+8*r(SPL)+7*w(SPL)+1
139
or a, e
1410
ld e, a
11+
; REQUIRE require __ior_fast
12+
13+
; REQUIRE .section .text
14+
.global __ior_fast
15+
.type __ior_fast, @function
16+
1517
__ior_fast:
1618
; CC: 22*r(PC)+8*r(SPL)+7*w(SPL)+1
1719
push hl
@@ -27,6 +29,12 @@ __ior_fast:
2729
or a, (hl)
2830
ld (hl), a
2931
pop hl
32+
; REQUIRE require __sor_fast
33+
34+
; REQUIRE .section .text
35+
.global __sor_fast
36+
.type __sor_fast, @function
37+
3038
__sor_fast:
3139
; CC: 8*r(PC)+3*r(SPL)+1
3240
ld a, h

0 commit comments

Comments
 (0)