mirror of
https://github.com/irmen/prog8.git
synced 2025-01-23 15:30:10 +00:00
fix asm gen for loops when dealing with registers as loopvar
This commit is contained in:
parent
9a3dab20dc
commit
aaaab2cfcf
@ -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 ->
|
||||
// this pattern is encountered as part of the loop bound condition in for loops (var + cmp + jz/jnz)
|
||||
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 ->
|
||||
// this pattern is encountered as part of the loop bound condition in for loops (var + cmp + jz/jnz)
|
||||
|
@ -4,17 +4,13 @@
|
||||
~ main {
|
||||
|
||||
sub start() {
|
||||
A=0
|
||||
Y=0
|
||||
ubyte aa =0
|
||||
|
||||
Y=10
|
||||
|
||||
for A in 0 to 4 {
|
||||
for Y in 0 to 3 {
|
||||
rsave()
|
||||
c64scr.print_ub(A)
|
||||
c64.CHROUT(',')
|
||||
rrestore()
|
||||
rsave()
|
||||
c64scr.print_ub(Y)
|
||||
c64.CHROUT('\n')
|
||||
rrestore()
|
||||
|
Loading…
x
Reference in New Issue
Block a user