mirror of
https://github.com/irmen/prog8.git
synced 2024-11-19 11:32:17 +00:00
fixed missing shifts codegen
This commit is contained in:
parent
164ac56db1
commit
7d8496c874
@ -240,16 +240,28 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
||||
}
|
||||
}
|
||||
DataType.UWORD -> {
|
||||
if(amount<=2)
|
||||
repeat(amount) { asmgen.out(" lsr $ESTACK_HI_PLUS1_HEX,x | ror $ESTACK_LO_PLUS1_HEX,x") }
|
||||
else
|
||||
asmgen.out(" jsr math.shift_right_uw_$amount") // 3-7 (8+ is done via other optimizations)
|
||||
if (amount<=2) repeat(amount) { asmgen.out(" lsr $ESTACK_HI_PLUS1_HEX,x | ror $ESTACK_LO_PLUS1_HEX,x") }
|
||||
else {
|
||||
var left = amount
|
||||
while(left>=7) {
|
||||
asmgen.out(" jsr math.shift_right_uw_7")
|
||||
left -= 7
|
||||
}
|
||||
if(left>0)
|
||||
asmgen.out(" jsr math.shift_right_uw_$left")
|
||||
}
|
||||
}
|
||||
DataType.WORD -> {
|
||||
if(amount<=2)
|
||||
repeat(amount) { asmgen.out(" lda $ESTACK_HI_PLUS1_HEX,x | asl a | ror $ESTACK_HI_PLUS1_HEX,x | ror $ESTACK_LO_PLUS1_HEX,x") }
|
||||
else
|
||||
asmgen.out(" jsr math.shift_right_w_$amount") // 3-7 (8+ is done via other optimizations)
|
||||
if (amount<=2) repeat(amount) { asmgen.out(" lda $ESTACK_HI_PLUS1_HEX,x | asl a | ror $ESTACK_HI_PLUS1_HEX,x | ror $ESTACK_LO_PLUS1_HEX,x") }
|
||||
else {
|
||||
var left=amount
|
||||
while(left>=7) {
|
||||
asmgen.out(" jsr math.shift_right_w_7")
|
||||
left -= 7
|
||||
}
|
||||
if(left>0)
|
||||
asmgen.out(" jsr math.shift_right_w_$left")
|
||||
}
|
||||
}
|
||||
else -> throw AssemblyError("weird type")
|
||||
}
|
||||
@ -269,10 +281,15 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(amount<=2) {
|
||||
repeat(amount) { asmgen.out(" asl $ESTACK_LO_PLUS1_HEX,x | rol $ESTACK_HI_PLUS1_HEX,x") }
|
||||
} else {
|
||||
asmgen.out(" jsr math.shift_left_w_$amount") // 3-7 (8+ is done via other optimizations)
|
||||
if (amount<=2) repeat(amount) { asmgen.out(" asl $ESTACK_LO_PLUS1_HEX,x | rol $ESTACK_HI_PLUS1_HEX,x") }
|
||||
else {
|
||||
var left=amount
|
||||
while(left>=7) {
|
||||
asmgen.out(" jsr math.shift_left_w_7")
|
||||
left -= 7
|
||||
}
|
||||
if(left > 0)
|
||||
asmgen.out(" jsr math.shift_left_w_$left")
|
||||
}
|
||||
}
|
||||
return
|
||||
|
@ -1,8 +1,6 @@
|
||||
%import c64lib
|
||||
%import c64utils
|
||||
|
||||
; TODO fix compiler errors when compiling without optimizations
|
||||
|
||||
|
||||
spritedata $2000 {
|
||||
; this memory block contains the sprite data
|
||||
|
Loading…
Reference in New Issue
Block a user