mirror of
https://github.com/irmen/prog8.git
synced 2024-10-25 00:24:16 +00:00
Optimize sign extension to AY
This commit is contained in:
parent
69b9dfa468
commit
73dfb5f443
@ -1707,7 +1707,13 @@ $repeatLabel lda $counterVar
|
|||||||
// sign extend signed byte in A to full word in AY
|
// sign extend signed byte in A to full word in AY
|
||||||
when(valueDt) {
|
when(valueDt) {
|
||||||
DataType.UBYTE -> out(" ldy #0")
|
DataType.UBYTE -> out(" ldy #0")
|
||||||
DataType.BYTE -> out(" jsr prog8_lib.sign_extend_AY_byte")
|
DataType.BYTE -> out("""
|
||||||
|
ldy #0
|
||||||
|
cmp #$80
|
||||||
|
bcc +
|
||||||
|
dey
|
||||||
|
+
|
||||||
|
""")
|
||||||
else -> throw AssemblyError("need byte type")
|
else -> throw AssemblyError("need byte type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1158,20 +1158,6 @@ sign_extend_stack_byte .proc
|
|||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
|
|
||||||
sign_extend_AY_byte .proc
|
|
||||||
; -- sign extend the (signed) byte in AY to full 16 bits
|
|
||||||
pha
|
|
||||||
and #$80
|
|
||||||
beq +
|
|
||||||
ldy #$ff
|
|
||||||
pla
|
|
||||||
rts
|
|
||||||
+ ldy #0
|
|
||||||
pla
|
|
||||||
rts
|
|
||||||
.pend
|
|
||||||
|
|
||||||
strlen .proc
|
strlen .proc
|
||||||
; -- returns the number of bytes in the string in AY, in Y.
|
; -- returns the number of bytes in the string in AY, in Y.
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
|
Loading…
Reference in New Issue
Block a user