mirror of
https://github.com/irmen/prog8.git
synced 2025-01-12 19:29:50 +00:00
fix bug in codegen for containment check in bytearrays and strings
This commit is contained in:
parent
6be3b62d78
commit
c6cf330e70
@ -344,8 +344,10 @@ internal class AssignmentAsmGen(private val program: Program,
|
||||
require(elementDt.isBytes)
|
||||
val stringVal = variable.value as StringLiteral
|
||||
val varname = asmgen.asmVariableName(containment.iterable as IdentifierReference)
|
||||
assignAddressOf(AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, containment.definingSubroutine, "P8ZP_SCRATCH_W1"), varname)
|
||||
assignExpressionToRegister(containment.element, RegisterOrPair.A, elementDt istype DataType.BYTE)
|
||||
asmgen.saveRegisterLocal(CpuRegister.A, containment.definingSubroutine!!)
|
||||
assignAddressOf(AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, containment.definingSubroutine, "P8ZP_SCRATCH_W1"), varname)
|
||||
asmgen.restoreRegisterLocal(CpuRegister.A)
|
||||
asmgen.out(" ldy #${stringVal.value.length}")
|
||||
asmgen.out(" jsr prog8_lib.containment_bytearray")
|
||||
return
|
||||
@ -361,8 +363,10 @@ internal class AssignmentAsmGen(private val program: Program,
|
||||
val varname = asmgen.asmVariableName(containment.iterable as IdentifierReference)
|
||||
when(dt) {
|
||||
in ByteDatatypes -> {
|
||||
assignAddressOf(AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, containment.definingSubroutine, "P8ZP_SCRATCH_W1"), varname)
|
||||
assignExpressionToRegister(containment.element, RegisterOrPair.A, elementDt istype DataType.BYTE)
|
||||
asmgen.saveRegisterLocal(CpuRegister.A, containment.definingSubroutine!!)
|
||||
assignAddressOf(AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, containment.definingSubroutine, "P8ZP_SCRATCH_W1"), varname)
|
||||
asmgen.restoreRegisterLocal(CpuRegister.A)
|
||||
asmgen.out(" ldy #${arrayVal.value.size}")
|
||||
asmgen.out(" jsr prog8_lib.containment_bytearray")
|
||||
}
|
||||
@ -383,8 +387,10 @@ internal class AssignmentAsmGen(private val program: Program,
|
||||
when(variable.datatype) {
|
||||
DataType.STR -> {
|
||||
// use subroutine
|
||||
assignAddressOf(AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, containment.definingSubroutine, "P8ZP_SCRATCH_W1"), varname)
|
||||
assignExpressionToRegister(containment.element, RegisterOrPair.A, elementDt istype DataType.BYTE)
|
||||
asmgen.saveRegisterLocal(CpuRegister.A, containment.definingSubroutine!!)
|
||||
assignAddressOf(AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, containment.definingSubroutine, "P8ZP_SCRATCH_W1"), varname)
|
||||
asmgen.restoreRegisterLocal(CpuRegister.A)
|
||||
val stringVal = variable.value as StringLiteral
|
||||
asmgen.out(" ldy #${stringVal.value.length}")
|
||||
asmgen.out(" jsr prog8_lib.containment_bytearray")
|
||||
@ -393,8 +399,10 @@ internal class AssignmentAsmGen(private val program: Program,
|
||||
DataType.ARRAY_F -> throw AssemblyError("containment check of floats not supported")
|
||||
DataType.ARRAY_B, DataType.ARRAY_UB -> {
|
||||
val arrayVal = variable.value as ArrayLiteral
|
||||
assignAddressOf(AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, containment.definingSubroutine, "P8ZP_SCRATCH_W1"), varname)
|
||||
assignExpressionToRegister(containment.element, RegisterOrPair.A, elementDt istype DataType.BYTE)
|
||||
asmgen.saveRegisterLocal(CpuRegister.A, containment.definingSubroutine!!)
|
||||
assignAddressOf(AsmAssignTarget(TargetStorageKind.VARIABLE, program, asmgen, DataType.UWORD, containment.definingSubroutine, "P8ZP_SCRATCH_W1"), varname)
|
||||
asmgen.restoreRegisterLocal(CpuRegister.A)
|
||||
asmgen.out(" ldy #${arrayVal.value.size}")
|
||||
asmgen.out(" jsr prog8_lib.containment_bytearray")
|
||||
return
|
||||
|
@ -3,7 +3,6 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- fix assembler application included file loading problem (hello4.asm)
|
||||
- x16: add new keyboard APIs https://github.com/commanderx16/x16-docs/blob/master/Commander%20X16%20Programmer%27s%20Reference%20Guide.md#keyboard
|
||||
- x16: optimize diskio load_raw because headerless files are now supported https://github.com/commanderx16/x16-rom/pull/216
|
||||
note: must still work on c64/c128 that don't have this!
|
||||
|
@ -4,69 +4,30 @@
|
||||
; NOTE: meant to test to virtual machine output target (use -target vitual)
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
txt.clear_screen()
|
||||
|
||||
txt.setcc2(10,3,'*',$12)
|
||||
txt.setcc2(11,3,'*',$02)
|
||||
txt.setcc2(12,3,'*',$10)
|
||||
txt.setcc2(10,4,'*',$d5)
|
||||
txt.setcc2(11,4,'*',$05)
|
||||
txt.setcc2(12,4,'*',$d0)
|
||||
|
||||
sys.wait(100)
|
||||
cx16.screen_mode(0, false)
|
||||
sys.wait(100)
|
||||
|
||||
|
||||
; byte[] barr = [-1,-2,-3]
|
||||
; uword[] uwarr = [1111,2222,3333]
|
||||
;
|
||||
; txt.print_b(barr[2])
|
||||
; txt.spc()
|
||||
; txt.print_uw(uwarr[2])
|
||||
; txt.nl()
|
||||
;
|
||||
; barr[2] --
|
||||
; uwarr[2] --
|
||||
;
|
||||
; txt.print_b(barr[2])
|
||||
; txt.spc()
|
||||
; txt.print_uw(uwarr[2])
|
||||
; txt.nl()
|
||||
;
|
||||
; barr[2] ++
|
||||
; uwarr[2] ++
|
||||
;
|
||||
; txt.print_b(barr[2])
|
||||
; txt.spc()
|
||||
; txt.print_uw(uwarr[2])
|
||||
; txt.nl()
|
||||
;
|
||||
; sys.exit(99)
|
||||
|
||||
|
||||
; the "pixelshader":
|
||||
; syscall1(8, 0) ; enable lo res creen
|
||||
; ubyte shifter
|
||||
;
|
||||
; shifter >>= 1
|
||||
;
|
||||
; repeat {
|
||||
; uword xx
|
||||
; uword yy = 0
|
||||
; repeat 240 {
|
||||
; xx = 0
|
||||
; repeat 320 {
|
||||
; syscall3(10, xx, yy, xx*yy + shifter) ; plot pixel
|
||||
; xx++
|
||||
; }
|
||||
; yy++
|
||||
; }
|
||||
; shifter+=4
|
||||
;
|
||||
; txt.print_ub(shifter)
|
||||
; txt.nl()
|
||||
; }
|
||||
syscall1(8, 0) ; enable lo res creen
|
||||
ubyte shifter
|
||||
|
||||
shifter >>= 1
|
||||
|
||||
repeat {
|
||||
uword xx
|
||||
uword yy = 0
|
||||
repeat 240 {
|
||||
xx = 0
|
||||
repeat 320 {
|
||||
syscall3(10, xx, yy, xx*yy + shifter) ; plot pixel
|
||||
xx++
|
||||
}
|
||||
yy++
|
||||
}
|
||||
shifter+=4
|
||||
|
||||
txt.print_ub(shifter)
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user