Skip to content

Commit 9b14449

Browse files
committed
optimize neg in truncl
1 parent 04412f4 commit 9b14449

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/libc/truncl.src

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _truncl:
1111
ld hl, (iy + 9)
1212
ld a, h
1313
add.s hl, hl
14-
ld de, 0xFF8020 ; -1023 shl 5
14+
ld de, 0xFF8020 ; -1023 shl 5
1515
add.s hl, de
1616
jr nc, .L.ret_zero
1717
; ld de, 0xFFF980 ; -52 shl 5
@@ -23,8 +23,8 @@ _truncl:
2323
add hl, hl
2424
add hl, hl
2525
add hl, hl
26-
ld a, h
27-
neg ; carry will be set as A is not zero
26+
xor a, a
27+
sub a, h ; carry will be set as H is not zero
2828
ld b, a
2929
; UINT56_MAX
3030
sbc a, a
@@ -40,7 +40,7 @@ _truncl:
4040
ex de, hl
4141
rla
4242
djnz .L.loop
43-
dec b ; b = $FF
43+
dec b ; b = $FF
4444
ld c, a
4545
; values already on the stack
4646
jp __lland

0 commit comments

Comments
 (0)