mirror of
https://github.com/irmen/prog8.git
synced 2024-10-06 09:58:13 +00:00
Revert "optimized repeat loop for word counts"
This reverts commit 51e6bf0d
This commit is contained in:
parent
51e6bf0d45
commit
eba0708099
@ -1008,30 +1008,28 @@ 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!
|
|
||||||
if(constIterations==0)
|
if(constIterations==0)
|
||||||
return
|
return
|
||||||
if(constIterations==null) {
|
// note: A/Y must have been loaded with the number of iterations already!
|
||||||
|
val counterVar = makeLabel("repeatcounter")
|
||||||
out("""
|
out("""
|
||||||
cmp #0
|
cmp #0
|
||||||
bne +
|
bne +
|
||||||
cpy #0
|
cpy #0
|
||||||
beq $endLabel ; skip if 0 iterations
|
beq $endLabel ; skip if 0 iterations
|
||||||
+""")
|
+ sta $counterVar
|
||||||
}
|
|
||||||
val counterVar = makeLabel("repeatcounter")
|
|
||||||
out("""
|
|
||||||
sta $counterVar
|
|
||||||
iny
|
|
||||||
sty $counterVar+1
|
sty $counterVar+1
|
||||||
$repeatLabel""")
|
$repeatLabel
|
||||||
translate(body)
|
lda $counterVar
|
||||||
out("""
|
bne +
|
||||||
dec $counterVar
|
lda $counterVar+1
|
||||||
bne $repeatLabel
|
beq $endLabel
|
||||||
|
+ lda $counterVar
|
||||||
|
bne +
|
||||||
dec $counterVar+1
|
dec $counterVar+1
|
||||||
bne $repeatLabel
|
+ dec $counterVar""")
|
||||||
beq $endLabel""")
|
translate(body)
|
||||||
|
jmp(repeatLabel)
|
||||||
|
|
||||||
if(constIterations!=null && constIterations>=16 && zeropage.available() > 1) {
|
if(constIterations!=null && constIterations>=16 && zeropage.available() > 1) {
|
||||||
// allocate count var on ZP
|
// allocate count var on ZP
|
||||||
|
@ -3,51 +3,25 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub iter(uword iterations) -> uword {
|
|
||||||
uword total = 0
|
|
||||||
repeat iterations {
|
|
||||||
repeat iterations {
|
|
||||||
total++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return total
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
uword xx1
|
uword xx1
|
||||||
uword xx2
|
uword xx2
|
||||||
uword xx3
|
uword xx3
|
||||||
uword iterations
|
uword iterations
|
||||||
|
|
||||||
xx1 = iter(0)
|
|
||||||
txt.print_uw(xx1) ; 0
|
|
||||||
txt.nl()
|
|
||||||
xx1 = iter(10)
|
|
||||||
txt.print_uw(xx1) ; 100
|
|
||||||
txt.nl()
|
|
||||||
xx1 = iter(16)
|
|
||||||
txt.print_uw(xx1) ; 256
|
|
||||||
txt.nl()
|
|
||||||
xx1 = iter(20)
|
|
||||||
txt.print_uw(xx1) ; 400
|
|
||||||
txt.nl()
|
|
||||||
xx1 = iter(200)
|
|
||||||
txt.print_uw(xx1) ; 4000
|
|
||||||
txt.nl()
|
|
||||||
xx1 = iter(600)
|
|
||||||
txt.print_uw(xx1) ; 32320
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
|
|
||||||
c64.SETTIM(0,0,0)
|
c64.SETTIM(0,0,0)
|
||||||
|
|
||||||
xx1=0
|
iterations = 0
|
||||||
xx2=0
|
repeat iterations {
|
||||||
xx3=0
|
repeat iterations {
|
||||||
|
xx1++
|
||||||
|
xx2++
|
||||||
|
xx3++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
iterations = 600
|
iterations = 600
|
||||||
repeat 600 {
|
repeat iterations {
|
||||||
repeat iterations {
|
repeat iterations {
|
||||||
xx1++
|
xx1++
|
||||||
xx2++
|
xx2++
|
||||||
|
Loading…
Reference in New Issue
Block a user