mirror of
https://github.com/irmen/prog8.git
synced 2026-04-20 11:17:01 +00:00
implement more long assignments through pointers
This commit is contained in:
@@ -882,7 +882,7 @@ class AsmGen6502Internal (
|
||||
TargetStorageKind.ARRAY -> TODO("assign long to array ${target.position}")
|
||||
TargetStorageKind.MEMORY -> throw AssemblyError("memory is bytes not long ${target.position}")
|
||||
TargetStorageKind.REGISTER -> assignExpressionToRegister(value, target.register!!, true)
|
||||
TargetStorageKind.POINTER -> throw AssemblyError("assign long into pointer ${target.position}")
|
||||
TargetStorageKind.POINTER -> TODO("assign long into pointer ${target.position}")
|
||||
TargetStorageKind.VOID -> { /* do nothing */ }
|
||||
}
|
||||
} else if(value is PtIdentifier && value.type.isLong) {
|
||||
@@ -905,7 +905,7 @@ class AsmGen6502Internal (
|
||||
TargetStorageKind.ARRAY -> TODO("assign long to array ${target.position}")
|
||||
TargetStorageKind.MEMORY -> throw AssemblyError("memory is bytes not long ${target.position}")
|
||||
TargetStorageKind.REGISTER -> assignExpressionToRegister(value, target.register!!, true)
|
||||
TargetStorageKind.POINTER -> throw AssemblyError("assign long expression to pointer ${target.position}")
|
||||
TargetStorageKind.POINTER -> TODO("assign long expression to pointer ${target.position}")
|
||||
TargetStorageKind.VOID -> { /* do nothing */ }
|
||||
}
|
||||
} else if(value is PtTypeCast && value.type.isLong) {
|
||||
@@ -920,7 +920,7 @@ class AsmGen6502Internal (
|
||||
TargetStorageKind.ARRAY -> TODO("assign typecasted long to array ${target.position}")
|
||||
TargetStorageKind.MEMORY -> throw AssemblyError("memory is bytes not long ${target.position}")
|
||||
TargetStorageKind.REGISTER -> assignExpressionToRegister(value, target.register!!, true)
|
||||
TargetStorageKind.POINTER -> throw AssemblyError("assign long into pointer ${target.position}")
|
||||
TargetStorageKind.POINTER -> TODO("assign long into pointer ${target.position}")
|
||||
TargetStorageKind.VOID -> { /* do nothing */ }
|
||||
}
|
||||
} else if(value.value.type.isWord) {
|
||||
|
||||
@@ -3525,7 +3525,7 @@ $endLabel""")
|
||||
else -> throw AssemblyError("wrong dt ${target.position}")
|
||||
}
|
||||
}
|
||||
TargetStorageKind.POINTER -> TODO("assign long to pointer ${target.position}")
|
||||
TargetStorageKind.POINTER -> pointergen.assignLongVar(target.pointer!!, varName)
|
||||
TargetStorageKind.VOID -> { /* do nothing */ }
|
||||
}
|
||||
}
|
||||
@@ -4545,7 +4545,7 @@ $endLabel""")
|
||||
stz $startreg+2
|
||||
stz $startreg+3""")
|
||||
}
|
||||
TargetStorageKind.POINTER -> TODO("assign long 0 to pointer ${target.position}")
|
||||
TargetStorageKind.POINTER -> pointergen.assignLong(target.pointer!!, 0)
|
||||
TargetStorageKind.VOID -> { /* do nothing */ }
|
||||
}
|
||||
return
|
||||
|
||||
@@ -462,7 +462,24 @@ internal class PointerAssignmentsGen(private val asmgen: AsmGen6502Internal, pri
|
||||
TODO("array ptr assign long var ${target.position}")
|
||||
}
|
||||
|
||||
fun assignLong(pointer: PtPointerDeref, long: Int) {
|
||||
internal fun assignLongVar(pointer: PtPointerDeref, varName: String) {
|
||||
val (ptrVar, offset) = deref(pointer)
|
||||
asmgen.out("""
|
||||
ldy #$offset
|
||||
lda $varName
|
||||
sta ($ptrVar),y
|
||||
iny
|
||||
lda $varName+1
|
||||
sta ($ptrVar),y
|
||||
iny
|
||||
lda $varName+2
|
||||
sta ($ptrVar),y
|
||||
iny
|
||||
lda $varName+3
|
||||
sta ($ptrVar),y""")
|
||||
}
|
||||
|
||||
internal fun assignLong(pointer: PtPointerDeref, long: Int) {
|
||||
val (ptrVar, offset) = deref(pointer)
|
||||
val hex = long.toLongHex()
|
||||
asmgen.out("""
|
||||
|
||||
+11
-3
@@ -13,7 +13,7 @@ main {
|
||||
long @shared l2 = -1
|
||||
long @shared l3 = $ffffffff
|
||||
long @shared l4 = $7fffffff
|
||||
^^long lptr = 50000
|
||||
^^long lptr = 20000
|
||||
|
||||
l1 ^= -1
|
||||
l2 ^= $ffffffff
|
||||
@@ -22,9 +22,17 @@ main {
|
||||
|
||||
lptr^^ = 82348234
|
||||
l2 = lptr^^
|
||||
l2 = 12345678
|
||||
|
||||
txt.print_l(lptr^^)
|
||||
txt.spc()
|
||||
lptr^^ = 0 ; crash was fixed
|
||||
txt.print_l(lptr^^)
|
||||
txt.spc()
|
||||
lptr^^ = l2 ; crash was fixed
|
||||
txt.print_l(lptr^^)
|
||||
txt.spc()
|
||||
|
||||
lptr^^ = 0 ; TODO fix crash
|
||||
lptr^^ = l2 ; TODO fix crash
|
||||
lptr^^ = 82348234+l2 ; TODO fix crash
|
||||
l3 = lptr^^+1 ; TODO fix crash
|
||||
|
||||
|
||||
Reference in New Issue
Block a user