mirror of
https://github.com/irmen/prog8.git
synced 2024-12-22 18:30:01 +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 {
|
||||
// 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
|
||||
asmgen.out("""
|
||||
lda #<${sourceAsm}
|
||||
|
@ -1,10 +1,7 @@
|
||||
package prog8.codegen.intermediate
|
||||
|
||||
import prog8.code.ast.*
|
||||
import prog8.code.core.AssemblyError
|
||||
import prog8.code.core.DataType
|
||||
import prog8.code.core.SignedDatatypes
|
||||
import prog8.code.core.SplitWordArrayTypes
|
||||
import prog8.code.core.*
|
||||
import prog8.intermediate.*
|
||||
|
||||
|
||||
@ -102,7 +99,7 @@ internal class BuiltinFuncGen(private val codeGen: IRCodeGen, private val exprGe
|
||||
}
|
||||
else {
|
||||
// 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 {
|
||||
it += IRInstruction(Opcode.LOAD, IRDataType.WORD, reg1=fromReg, labelSymbol = source.name)
|
||||
it += IRInstruction(Opcode.LOAD, IRDataType.WORD, reg1=toReg, labelSymbol = target.name)
|
||||
|
@ -5,36 +5,17 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
uword[7] rolls
|
||||
ubyte[5] cave_times
|
||||
ubyte[5] diamonds_needed
|
||||
|
||||
txt.print("wait...\n")
|
||||
repeat 30 {
|
||||
repeat 1000 {
|
||||
unroll 10 rolls[math.rnd() % len(rolls)]++
|
||||
}
|
||||
}
|
||||
cave_times = [1,2,3,4,5]
|
||||
diamonds_needed = [1,2,3,4,5]
|
||||
|
||||
for cx16.r0L in 0 to len(rolls)-1 {
|
||||
txt.print_ub(cx16.r0L)
|
||||
for cx16.r0L in 0 to len(cave_times)-1 {
|
||||
txt.print_ub(cave_times[cx16.r0L])
|
||||
txt.spc()
|
||||
txt.print_uw(rolls[cx16.r0L])
|
||||
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()
|
||||
}
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user