mirror of
https://github.com/irmen/prog8.git
synced 2025-08-13 00:25:17 +00:00
fix asm gen for loops when dealing with registers as loopvar
This commit is contained in:
@@ -2066,7 +2066,20 @@ internal val patterns = listOf<AsmPattern>(
|
|||||||
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.CMP_B), listOf(Opcode.PUSH_VAR_BYTE, Opcode.CMP_UB)) { segment ->
|
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.CMP_B), listOf(Opcode.PUSH_VAR_BYTE, Opcode.CMP_UB)) { segment ->
|
||||||
// this pattern is encountered as part of the loop bound condition in for loops (var + cmp + jz/jnz)
|
// this pattern is encountered as part of the loop bound condition in for loops (var + cmp + jz/jnz)
|
||||||
val cmpval = segment[1].arg!!.integerValue()
|
val cmpval = segment[1].arg!!.integerValue()
|
||||||
" lda ${segment[0].callLabel} | cmp #$cmpval "
|
when(segment[0].callLabel) {
|
||||||
|
"A" -> {
|
||||||
|
" cmp #$cmpval "
|
||||||
|
}
|
||||||
|
"X" -> {
|
||||||
|
" cpx #$cmpval "
|
||||||
|
}
|
||||||
|
"Y" -> {
|
||||||
|
" cpy #$cmpval "
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
" lda ${segment[0].callLabel} | cmp #$cmpval "
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_WORD, Opcode.CMP_W), listOf(Opcode.PUSH_VAR_WORD, Opcode.CMP_UW)) { segment ->
|
AsmPattern(listOf(Opcode.PUSH_VAR_WORD, Opcode.CMP_W), listOf(Opcode.PUSH_VAR_WORD, Opcode.CMP_UW)) { segment ->
|
||||||
// this pattern is encountered as part of the loop bound condition in for loops (var + cmp + jz/jnz)
|
// this pattern is encountered as part of the loop bound condition in for loops (var + cmp + jz/jnz)
|
||||||
|
@@ -4,17 +4,13 @@
|
|||||||
~ main {
|
~ main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
A=0
|
|
||||||
Y=0
|
|
||||||
ubyte aa =0
|
|
||||||
|
|
||||||
Y=10
|
|
||||||
|
|
||||||
for A in 0 to 4 {
|
for A in 0 to 4 {
|
||||||
for Y in 0 to 3 {
|
for Y in 0 to 3 {
|
||||||
rsave()
|
rsave()
|
||||||
c64scr.print_ub(A)
|
c64scr.print_ub(A)
|
||||||
c64.CHROUT(',')
|
c64.CHROUT(',')
|
||||||
|
rrestore()
|
||||||
|
rsave()
|
||||||
c64scr.print_ub(Y)
|
c64scr.print_ub(Y)
|
||||||
c64.CHROUT('\n')
|
c64.CHROUT('\n')
|
||||||
rrestore()
|
rrestore()
|
||||||
|
Reference in New Issue
Block a user