Skip to content

Commit e0e767b

Browse files
authored
Fix signed comparisons
1 parent 3fafdb3 commit e0e767b

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

src/crt/lcmps.src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ __lcmps:
1717
jr nz, .finish
1818
sbc hl, bc
1919
add hl, bc
20+
sbc a, a
2021
.finish:
2122
ld a, d
2223
pop de

src/crt/lcmps_fast.src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ __lcmps_fast:
88
sub a, d
99
ret nz
1010
sbc hl, bc
11+
sbc a, a
1112
ret

src/crt/llcmps.src

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@ __llcmps:
1313
ld bc, (iy + 12)
1414
sbc.s hl, bc
1515
pop hl
16-
jr nz, .ne
16+
jr nz, .finish
1717
ld bc, (iy + 9)
1818
ex de, hl
1919
sbc hl, de
2020
add hl, de
2121
ex de, hl
22-
jr nz, .ne
22+
jr nz, .finish_unsigned
2323
ld bc, (iy + 6)
2424
sbc hl, bc
2525
add hl, bc
26-
.ne:
26+
.finish_unsigned:
27+
ld b, a
28+
sbc a, a
29+
ld a, b
30+
.finish:
2731
pop bc
2832
pop iy
2933
ret

src/crt/llcmps_fast.src

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
assume adl=1
2+
3+
section .text
4+
public __llcmps_fast
5+
__llcmps_fast:
6+
ld iy, 0
7+
add iy, sp
8+
ld a, b
9+
sub a, (iy + 10)
10+
ret nz
11+
ld a, c
12+
sub a, (iy + 9)
13+
jr nz, .finish
14+
ex de, hl
15+
ld bc, (iy + 6)
16+
sbc hl, bc
17+
jr nz, .finish
18+
ex de, hl
19+
ld bc, (iy + 3)
20+
sbc hl, bc
21+
.finish:
22+
sbc a, a
23+
ret

src/crt/llcmpu_fast.src

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
assume adl=1
22

33
section .text
4-
public __llcmps_fast
5-
__llcmps_fast:
64
public __llcmpu_fast
75
__llcmpu_fast:
86
ld iy, 0

0 commit comments

Comments
 (0)