mirror of
https://github.com/irmen/prog8.git
synced 2024-12-27 20:33:39 +00:00
fix for loop with signed byte loopvar over non-const
This commit is contained in:
parent
afd155ac4f
commit
fefd9b52a8
@ -54,11 +54,11 @@ internal class ForLoopsAsmGen(private val program: Program, private val asmgen:
|
|||||||
asmgen.out(loopLabel)
|
asmgen.out(loopLabel)
|
||||||
asmgen.translate(stmt.body)
|
asmgen.translate(stmt.body)
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
lda $varname
|
lda $varname
|
||||||
$modifiedLabel cmp #0 ; modified
|
$modifiedLabel cmp #0 ; modified
|
||||||
beq $endLabel
|
beq $endLabel
|
||||||
$incdec $varname
|
$incdec $varname
|
||||||
jmp $loopLabel
|
jmp $loopLabel
|
||||||
$endLabel""")
|
$endLabel""")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -71,22 +71,23 @@ $endLabel""")
|
|||||||
asmgen.assignExpressionToVariable(range.to, "$modifiedLabel+1", ArrayElementTypes.getValue(iterableDt), null)
|
asmgen.assignExpressionToVariable(range.to, "$modifiedLabel+1", ArrayElementTypes.getValue(iterableDt), null)
|
||||||
asmgen.out(loopLabel)
|
asmgen.out(loopLabel)
|
||||||
asmgen.translate(stmt.body)
|
asmgen.translate(stmt.body)
|
||||||
asmgen.out(" lda $varname")
|
|
||||||
if(stepsize>0) {
|
if(stepsize>0) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
clc
|
lda $varname
|
||||||
adc #$stepsize
|
clc
|
||||||
sta $varname
|
adc #$stepsize
|
||||||
$modifiedLabel cmp #0 ; modified
|
sta $varname
|
||||||
bcc $loopLabel
|
$modifiedLabel cmp #0 ; modified
|
||||||
beq $loopLabel""")
|
bmi $loopLabel
|
||||||
|
beq $loopLabel""")
|
||||||
} else {
|
} else {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
sec
|
lda $varname
|
||||||
sbc #${stepsize.absoluteValue}
|
sec
|
||||||
sta $varname
|
sbc #${stepsize.absoluteValue}
|
||||||
$modifiedLabel cmp #0 ; modified
|
sta $varname
|
||||||
bcs $loopLabel""")
|
$modifiedLabel cmp #0 ; modified
|
||||||
|
bpl $loopLabel""")
|
||||||
}
|
}
|
||||||
asmgen.out(endLabel)
|
asmgen.out(endLabel)
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,10 @@ main {
|
|||||||
uword uw
|
uword uw
|
||||||
word ww
|
word ww
|
||||||
|
|
||||||
ubyte arrub = 10
|
const ubyte arrub = 10
|
||||||
uword arruw = 10
|
const uword arruw = 10
|
||||||
byte arrb = 10
|
const byte arrb = 10
|
||||||
word arrw = 10
|
const word arrw = 10
|
||||||
|
|
||||||
test_stack.test()
|
test_stack.test()
|
||||||
|
|
||||||
@ -73,11 +73,11 @@ main {
|
|||||||
}
|
}
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
|
|
||||||
for ww in arrw-2 to -2 step -2 {
|
; for ww in arrw-2 to -2 step -2 {
|
||||||
txt.print_w(ww)
|
; txt.print_w(ww)
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
}
|
; }
|
||||||
txt.chrout('\n')
|
; txt.chrout('\n')
|
||||||
|
|
||||||
test_stack.test()
|
test_stack.test()
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user