mirror of
https://github.com/irmen/prog8.git
synced 2024-10-25 00:24:16 +00:00
fix element size calc when copying array
This commit is contained in:
parent
8b8caa1c2e
commit
8201408f16
@ -153,7 +153,7 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// normal array to array copy, various element types
|
// normal array to array copy, various element types
|
||||||
val eltsize = asmgen.options.compTarget.memorySize(source.type)
|
val eltsize = asmgen.options.compTarget.memorySize(ArrayToElementTypes.getValue(source.type))
|
||||||
val numBytes = numElements * eltsize
|
val numBytes = numElements * eltsize
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
lda #<${sourceAsm}
|
lda #<${sourceAsm}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package prog8.codegen.intermediate
|
package prog8.codegen.intermediate
|
||||||
|
|
||||||
import prog8.code.ast.*
|
import prog8.code.ast.*
|
||||||
import prog8.code.core.AssemblyError
|
import prog8.code.core.*
|
||||||
import prog8.code.core.DataType
|
|
||||||
import prog8.code.core.SignedDatatypes
|
|
||||||
import prog8.code.core.SplitWordArrayTypes
|
|
||||||
import prog8.intermediate.*
|
import prog8.intermediate.*
|
||||||
|
|
||||||
|
|
||||||
@ -102,7 +99,7 @@ internal class BuiltinFuncGen(private val codeGen: IRCodeGen, private val exprGe
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// normal array to array copy (various element types)
|
// normal array to array copy (various element types)
|
||||||
val eltsize = codeGen.options.compTarget.memorySize(source.type)
|
val eltsize = codeGen.options.compTarget.memorySize(ArrayToElementTypes.getValue(source.type))
|
||||||
result += IRCodeChunk(null, null).also {
|
result += IRCodeChunk(null, null).also {
|
||||||
it += IRInstruction(Opcode.LOAD, IRDataType.WORD, reg1=fromReg, labelSymbol = source.name)
|
it += IRInstruction(Opcode.LOAD, IRDataType.WORD, reg1=fromReg, labelSymbol = source.name)
|
||||||
it += IRInstruction(Opcode.LOAD, IRDataType.WORD, reg1=toReg, labelSymbol = target.name)
|
it += IRInstruction(Opcode.LOAD, IRDataType.WORD, reg1=toReg, labelSymbol = target.name)
|
||||||
|
@ -5,37 +5,18 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
uword[7] rolls
|
ubyte[5] cave_times
|
||||||
|
ubyte[5] diamonds_needed
|
||||||
|
|
||||||
txt.print("wait...\n")
|
cave_times = [1,2,3,4,5]
|
||||||
repeat 30 {
|
diamonds_needed = [1,2,3,4,5]
|
||||||
repeat 1000 {
|
|
||||||
unroll 10 rolls[math.rnd() % len(rolls)]++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for cx16.r0L in 0 to len(rolls)-1 {
|
for cx16.r0L in 0 to len(cave_times)-1 {
|
||||||
txt.print_ub(cx16.r0L)
|
txt.print_ub(cave_times[cx16.r0L])
|
||||||
txt.spc()
|
txt.spc()
|
||||||
txt.print_uw(rolls[cx16.r0L])
|
}
|
||||||
txt.nl()
|
txt.nl()
|
||||||
}
|
}
|
||||||
|
|
||||||
txt.print("wait...\n")
|
|
||||||
rolls = [0,0,0,0,0,0,0]
|
|
||||||
repeat 30 {
|
|
||||||
repeat 1000 {
|
|
||||||
unroll 10 rolls[math.randrange(len(rolls))]++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for cx16.r0L in 0 to len(rolls)-1 {
|
|
||||||
txt.print_ub(cx16.r0L)
|
|
||||||
txt.spc()
|
|
||||||
txt.print_uw(rolls[cx16.r0L])
|
|
||||||
txt.nl()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user