mirror of
https://github.com/irmen/prog8.git
synced 2025-01-12 04:30:03 +00:00
invalid repeat loop code is generated...
This commit is contained in:
parent
ebf4b50059
commit
10145b946b
@ -938,6 +938,7 @@ internal class AsmGen(private val program: Program,
|
|||||||
when {
|
when {
|
||||||
iterations == 0 -> {}
|
iterations == 0 -> {}
|
||||||
iterations <= 256 -> {
|
iterations <= 256 -> {
|
||||||
|
// TODO faulty loop code when 256 because of the beq that's also generated (should be ok if that is removed?)
|
||||||
out(" lda #${iterations and 255}")
|
out(" lda #${iterations and 255}")
|
||||||
repeatByteCountInA(iterations, repeatLabel, endLabel, stmt.body)
|
repeatByteCountInA(iterations, repeatLabel, endLabel, stmt.body)
|
||||||
}
|
}
|
||||||
@ -985,6 +986,7 @@ internal class AsmGen(private val program: Program,
|
|||||||
private fun repeatWordCountInAY(constIterations: Int?, repeatLabel: String, endLabel: String, body: AnonymousScope) {
|
private fun repeatWordCountInAY(constIterations: Int?, repeatLabel: String, endLabel: String, body: AnonymousScope) {
|
||||||
// note: A/Y must have been loaded with the number of iterations already!
|
// note: A/Y must have been loaded with the number of iterations already!
|
||||||
val counterVar = makeLabel("repeatcounter")
|
val counterVar = makeLabel("repeatcounter")
|
||||||
|
// TODO the 0.w check at the start is invalid(wrong register check order), and must not be done at all if the loop count is numeric literal >0
|
||||||
out("""
|
out("""
|
||||||
bne +
|
bne +
|
||||||
cpy #0
|
cpy #0
|
||||||
@ -1018,6 +1020,7 @@ $counterVar .word 0""")
|
|||||||
private fun repeatByteCountInA(constIterations: Int?, repeatLabel: String, endLabel: String, body: AnonymousScope) {
|
private fun repeatByteCountInA(constIterations: Int?, repeatLabel: String, endLabel: String, body: AnonymousScope) {
|
||||||
// note: A must have been loaded with the number of iterations already!
|
// note: A must have been loaded with the number of iterations already!
|
||||||
val counterVar = makeLabel("repeatcounter")
|
val counterVar = makeLabel("repeatcounter")
|
||||||
|
// TODO the beq endlabel check can be omitted if the number of iterations is a numeric literal >0
|
||||||
out("""
|
out("""
|
||||||
beq $endLabel
|
beq $endLabel
|
||||||
sta $counterVar
|
sta $counterVar
|
||||||
|
@ -7,8 +7,50 @@
|
|||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
derp()
|
ubyte xx = 0
|
||||||
rec2()
|
repeat 254 {
|
||||||
|
txt.chrout('1')
|
||||||
|
xx++
|
||||||
|
}
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
xx=0
|
||||||
|
|
||||||
|
repeat 255 {
|
||||||
|
txt.chrout('2')
|
||||||
|
xx++
|
||||||
|
}
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
xx=0
|
||||||
|
repeat 256 { ; TODO generates faulty code, loop is never executed at all
|
||||||
|
txt.chrout('3')
|
||||||
|
xx++
|
||||||
|
}
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
xx=0
|
||||||
|
repeat 257 { ; TODO generates invalid 0-check code at start
|
||||||
|
txt.chrout('4')
|
||||||
|
xx++
|
||||||
|
}
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
ubyte bb
|
||||||
|
|
||||||
|
repeat bb {
|
||||||
|
xx++
|
||||||
|
}
|
||||||
|
|
||||||
|
uword ww
|
||||||
|
|
||||||
|
repeat ww {
|
||||||
|
xx++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub rec2() {
|
sub rec2() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user