mirror of
https://github.com/irmen/prog8.git
synced 2024-11-29 17:50:35 +00:00
assignments again
This commit is contained in:
parent
729d931ccb
commit
8446dd567b
@ -59,104 +59,122 @@ byte_assignment_to_register:
|
|||||||
A = X
|
A = X
|
||||||
A = ub
|
A = ub
|
||||||
A = mubyte
|
A = mubyte
|
||||||
A = ubarr1[2]
|
|
||||||
A = ubmatrix1[1,2]
|
|
||||||
A = string[4]
|
|
||||||
A = AY[4]
|
A = AY[4]
|
||||||
|
A = ubarr1[2]
|
||||||
|
A = string[4]
|
||||||
|
A = string[X]
|
||||||
|
A = string[b]
|
||||||
|
A = string[ub]
|
||||||
|
A = ubarr1[X]
|
||||||
|
A = ubarr1[b]
|
||||||
|
A = ubarr1[ub]
|
||||||
|
A = AY[Y]
|
||||||
|
A = AY[b]
|
||||||
|
A = AY[ub]
|
||||||
|
A = ubmatrix1[1,2]
|
||||||
|
;A = ubmatrix1[1,Y] ; todo via evaluation
|
||||||
|
A = ubmatrix1[X,2] ; todo via evaluation TODO fix error constant y dimension of index should have been const-folded with x into one value
|
||||||
|
;A = ubmatrix1[X,Y] ; todo via evaluation
|
||||||
|
;A = ubmatrix1[1,b2] ; todo via evaluation
|
||||||
|
;A = ubmatrix1[X,b2] ; todo via evaluation
|
||||||
|
A = ubmatrix1[b2,2] ; todo FIX ERROR constant y dimension of index should have been const-folded with x into one value
|
||||||
|
;A = ubmatrix1[b2,X] ; todo via evaluation
|
||||||
|
;A = ubmatrix1[b,b2] ; todo via evaluation
|
||||||
|
;A = ubmatrix1[ub,ub2] ; todo via evaluation
|
||||||
|
|
||||||
byte_assignment_to_bytevar:
|
;byte_assignment_to_bytevar:
|
||||||
b = 42
|
; b = 42
|
||||||
b = b2
|
; b = b2
|
||||||
b = mbyte
|
; b = mbyte
|
||||||
b = barr1[2]
|
; b = barr1[2]
|
||||||
b = bmatrix1[1,2]
|
; b = bmatrix1[1,2]
|
||||||
|
;
|
||||||
ub = 42
|
; ub = 42
|
||||||
ub = X
|
; ub = X
|
||||||
ub = ub2
|
; ub = ub2
|
||||||
ub = mubyte
|
; ub = mubyte
|
||||||
ub = ubarr1[2]
|
; ub = ubarr1[2]
|
||||||
ub = ubmatrix1[1,2]
|
; ub = ubmatrix1[1,2]
|
||||||
ub = string[4]
|
; ub = string[4]
|
||||||
ub = AY[4]
|
; ub = AY[4]
|
||||||
|
;
|
||||||
|
;
|
||||||
; all possible assignments to a WORD VARIABLE (not array)
|
;; all possible assignments to a WORD VARIABLE (not array)
|
||||||
|
;
|
||||||
word_assignment_to_registerpair:
|
;word_assignment_to_registerpair:
|
||||||
AY = 42
|
; AY = 42
|
||||||
AY = 42.w
|
; AY = 42.w
|
||||||
AY = 42555
|
; AY = 42555
|
||||||
AY = X
|
; AY = X
|
||||||
AY = XY
|
; AY = XY
|
||||||
AY = ub
|
; AY = ub
|
||||||
AY = mubyte
|
; AY = mubyte
|
||||||
AY = ubarr1[2]
|
; AY = ubarr1[2]
|
||||||
AY = ubmatrix1[1,2]
|
; AY = ubmatrix1[1,2]
|
||||||
AY = string[4]
|
; AY = string[4]
|
||||||
AY = uw
|
; AY = uw
|
||||||
AY = muword
|
; AY = muword
|
||||||
AY = uwarr1[2]
|
; AY = uwarr1[2]
|
||||||
AY = string[4]
|
; AY = string[4]
|
||||||
AY = XY[4]
|
; AY = XY[4]
|
||||||
|
;
|
||||||
;word_assignment_to_wordvar:
|
;;word_assignment_to_wordvar:
|
||||||
w = -42
|
; w = -42
|
||||||
w = -42.w
|
; w = -42.w
|
||||||
w = -12345
|
; w = -12345
|
||||||
w = X
|
; w = X
|
||||||
w = b2
|
; w = b2
|
||||||
w = ub2
|
; w = ub2
|
||||||
w = w2
|
; w = w2
|
||||||
w = mbyte
|
; w = mbyte
|
||||||
w = mubyte
|
; w = mubyte
|
||||||
w = mword
|
; w = mword
|
||||||
w = barr1[2]
|
; w = barr1[2]
|
||||||
w = ubarr1[2]
|
; w = ubarr1[2]
|
||||||
w = warr1[2]
|
; w = warr1[2]
|
||||||
w = bmatrix1[1,2]
|
; w = bmatrix1[1,2]
|
||||||
w = ubmatrix1[1,2]
|
; w = ubmatrix1[1,2]
|
||||||
w = string[4]
|
; w = string[4]
|
||||||
w = AY[4]
|
; w = AY[4]
|
||||||
|
;
|
||||||
uw = 42
|
; uw = 42
|
||||||
uw = 42.w
|
; uw = 42.w
|
||||||
uw = 42555
|
; uw = 42555
|
||||||
uw = X
|
; uw = X
|
||||||
uw = AY
|
; uw = AY
|
||||||
uw = ub2
|
; uw = ub2
|
||||||
uw = uw2
|
; uw = uw2
|
||||||
uw = mubyte
|
; uw = mubyte
|
||||||
uw = muword
|
; uw = muword
|
||||||
uw = ubarr1[2]
|
; uw = ubarr1[2]
|
||||||
uw = uwarr1[2]
|
; uw = uwarr1[2]
|
||||||
uw = ubmatrix1[1,2]
|
; uw = ubmatrix1[1,2]
|
||||||
uw = string[4]
|
; uw = string[4]
|
||||||
uw = AY[4]
|
; uw = AY[4]
|
||||||
|
;
|
||||||
|
;
|
||||||
; all possible assignments to a FLOAT VARIABLE
|
;; all possible assignments to a FLOAT VARIABLE
|
||||||
float_assignment_to_floatvar:
|
;float_assignment_to_floatvar:
|
||||||
fl1 = 34
|
; fl1 = 34
|
||||||
fl1 = 34555.w
|
; fl1 = 34555.w
|
||||||
fl1 = 3.33e22
|
; fl1 = 3.33e22
|
||||||
fl1 = X
|
; fl1 = X
|
||||||
fl1 = AY
|
; fl1 = AY
|
||||||
fl1 = b2
|
; fl1 = b2
|
||||||
fl1 = ub2
|
; fl1 = ub2
|
||||||
fl1 = w2
|
; fl1 = w2
|
||||||
fl1 = uw2
|
; fl1 = uw2
|
||||||
fl1 = mbyte
|
; fl1 = mbyte
|
||||||
fl1 = mubyte
|
; fl1 = mubyte
|
||||||
fl1 = mword
|
; fl1 = mword
|
||||||
fl1 = muword
|
; fl1 = muword
|
||||||
fl1 = barr1[2]
|
; fl1 = barr1[2]
|
||||||
fl1 = ubarr1[2]
|
; fl1 = ubarr1[2]
|
||||||
fl1 = warr1[2]
|
; fl1 = warr1[2]
|
||||||
fl1 = uwarr1[2]
|
; fl1 = uwarr1[2]
|
||||||
fl1 = bmatrix1[1,2]
|
; fl1 = bmatrix1[1,2]
|
||||||
fl1 = ubmatrix1[1,2]
|
; fl1 = ubmatrix1[1,2]
|
||||||
fl1 = string[4]
|
; fl1 = string[4]
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -729,7 +729,7 @@ class AstChecker(private val namespace: INameScope,
|
|||||||
if(arraysize!=null) {
|
if(arraysize!=null) {
|
||||||
// check out of bounds
|
// check out of bounds
|
||||||
if((arrayIndexedExpression.arrayspec.y as? LiteralValue)?.asIntegerValue != null) {
|
if((arrayIndexedExpression.arrayspec.y as? LiteralValue)?.asIntegerValue != null) {
|
||||||
throw FatalAstException("constant y dimension of index should have been const-folded with x into one value")
|
throw FatalAstException("constant y dimension of index should have been const-folded with x into one value ${arrayIndexedExpression.arrayspec.position}")
|
||||||
}
|
}
|
||||||
val index = (arrayIndexedExpression.arrayspec.x as? LiteralValue)?.asIntegerValue
|
val index = (arrayIndexedExpression.arrayspec.x as? LiteralValue)?.asIntegerValue
|
||||||
if(index!=null && (index<0 || index>=arraysize))
|
if(index!=null && (index<0 || index>=arraysize))
|
||||||
|
@ -704,8 +704,13 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(pattern in patterns.filter { it.sequence.size <= segment.size}) {
|
for(pattern in patterns.filter { it.sequence.size <= segment.size || (it.altSequence != null && it.altSequence.size <= segment.size)}) {
|
||||||
if(pattern.sequence == opcodes.subList(0, pattern.sequence.size)) {
|
val opcodesList = opcodes.subList(0, pattern.sequence.size)
|
||||||
|
if(pattern.sequence == opcodesList) {
|
||||||
|
val asm = pattern.asm(segment)
|
||||||
|
if(asm!=null)
|
||||||
|
result.add(AsmFragment(asm, pattern.sequence.size))
|
||||||
|
} else if(pattern.altSequence == opcodesList) {
|
||||||
val asm = pattern.asm(segment)
|
val asm = pattern.asm(segment)
|
||||||
if(asm!=null)
|
if(asm!=null)
|
||||||
result.add(AsmFragment(asm, pattern.sequence.size))
|
result.add(AsmFragment(asm, pattern.sequence.size))
|
||||||
@ -905,7 +910,7 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
|
|
||||||
class AsmFragment(val asm: String, var segmentSize: Int=0)
|
class AsmFragment(val asm: String, var segmentSize: Int=0)
|
||||||
|
|
||||||
class AsmPattern(val sequence: List<Opcode>, val asm: (List<Instruction>)->String?)
|
class AsmPattern(val sequence: List<Opcode>, val altSequence: List<Opcode>?=null, val asm: (List<Instruction>)->String?)
|
||||||
|
|
||||||
private val patterns = listOf(
|
private val patterns = listOf(
|
||||||
|
|
||||||
@ -953,13 +958,9 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// var = mem (u)byte
|
// var = mem (u)byte
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_B, Opcode.POP_VAR_BYTE)) { segment ->
|
AsmPattern(
|
||||||
when(segment[1].callLabel) {
|
listOf(Opcode.PUSH_MEM_B, Opcode.POP_VAR_BYTE),
|
||||||
"A", "X", "Y" -> " ld${segment[1].callLabel!!.toLowerCase()} ${segment[0].arg!!.integerValue().toHex()}"
|
listOf(Opcode.PUSH_MEM_UB, Opcode.POP_VAR_BYTE)) { segment ->
|
||||||
else -> " lda ${segment[0].arg!!.integerValue().toHex()} | sta ${segment[1].callLabel}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_UB, Opcode.POP_VAR_BYTE)) { segment ->
|
|
||||||
when(segment[1].callLabel) {
|
when(segment[1].callLabel) {
|
||||||
"A", "X", "Y" -> " ld${segment[1].callLabel!!.toLowerCase()} ${segment[0].arg!!.integerValue().toHex()}"
|
"A", "X", "Y" -> " ld${segment[1].callLabel!!.toLowerCase()} ${segment[0].arg!!.integerValue().toHex()}"
|
||||||
else -> " lda ${segment[0].arg!!.integerValue().toHex()} | sta ${segment[1].callLabel}"
|
else -> " lda ${segment[0].arg!!.integerValue().toHex()} | sta ${segment[1].callLabel}"
|
||||||
@ -998,7 +999,68 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
},
|
},
|
||||||
// var = bytearray[indexvar]
|
// var = bytearray[indexvar]
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.READ_INDEXED_VAR_BYTE, Opcode.POP_VAR_BYTE)) { segment ->
|
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.READ_INDEXED_VAR_BYTE, Opcode.POP_VAR_BYTE)) { segment ->
|
||||||
TODO("$segment")
|
// TODO reuse: load byte in A
|
||||||
|
val setupPtr: String
|
||||||
|
val loadByte: String
|
||||||
|
when(segment[1].callLabel) {
|
||||||
|
"AX" -> {
|
||||||
|
setupPtr = "sta ${C64Zeropage.SCRATCH_W1} | stx ${C64Zeropage.SCRATCH_W1 + 1} "
|
||||||
|
loadByte = when (segment[0].callLabel) {
|
||||||
|
"A" -> "tay | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
"X" -> "txa | tay | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
"Y" -> "lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
else -> "ldy ${segment[0].callLabel} | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"AY" -> {
|
||||||
|
setupPtr = " sta ${C64Zeropage.SCRATCH_W1} | sty ${C64Zeropage.SCRATCH_W1 + 1} "
|
||||||
|
loadByte = when (segment[0].callLabel) {
|
||||||
|
"A" -> "tay | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
"X" -> "txa | tay | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
"Y" -> "lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
else -> "ldy ${segment[0].callLabel} | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"XY" -> {
|
||||||
|
setupPtr = " stx ${C64Zeropage.SCRATCH_W1} | sty ${C64Zeropage.SCRATCH_W1 + 1} "
|
||||||
|
loadByte = when (segment[0].callLabel) {
|
||||||
|
"A" -> "tay | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
"X" -> "txa | tay | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
"Y" -> "lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
else -> "ldy ${segment[0].callLabel} | lda (${C64Zeropage.SCRATCH_W1}),y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
when (segment[0].callLabel) {
|
||||||
|
"A" -> {
|
||||||
|
setupPtr = ""
|
||||||
|
loadByte = "tay | lda ${segment[1].callLabel},y"
|
||||||
|
}
|
||||||
|
"X" -> {
|
||||||
|
setupPtr = ""
|
||||||
|
loadByte = "txa | tay | lda ${segment[1].callLabel},y"
|
||||||
|
}
|
||||||
|
"Y" -> {
|
||||||
|
setupPtr = ""
|
||||||
|
loadByte = "lda ${segment[1].callLabel},y"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
setupPtr = ""
|
||||||
|
loadByte = "ldy ${segment[0].callLabel} | lda ${segment[1].callLabel},y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// store A in target
|
||||||
|
val storeByte = when(segment[2].callLabel) {
|
||||||
|
"A" -> ""
|
||||||
|
"X" -> " tax"
|
||||||
|
"Y" -> " tya"
|
||||||
|
else -> " sta ${segment[2].callLabel}"
|
||||||
|
}
|
||||||
|
|
||||||
|
" $setupPtr | $loadByte | $storeByte"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -1089,21 +1151,9 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// var = mem (u)word
|
// var = mem (u)word
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_W, Opcode.POP_VAR_WORD)) { segment ->
|
AsmPattern(
|
||||||
when(segment[1].callLabel) {
|
listOf(Opcode.PUSH_MEM_W, Opcode.POP_VAR_WORD),
|
||||||
"AX" -> " lda ${segment[0].arg!!.integerValue().toHex()} | ldx ${(segment[0].arg!!.integerValue()+1).toHex()}"
|
listOf(Opcode.PUSH_MEM_UW, Opcode.POP_VAR_WORD)) { segment ->
|
||||||
"AY" -> " lda ${segment[0].arg!!.integerValue().toHex()} | ldy ${(segment[0].arg!!.integerValue()+1).toHex()}"
|
|
||||||
"XY" -> " ldx ${segment[0].arg!!.integerValue().toHex()} | ldy ${(segment[0].arg!!.integerValue()+1).toHex()}"
|
|
||||||
else ->
|
|
||||||
"""
|
|
||||||
lda ${segment[0].arg!!.integerValue().toHex()}
|
|
||||||
sta ${segment[1].callLabel}
|
|
||||||
lda ${(segment[0].arg!!.integerValue()+1).toHex()}
|
|
||||||
sta ${segment[1].callLabel}+1
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_UW, Opcode.POP_VAR_WORD)) { segment ->
|
|
||||||
when(segment[1].callLabel) {
|
when(segment[1].callLabel) {
|
||||||
"AX" -> " lda ${segment[0].arg!!.integerValue().toHex()} | ldx ${(segment[0].arg!!.integerValue()+1).toHex()}"
|
"AX" -> " lda ${segment[0].arg!!.integerValue().toHex()} | ldx ${(segment[0].arg!!.integerValue()+1).toHex()}"
|
||||||
"AY" -> " lda ${segment[0].arg!!.integerValue().toHex()} | ldy ${(segment[0].arg!!.integerValue()+1).toHex()}"
|
"AY" -> " lda ${segment[0].arg!!.integerValue().toHex()} | ldy ${(segment[0].arg!!.integerValue()+1).toHex()}"
|
||||||
@ -1209,14 +1259,9 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
else -> " lda ${segment[1].callLabel}+$index | sta ${segment[2].callLabel} | lda ${segment[1].callLabel}+${index+1} | sta ${segment[2].callLabel}+1"
|
else -> " lda ${segment[1].callLabel}+$index | sta ${segment[2].callLabel} | lda ${segment[1].callLabel}+${index+1} | sta ${segment[2].callLabel}+1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// var = bytearray[indexvar] (sign extended)
|
// var = bytearray[indexvar] (sign extended) VIA REGULAR STACK EVALUATION: Opcode.PUSH_VAR_BYTE, Opcode.READ_INDEXED_VAR_BYTE, Opcode.UB2UWORD, Opcode.POP_VAR_WORD
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.READ_INDEXED_VAR_BYTE, Opcode.UB2UWORD, Opcode.POP_VAR_WORD)) { segment ->
|
// TODO: UB2UWORD + POP_VAR_WORD special pattern?
|
||||||
TODO("$segment")
|
// var = (u)wordarray[indexvar] VIA REGULAR STACK EVALUATION: Opcode.PUSH_VAR_BYTE, Opcode.READ_INDEXED_VAR_WORD, Opcode.POP_VAR_WORD
|
||||||
},
|
|
||||||
// var = (u)wordarray[indexvar]
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.READ_INDEXED_VAR_WORD, Opcode.POP_VAR_WORD)) { segment ->
|
|
||||||
TODO("$segment")
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
// ----------- assignment to MEMORY WORD ----------------
|
// ----------- assignment to MEMORY WORD ----------------
|
||||||
@ -1458,17 +1503,8 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
AsmPattern(listOf(Opcode.PUSH_BYTE, Opcode.READ_INDEXED_VAR_FLOAT, Opcode.POP_VAR_FLOAT)) { segment ->
|
AsmPattern(listOf(Opcode.PUSH_BYTE, Opcode.READ_INDEXED_VAR_FLOAT, Opcode.POP_VAR_FLOAT)) { segment ->
|
||||||
TODO("$segment")
|
TODO("$segment")
|
||||||
},
|
},
|
||||||
// floatvar = floatarray[indexvar]
|
// floatvar = floatarray[indexvar] VIA REGULAR STACK EVALUATION FOR NOW: Opcode.PUSH_VAR_BYTE, Opcode.READ_INDEXED_VAR_FLOAT, Opcode.POP_VAR_FLOAT) TODO Optimize this in special pattern?
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.READ_INDEXED_VAR_FLOAT, Opcode.POP_VAR_FLOAT)) { segment ->
|
// floatvar = floatarray[mem index (u)byte] VIA REGULAR STACK EVALUATION FOR NOW: Opcode.PUSH_MEM_[U]B, Opcode.READ_INDEXED_VAR_FLOAT, Opcode.POP_VAR_FLOAT TODO Optimize this in special pattern?
|
||||||
TODO("$segment")
|
|
||||||
},
|
|
||||||
// floatvar = floatarray[mem index (u)byte]
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_B, Opcode.READ_INDEXED_VAR_FLOAT, Opcode.POP_VAR_FLOAT)) { segment ->
|
|
||||||
TODO("$segment")
|
|
||||||
},
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_UB, Opcode.READ_INDEXED_VAR_FLOAT, Opcode.POP_VAR_FLOAT)) { segment ->
|
|
||||||
TODO("$segment")
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1548,10 +1584,9 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
},
|
},
|
||||||
|
|
||||||
// assignment: bytearray[memory (u)byte] = byte
|
// assignment: bytearray[memory (u)byte] = byte
|
||||||
AsmPattern(listOf(Opcode.PUSH_BYTE, Opcode.PUSH_MEM_B, Opcode.WRITE_INDEXED_VAR_BYTE)) { segment ->
|
AsmPattern(
|
||||||
TODO("$segment")
|
listOf(Opcode.PUSH_BYTE, Opcode.PUSH_MEM_B, Opcode.WRITE_INDEXED_VAR_BYTE),
|
||||||
},
|
listOf(Opcode.PUSH_BYTE, Opcode.PUSH_MEM_UB, Opcode.WRITE_INDEXED_VAR_BYTE)) { segment ->
|
||||||
AsmPattern(listOf(Opcode.PUSH_BYTE, Opcode.PUSH_MEM_UB, Opcode.WRITE_INDEXED_VAR_BYTE)) { segment ->
|
|
||||||
TODO("$segment")
|
TODO("$segment")
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1565,16 +1600,16 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
},
|
},
|
||||||
|
|
||||||
// assignment: bytearray[mem (u)byte] = bytevar
|
// assignment: bytearray[mem (u)byte] = bytevar
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.PUSH_MEM_B, Opcode.WRITE_INDEXED_VAR_BYTE)) { segment ->
|
AsmPattern(
|
||||||
TODO("$segment")
|
listOf(Opcode.PUSH_VAR_BYTE, Opcode.PUSH_MEM_B, Opcode.WRITE_INDEXED_VAR_BYTE),
|
||||||
},
|
listOf(Opcode.PUSH_VAR_BYTE, Opcode.PUSH_MEM_UB, Opcode.WRITE_INDEXED_VAR_BYTE)) { segment ->
|
||||||
AsmPattern(listOf(Opcode.PUSH_VAR_BYTE, Opcode.PUSH_MEM_UB, Opcode.WRITE_INDEXED_VAR_BYTE)) { segment ->
|
|
||||||
TODO("$segment")
|
TODO("$segment")
|
||||||
},
|
},
|
||||||
|
|
||||||
// assignment: bytearray[idxbyte] = membyte
|
// assignment: bytearray[idxbyte] = membyte
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_B, Opcode.PUSH_BYTE, Opcode.WRITE_INDEXED_VAR_BYTE)) { segment ->
|
AsmPattern(listOf(Opcode.PUSH_MEM_B, Opcode.PUSH_BYTE, Opcode.WRITE_INDEXED_VAR_BYTE)) { segment ->
|
||||||
val index = segment[1].arg!!.integerValue()
|
val index = segment[1].arg!!.integerValue()
|
||||||
|
TODO("registerpair array") // same as below???
|
||||||
" lda ${segment[0].arg!!.integerValue().toHex()} | sta ${segment[2].callLabel}+$index "
|
" lda ${segment[0].arg!!.integerValue().toHex()} | sta ${segment[2].callLabel}+$index "
|
||||||
},
|
},
|
||||||
// assignment: bytearray[idxbyte] = memubyte
|
// assignment: bytearray[idxbyte] = memubyte
|
||||||
@ -1599,10 +1634,9 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
},
|
},
|
||||||
|
|
||||||
// assignment: wordarray[memory (u)byte] = word
|
// assignment: wordarray[memory (u)byte] = word
|
||||||
AsmPattern(listOf(Opcode.PUSH_WORD, Opcode.PUSH_MEM_B, Opcode.WRITE_INDEXED_VAR_WORD)) { segment ->
|
AsmPattern(
|
||||||
TODO("$segment")
|
listOf(Opcode.PUSH_WORD, Opcode.PUSH_MEM_B, Opcode.WRITE_INDEXED_VAR_WORD),
|
||||||
},
|
listOf(Opcode.PUSH_WORD, Opcode.PUSH_MEM_UB, Opcode.WRITE_INDEXED_VAR_WORD)) { segment ->
|
||||||
AsmPattern(listOf(Opcode.PUSH_WORD, Opcode.PUSH_MEM_UB, Opcode.WRITE_INDEXED_VAR_WORD)) { segment ->
|
|
||||||
TODO("$segment")
|
TODO("$segment")
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1630,18 +1664,10 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
AsmPattern(listOf(Opcode.PUSH_VAR_WORD, Opcode.PUSH_VAR_BYTE, Opcode.WRITE_INDEXED_VAR_WORD)) { segment ->
|
AsmPattern(listOf(Opcode.PUSH_VAR_WORD, Opcode.PUSH_VAR_BYTE, Opcode.WRITE_INDEXED_VAR_WORD)) { segment ->
|
||||||
TODO("$segment")
|
TODO("$segment")
|
||||||
},
|
},
|
||||||
// assignment: wordarray[idxbyte] = memword
|
// assignment: wordarray[idxbyte] = mem(u)word
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_W, Opcode.PUSH_BYTE, Opcode.WRITE_INDEXED_VAR_WORD)) { segment ->
|
AsmPattern(
|
||||||
val index = segment[1].arg!!.integerValue()*2
|
listOf(Opcode.PUSH_MEM_W, Opcode.PUSH_BYTE, Opcode.WRITE_INDEXED_VAR_WORD),
|
||||||
"""
|
listOf(Opcode.PUSH_MEM_UW, Opcode.PUSH_BYTE, Opcode.WRITE_INDEXED_VAR_WORD)) { segment ->
|
||||||
lda ${segment[0].arg!!.integerValue().toHex()}
|
|
||||||
ldy ${(segment[0].arg!!.integerValue()+1).toHex()}
|
|
||||||
sta ${segment[2].callLabel}+$index
|
|
||||||
sty ${segment[2].callLabel}+${index+1}
|
|
||||||
"""
|
|
||||||
},
|
|
||||||
// assignment: wordarray[idxbyte] = memuword (=same as above)
|
|
||||||
AsmPattern(listOf(Opcode.PUSH_MEM_UW, Opcode.PUSH_BYTE, Opcode.WRITE_INDEXED_VAR_WORD)) { segment ->
|
|
||||||
val index = segment[1].arg!!.integerValue()*2
|
val index = segment[1].arg!!.integerValue()*2
|
||||||
"""
|
"""
|
||||||
lda ${segment[0].arg!!.integerValue().toHex()}
|
lda ${segment[0].arg!!.integerValue().toHex()}
|
||||||
|
Loading…
Reference in New Issue
Block a user