Skip to content

Commit c5ca508

Browse files
committed
Implement enough junk for my long long test program to link
1 parent dfa34fd commit c5ca508

File tree

13 files changed

+448
-5
lines changed

13 files changed

+448
-5
lines changed

src/std/linked/linked.src

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ __ixor := 000198h
8686
__ladd := 00019Ch
8787
public __land
8888
__land := 0001A4h
89+
public __lcmps
90+
__lcmps := 0001A8h
91+
public __lcmpu
92+
__lcmpu := 0001ACh
8993
public __lcmpzero
9094
__lcmpzero := 0001B0h
9195
public __lmuls

src/std/shared/lcmps_fast.src

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public __lcmps_fast
2+
__lcmps_fast:
3+
ld d, a
4+
ld a, e
5+
sub a, d
6+
ret nz
7+
sbc hl, bc
8+
ret z
9+
sbc a, a
10+
ret nz
11+
inc a
12+
ret

src/std/shared/lcmpu_fast.src

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public __lcmpu_fast
2+
__lcmpu_fast:
3+
sub a, e
4+
ccf
5+
ret nz
6+
or a, a
7+
sbc hl, bc
8+
ret

src/std/shared/llcmpu.src

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
public __llcmpu
2+
__llcmpu:
3+
if 0
4+
ld iy, 0
5+
add iy, sp
6+
ld a, b
7+
sub a, (iy + 10)
8+
ret nz
9+
ld a, c
10+
sub a, (iy + 9)
11+
ret nz
12+
ex de, hl
13+
ld bc, (iy + 6)
14+
sbc hl, bc
15+
ret nz
16+
ex de, hl
17+
ld bc, (iy + 3)
18+
sbc hl, bc
19+
ret
20+
else
21+
ld a, c
22+
ld iyh, b
23+
pop bc
24+
or a, a
25+
sbc hl, bc
26+
ex de, hl
27+
pop bc
28+
pop de
29+
jr nz, .ne24
30+
sbc hl, bc
31+
jr nz, .ne48
32+
sbc a, e
33+
jr nz, .ne56
34+
ld a, iyh
35+
sbc a, d
36+
ld hl, 9
37+
add hl, sp
38+
ld sp, hl
39+
ret
40+
.ne24:
41+
sbc hl, bc
42+
.ne48:
43+
sbc a, e
44+
.ne56:
45+
ld a, iyh
46+
sbc a, d
47+
ld hl, 9
48+
add hl, sp
49+
ld sp, hl
50+
ret nz
51+
inc a
52+
ret
53+
end if

src/std/shared/llcmpu_fast.src

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
public __llcmpu_fast
2+
__llcmpu_fast:
3+
if 1
4+
ld iy, 0
5+
add iy, sp
6+
ld a, b
7+
sub a, (iy + 10)
8+
ret nz
9+
ld a, c
10+
sub a, (iy + 9)
11+
ret nz
12+
ex de, hl
13+
ld bc, (iy + 6)
14+
sbc hl, bc
15+
ret nz
16+
ex de, hl
17+
ld bc, (iy + 3)
18+
sbc hl, bc
19+
ret
20+
else
21+
ld a, c
22+
ld iyh, b
23+
pop bc
24+
or a, a
25+
sbc hl, bc
26+
ex de, hl
27+
pop bc
28+
pop de
29+
jr nz, .ne24
30+
sbc hl, bc
31+
jr nz, .ne48
32+
sbc a, e
33+
jr nz, .ne56
34+
ld a, iyh
35+
sbc a, d
36+
ld hl, 9
37+
add hl, sp
38+
ld sp, hl
39+
ret
40+
.ne24:
41+
sbc hl, bc
42+
.ne48:
43+
sbc a, e
44+
.ne56:
45+
ld a, iyh
46+
sbc a, d
47+
ld hl, 9
48+
add hl, sp
49+
ld sp, hl
50+
ret nz
51+
inc a
52+
ret
53+
end if

src/std/shared/lldivu_b_fast.src

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
public __lldivu
2+
__lldivu:
3+
public __lldivu_b_fast
4+
__lldivu_b_fast:
5+
; Not well-optimized
6+
ld iy, 0
7+
add iy, sp
8+
ld iy, (iy + 3)
9+
ld iyh, 64
10+
.loop:
11+
adc hl, hl
12+
ex de, hl
13+
adc hl, hl
14+
ex de, hl
15+
rl c
16+
rl b
17+
rla
18+
jr c, .1
19+
cp a, iyl
20+
jr nc, .0
21+
.1:
22+
sub a, iyl
23+
inc l
24+
.0:
25+
dec iyh
26+
jr nz, .loop
27+
ret

src/std/shared/llmulu_b_fast.src

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
public __llmulu
2+
__llmulu:
3+
public __llmulu_b_fast
4+
__llmulu_b_fast:
5+
ld iy, 0
6+
add iy, sp
7+
push de
8+
push hl
9+
ld a, (iy + 3)
10+
ld h, a
11+
mlt hl
12+
ld (iy - 6), l
13+
ld d, a
14+
ld e, (iy - 5)
15+
mlt de
16+
ld l, h
17+
ld h, 0
18+
add hl, de
19+
ld (iy - 5), l
20+
ld d, a
21+
ld e, (iy - 4)
22+
mlt de
23+
ld l, h
24+
ld h, 0
25+
add hl, de
26+
ld (iy - 4), l
27+
ld d, a
28+
ld e, (iy - 3)
29+
mlt de
30+
ld l, h
31+
ld h, 0
32+
add hl, de
33+
ld (iy - 3), l
34+
ld d, a
35+
ld e, (iy - 2)
36+
mlt de
37+
ld l, h
38+
ld h, 0
39+
add hl, de
40+
ld (iy - 2), l
41+
ld d, a
42+
ld e, (iy - 1)
43+
mlt de
44+
ld l, h
45+
ld h, 0
46+
add hl, de
47+
ld (iy - 1), l
48+
ld d, a
49+
ld e, c
50+
mlt de
51+
ld l, h
52+
ld h, 0
53+
add hl, de
54+
ld c, l
55+
ld d, a
56+
ld e, b
57+
mlt de
58+
ld a, h
59+
add a, e
60+
ld b, a
61+
pop hl
62+
pop de
63+
ret

src/std/shared/llshrs.src

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
public __llshrs
2+
__llshrs:
3+
; Not well-optimized, but it probably works
4+
push iy
5+
ld iy, 0
6+
add iy, sp
7+
push af
8+
ld a, c
9+
ld c, b
10+
ld b, (iy + 6)
11+
inc b
12+
dec b
13+
jr z, .finish
14+
push de
15+
push hl
16+
.loop:
17+
sra c
18+
rra
19+
rr (iy - 1)
20+
rr d
21+
rr e
22+
rr (iy - 4)
23+
rr h
24+
rr l
25+
djnz .loop
26+
ld b, c
27+
ld c, a
28+
.finish:
29+
pop af
30+
pop iy
31+
ret

0 commit comments

Comments
 (0)