|
|
|
@@ -83,24 +83,24 @@ object BuiltIns {
|
|
|
|
|
indexChoice match {
|
|
|
|
|
case IndexChoice.RequireX | IndexChoice.PreferX =>
|
|
|
|
|
val array = env.getArrayOrPointer(arrayName)
|
|
|
|
|
val calculateIndex = MlCompiler.compile(ctx, index, Some(b -> RegisterVariable(Register.X, b)), NoBranching)
|
|
|
|
|
val calculateIndex = MfCompiler.compile(ctx, index, Some(b -> RegisterVariable(Register.X, b)), NoBranching)
|
|
|
|
|
val baseAddress = array match {
|
|
|
|
|
case c: ConstantThing => c.value
|
|
|
|
|
case a: MlArray => a.toAddress
|
|
|
|
|
case a: MfArray => a.toAddress
|
|
|
|
|
}
|
|
|
|
|
calculateIndex -> List(AssemblyLine.absoluteX(opcode, baseAddress))
|
|
|
|
|
case IndexChoice.PreferY =>
|
|
|
|
|
val array = env.getArrayOrPointer(arrayName)
|
|
|
|
|
val calculateIndex = MlCompiler.compile(ctx, index, Some(b -> RegisterVariable(Register.Y, b)), NoBranching)
|
|
|
|
|
val calculateIndex = MfCompiler.compile(ctx, index, Some(b -> RegisterVariable(Register.Y, b)), NoBranching)
|
|
|
|
|
val baseAddress = array match {
|
|
|
|
|
case c: ConstantThing => c.value
|
|
|
|
|
case a: MlArray => a.toAddress
|
|
|
|
|
case a: MfArray => a.toAddress
|
|
|
|
|
}
|
|
|
|
|
calculateIndex -> List(AssemblyLine.absoluteY(opcode, baseAddress))
|
|
|
|
|
}
|
|
|
|
|
case _: FunctionCallExpression | _:SumExpression if commutative =>
|
|
|
|
|
// TODO: is it ok?
|
|
|
|
|
return List(AssemblyLine.implied(PHA)) ++ MlCompiler.compile(ctx.addStack(1), source, Some(b -> RegisterVariable(Register.A, b)), NoBranching) ++ wrapInSedCldIfNeeded(decimal, List(
|
|
|
|
|
return List(AssemblyLine.implied(PHA)) ++ MfCompiler.compile(ctx.addStack(1), source, Some(b -> RegisterVariable(Register.A, b)), NoBranching) ++ wrapInSedCldIfNeeded(decimal, List(
|
|
|
|
|
AssemblyLine.implied(TSX),
|
|
|
|
|
AssemblyLine.absoluteX(opcode, 0x101),
|
|
|
|
|
AssemblyLine.implied(INX),
|
|
|
|
@@ -149,7 +149,7 @@ object BuiltIns {
|
|
|
|
|
val normalizedParams = sortedParams
|
|
|
|
|
|
|
|
|
|
val h = normalizedParams.head
|
|
|
|
|
val firstParamCompiled = MlCompiler.compile(ctx, h._2, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val firstParamCompiled = MfCompiler.compile(ctx, h._2, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val firstParamSignCompiled = if (h._1) {
|
|
|
|
|
// TODO: check if decimal subtraction works correctly here
|
|
|
|
|
List(AssemblyLine.immediate(EOR, 0xff), AssemblyLine.implied(SEC), AssemblyLine.immediate(ADC, 0))
|
|
|
|
@@ -200,7 +200,7 @@ object BuiltIns {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val h = sortedParams.head
|
|
|
|
|
val firstParamCompiled = MlCompiler.compile(ctx, h, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val firstParamCompiled = MfCompiler.compile(ctx, h, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
|
|
|
|
|
val remainingParamsCompiled = sortedParams.tail.flatMap { p =>
|
|
|
|
|
simpleOperation(opcode, ctx, p, IndexChoice.PreferY, preserveA = true, commutative = true)
|
|
|
|
@@ -211,7 +211,7 @@ object BuiltIns {
|
|
|
|
|
|
|
|
|
|
def compileShiftOps(opcode: Opcode.Value, ctx: CompilationContext, l: Expression, r: Expression): List[AssemblyLine] = {
|
|
|
|
|
val b = ctx.env.get[Type]("byte")
|
|
|
|
|
val firstParamCompiled = MlCompiler.compile(ctx, l, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val firstParamCompiled = MfCompiler.compile(ctx, l, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
ctx.env.eval(r) match {
|
|
|
|
|
case Some(NumericConstant(0, _)) =>
|
|
|
|
|
Nil
|
|
|
|
@@ -251,7 +251,7 @@ object BuiltIns {
|
|
|
|
|
def compileInPlaceByteShiftOps(opcode: Opcode.Value, ctx: CompilationContext, lhs: LhsExpression, rhs: Expression): List[AssemblyLine] = {
|
|
|
|
|
val env = ctx.env
|
|
|
|
|
val b = env.get[Type]("byte")
|
|
|
|
|
val firstParamCompiled = MlCompiler.compile(ctx, lhs, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val firstParamCompiled = MfCompiler.compile(ctx, lhs, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
env.eval(rhs) match {
|
|
|
|
|
case Some(NumericConstant(0, _)) =>
|
|
|
|
|
Nil
|
|
|
|
@@ -293,7 +293,7 @@ object BuiltIns {
|
|
|
|
|
if (simplicity(env, lhs) >= 'J' && simplicity(env, rhs) < 'J') {
|
|
|
|
|
return compileByteComparison(ctx, ComparisonType.flip(compType), rhs, lhs, branches)
|
|
|
|
|
}
|
|
|
|
|
val firstParamCompiled = MlCompiler.compile(ctx, lhs, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val firstParamCompiled = MfCompiler.compile(ctx, lhs, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val maybeConstant = env.eval(rhs)
|
|
|
|
|
maybeConstant match {
|
|
|
|
|
case Some(NumericConstant(0, _)) =>
|
|
|
|
@@ -365,7 +365,7 @@ object BuiltIns {
|
|
|
|
|
case ComparisonType.LessOrEqualUnsigned =>
|
|
|
|
|
List(AssemblyLine.relative(BCC, Label(label)), AssemblyLine.relative(BEQ, Label(label)))
|
|
|
|
|
case ComparisonType.GreaterUnsigned =>
|
|
|
|
|
val x = MlCompiler.nextLabel("co")
|
|
|
|
|
val x = MfCompiler.nextLabel("co")
|
|
|
|
|
List(
|
|
|
|
|
AssemblyLine.relative(BEQ, x),
|
|
|
|
|
AssemblyLine.relative(BCS, Label(label)),
|
|
|
|
@@ -378,7 +378,7 @@ object BuiltIns {
|
|
|
|
|
case ComparisonType.LessOrEqualSigned =>
|
|
|
|
|
List(AssemblyLine.relative(BMI, Label(label)), AssemblyLine.relative(BEQ, Label(label)))
|
|
|
|
|
case ComparisonType.GreaterSigned =>
|
|
|
|
|
val x = MlCompiler.nextLabel("co")
|
|
|
|
|
val x = MfCompiler.nextLabel("co")
|
|
|
|
|
List(
|
|
|
|
|
AssemblyLine.relative(BEQ, x),
|
|
|
|
|
AssemblyLine.relative(BPL, Label(label)),
|
|
|
|
@@ -447,7 +447,7 @@ object BuiltIns {
|
|
|
|
|
}
|
|
|
|
|
effectiveComparisonType match {
|
|
|
|
|
case ComparisonType.Equal =>
|
|
|
|
|
val innerLabel = MlCompiler.nextLabel("cp")
|
|
|
|
|
val innerLabel = MfCompiler.nextLabel("cp")
|
|
|
|
|
staTo(LDA, ll) ++
|
|
|
|
|
staTo(CMP, rl) ++
|
|
|
|
|
List(AssemblyLine.relative(BNE, innerLabel)) ++
|
|
|
|
@@ -466,7 +466,7 @@ object BuiltIns {
|
|
|
|
|
List(AssemblyLine.relative(BNE, Label(x)))
|
|
|
|
|
|
|
|
|
|
case ComparisonType.LessUnsigned =>
|
|
|
|
|
val innerLabel = MlCompiler.nextLabel("cp")
|
|
|
|
|
val innerLabel = MfCompiler.nextLabel("cp")
|
|
|
|
|
staTo(LDA, lh) ++
|
|
|
|
|
staTo(CMP, rh) ++
|
|
|
|
|
List(
|
|
|
|
@@ -479,7 +479,7 @@ object BuiltIns {
|
|
|
|
|
AssemblyLine.label(innerLabel))
|
|
|
|
|
|
|
|
|
|
case ComparisonType.LessOrEqualUnsigned =>
|
|
|
|
|
val innerLabel = MlCompiler.nextLabel("cp")
|
|
|
|
|
val innerLabel = MfCompiler.nextLabel("cp")
|
|
|
|
|
staTo(LDA, rh) ++
|
|
|
|
|
staTo(CMP, lh) ++
|
|
|
|
|
List(AssemblyLine.relative(BCC, innerLabel),
|
|
|
|
@@ -490,7 +490,7 @@ object BuiltIns {
|
|
|
|
|
AssemblyLine.label(innerLabel))
|
|
|
|
|
|
|
|
|
|
case ComparisonType.GreaterUnsigned =>
|
|
|
|
|
val innerLabel = MlCompiler.nextLabel("cp")
|
|
|
|
|
val innerLabel = MfCompiler.nextLabel("cp")
|
|
|
|
|
staTo(LDA, rh) ++
|
|
|
|
|
staTo(CMP, lh) ++
|
|
|
|
|
List(AssemblyLine.relative(BCC, Label(x)),
|
|
|
|
@@ -501,7 +501,7 @@ object BuiltIns {
|
|
|
|
|
AssemblyLine.label(innerLabel))
|
|
|
|
|
|
|
|
|
|
case ComparisonType.GreaterOrEqualUnsigned =>
|
|
|
|
|
val innerLabel = MlCompiler.nextLabel("cp")
|
|
|
|
|
val innerLabel = MfCompiler.nextLabel("cp")
|
|
|
|
|
staTo(LDA, lh) ++
|
|
|
|
|
staTo(CMP, rh) ++
|
|
|
|
|
List(AssemblyLine.relative(BCC, innerLabel),
|
|
|
|
@@ -520,11 +520,11 @@ object BuiltIns {
|
|
|
|
|
val b = ctx.env.get[Type]("byte")
|
|
|
|
|
ctx.env.eval(addend) match {
|
|
|
|
|
case Some(NumericConstant(0, _)) =>
|
|
|
|
|
AssemblyLine.immediate(LDA, 0) :: MlCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
AssemblyLine.immediate(LDA, 0) :: MfCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
case Some(NumericConstant(1, _)) =>
|
|
|
|
|
Nil
|
|
|
|
|
case Some(NumericConstant(x, _)) =>
|
|
|
|
|
compileByteMultiplication(ctx, v, x.toInt) ++ MlCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
compileByteMultiplication(ctx, v, x.toInt) ++ MfCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
case _ =>
|
|
|
|
|
ErrorReporting.error("Multiplying by not a constant not supported", v.position)
|
|
|
|
|
Nil
|
|
|
|
@@ -589,18 +589,18 @@ object BuiltIns {
|
|
|
|
|
}
|
|
|
|
|
case _ =>
|
|
|
|
|
if (!subtract && simplicity(env, v) > simplicity(env, addend)) {
|
|
|
|
|
val loadRhs = MlCompiler.compile(ctx, addend, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val loadRhs = MfCompiler.compile(ctx, addend, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val modifyAcc = insertBeforeLast(AssemblyLine.implied(CLC), simpleOperation(ADC, ctx, v, IndexChoice.PreferY, preserveA = true, commutative = true, decimal = decimal))
|
|
|
|
|
val storeLhs = MlCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
val storeLhs = MfCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
loadRhs ++ modifyAcc ++ storeLhs
|
|
|
|
|
} else {
|
|
|
|
|
val loadLhs = MlCompiler.compile(ctx, v, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val loadLhs = MfCompiler.compile(ctx, v, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val modifyLhs = if (subtract) {
|
|
|
|
|
insertBeforeLast(AssemblyLine.implied(SEC), simpleOperation(SBC, ctx, addend, IndexChoice.PreferY, preserveA = true, commutative = false, decimal = decimal))
|
|
|
|
|
} else {
|
|
|
|
|
insertBeforeLast(AssemblyLine.implied(CLC), simpleOperation(ADC, ctx, addend, IndexChoice.PreferY, preserveA = true, commutative = true, decimal = decimal))
|
|
|
|
|
}
|
|
|
|
|
val storeLhs = MlCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
val storeLhs = MfCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
loadLhs ++ modifyLhs ++ storeLhs
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -616,7 +616,7 @@ object BuiltIns {
|
|
|
|
|
val targetBytes: List[List[AssemblyLine]] = getStorageForEachByte(ctx, lhs)
|
|
|
|
|
val lhsIsStack = targetBytes.head.head.opcode == TSX
|
|
|
|
|
val targetSize = targetBytes.size
|
|
|
|
|
val addendType = MlCompiler.getExpressionType(ctx, addend)
|
|
|
|
|
val addendType = MfCompiler.getExpressionType(ctx, addend)
|
|
|
|
|
var addendSize = addendType.size
|
|
|
|
|
|
|
|
|
|
def isRhsComplex(xs: List[AssemblyLine]): Boolean = xs match {
|
|
|
|
@@ -639,7 +639,7 @@ object BuiltIns {
|
|
|
|
|
case Nil => Nil
|
|
|
|
|
case x :: Nil => staTo(DEC, x)
|
|
|
|
|
case x :: xs =>
|
|
|
|
|
val label = MlCompiler.nextLabel("de")
|
|
|
|
|
val label = MfCompiler.nextLabel("de")
|
|
|
|
|
staTo(LDA, x) ++
|
|
|
|
|
List(AssemblyLine.relative(BNE, label)) ++
|
|
|
|
|
doDec(xs) ++
|
|
|
|
@@ -651,16 +651,16 @@ object BuiltIns {
|
|
|
|
|
case Some(NumericConstant(0, _)) =>
|
|
|
|
|
return Nil
|
|
|
|
|
case Some(NumericConstant(1, _)) if canUseIncDec && !subtract =>
|
|
|
|
|
val label = MlCompiler.nextLabel("in")
|
|
|
|
|
val label = MfCompiler.nextLabel("in")
|
|
|
|
|
return staTo(INC, targetBytes.head) ++ targetBytes.tail.flatMap(l => AssemblyLine.relative(BNE, label)::staTo(INC, l)) :+ AssemblyLine.label(label)
|
|
|
|
|
case Some(NumericConstant(-1, _)) if canUseIncDec && subtract =>
|
|
|
|
|
val label = MlCompiler.nextLabel("in")
|
|
|
|
|
val label = MfCompiler.nextLabel("in")
|
|
|
|
|
return staTo(INC, targetBytes.head) ++ targetBytes.tail.flatMap(l => AssemblyLine.relative(BNE, label)::staTo(INC, l)) :+ AssemblyLine.label(label)
|
|
|
|
|
case Some(NumericConstant(1, _)) if canUseIncDec && subtract =>
|
|
|
|
|
val label = MlCompiler.nextLabel("de")
|
|
|
|
|
val label = MfCompiler.nextLabel("de")
|
|
|
|
|
return doDec(targetBytes)
|
|
|
|
|
case Some(NumericConstant(-1, _)) if canUseIncDec && !subtract =>
|
|
|
|
|
val label = MlCompiler.nextLabel("de")
|
|
|
|
|
val label = MfCompiler.nextLabel("de")
|
|
|
|
|
return doDec(targetBytes)
|
|
|
|
|
case Some(constant) =>
|
|
|
|
|
addendSize = targetSize
|
|
|
|
@@ -668,7 +668,7 @@ object BuiltIns {
|
|
|
|
|
case None =>
|
|
|
|
|
addendSize match {
|
|
|
|
|
case 1 =>
|
|
|
|
|
val base = MlCompiler.compile(ctx, addend, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val base = MfCompiler.compile(ctx, addend, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
if (subtract) {
|
|
|
|
|
if (isRhsComplex(base)) {
|
|
|
|
|
if (isRhsStack(base)) {
|
|
|
|
@@ -683,9 +683,9 @@ object BuiltIns {
|
|
|
|
|
base -> List(Nil)
|
|
|
|
|
}
|
|
|
|
|
case 2 =>
|
|
|
|
|
val base = MlCompiler.compile(ctx, addend, Some(w -> RegisterVariable(Register.AX, w)), NoBranching)
|
|
|
|
|
val base = MfCompiler.compile(ctx, addend, Some(w -> RegisterVariable(Register.AX, w)), NoBranching)
|
|
|
|
|
if (isRhsStack(base)) {
|
|
|
|
|
val fixedBase = MlCompiler.compile(ctx, addend, Some(w -> RegisterVariable(Register.AY, w)), NoBranching)
|
|
|
|
|
val fixedBase = MfCompiler.compile(ctx, addend, Some(w -> RegisterVariable(Register.AY, w)), NoBranching)
|
|
|
|
|
if (subtract) {
|
|
|
|
|
ErrorReporting.warn("Subtracting a stack-based value", ctx.options)
|
|
|
|
|
if (isRhsComplex(base)) {
|
|
|
|
@@ -712,7 +712,7 @@ object BuiltIns {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (lhsIsStack) {
|
|
|
|
|
val fixedBase = MlCompiler.compile(ctx, addend, Some(w -> RegisterVariable(Register.AY, w)), NoBranching)
|
|
|
|
|
val fixedBase = MfCompiler.compile(ctx, addend, Some(w -> RegisterVariable(Register.AY, w)), NoBranching)
|
|
|
|
|
fixedBase -> List(Nil, List(AssemblyLine.implied(TYA)))
|
|
|
|
|
} else {
|
|
|
|
|
base -> List(Nil, List(AssemblyLine.implied(TXA)))
|
|
|
|
@@ -744,7 +744,7 @@ object BuiltIns {
|
|
|
|
|
} else {
|
|
|
|
|
if (i >= addendSize) {
|
|
|
|
|
if (addendType.isSigned) {
|
|
|
|
|
val label = MlCompiler.nextLabel("sx")
|
|
|
|
|
val label = MfCompiler.nextLabel("sx")
|
|
|
|
|
buffer += AssemblyLine.implied(TXA)
|
|
|
|
|
if (i == addendSize) {
|
|
|
|
|
buffer += AssemblyLine.immediate(ORA, 0x7f)
|
|
|
|
@@ -783,14 +783,14 @@ object BuiltIns {
|
|
|
|
|
Nil
|
|
|
|
|
case _ =>
|
|
|
|
|
if (simplicity(env, v) > simplicity(env, param)) {
|
|
|
|
|
val loadRhs = MlCompiler.compile(ctx, param, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val loadRhs = MfCompiler.compile(ctx, param, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val modifyAcc = simpleOperation(operation, ctx, v, IndexChoice.PreferY, preserveA = true, commutative = true)
|
|
|
|
|
val storeLhs = MlCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
val storeLhs = MfCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
loadRhs ++ modifyAcc ++ storeLhs
|
|
|
|
|
} else {
|
|
|
|
|
val loadLhs = MlCompiler.compile(ctx, v, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val loadLhs = MfCompiler.compile(ctx, v, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val modifyLhs = simpleOperation(operation, ctx, param, IndexChoice.PreferY, preserveA = true, commutative = true)
|
|
|
|
|
val storeLhs = MlCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
val storeLhs = MfCompiler.compileByteStorage(ctx, Register.A, v)
|
|
|
|
|
loadLhs ++ modifyLhs ++ storeLhs
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -804,7 +804,7 @@ object BuiltIns {
|
|
|
|
|
val targetBytes: List[List[AssemblyLine]] = getStorageForEachByte(ctx, lhs)
|
|
|
|
|
val lo = targetBytes.head
|
|
|
|
|
val targetSize = targetBytes.size
|
|
|
|
|
val paramType = MlCompiler.getExpressionType(ctx, param)
|
|
|
|
|
val paramType = MfCompiler.getExpressionType(ctx, param)
|
|
|
|
|
var paramSize = paramType.size
|
|
|
|
|
val extendMultipleBytes = targetSize > paramSize + 1
|
|
|
|
|
val extendAtLeastOneByte = targetSize > paramSize
|
|
|
|
@@ -815,10 +815,10 @@ object BuiltIns {
|
|
|
|
|
case None =>
|
|
|
|
|
paramSize match {
|
|
|
|
|
case 1 =>
|
|
|
|
|
val base = MlCompiler.compile(ctx, param, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
val base = MfCompiler.compile(ctx, param, Some(b -> RegisterVariable(Register.A, b)), NoBranching)
|
|
|
|
|
base -> List(Nil)
|
|
|
|
|
case 2 =>
|
|
|
|
|
val base = MlCompiler.compile(ctx, param, Some(w -> RegisterVariable(Register.AX, w)), NoBranching)
|
|
|
|
|
val base = MfCompiler.compile(ctx, param, Some(w -> RegisterVariable(Register.AX, w)), NoBranching)
|
|
|
|
|
base -> List(Nil, List(AssemblyLine.implied(TXA)))
|
|
|
|
|
case _ => Nil -> (param match {
|
|
|
|
|
case vv: VariableExpression =>
|
|
|
|
@@ -844,7 +844,7 @@ object BuiltIns {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (paramType.isSigned) {
|
|
|
|
|
val label = MlCompiler.nextLabel("sx")
|
|
|
|
|
val label = MfCompiler.nextLabel("sx")
|
|
|
|
|
buffer += AssemblyLine.implied(TXA)
|
|
|
|
|
if (i == paramSize) {
|
|
|
|
|
buffer += AssemblyLine.immediate(ORA, 0x7f)
|
|
|
|
@@ -875,7 +875,7 @@ object BuiltIns {
|
|
|
|
|
val variable = env.get[Variable](v.name)
|
|
|
|
|
List.tabulate(variable.typ.size) { i => AssemblyLine.variable(ctx, STA, variable, i) }
|
|
|
|
|
case IndexedExpression(variable, index) =>
|
|
|
|
|
List(MlCompiler.compileByteStorage(ctx, Register.A, lhs))
|
|
|
|
|
List(MfCompiler.compileByteStorage(ctx, Register.A, lhs))
|
|
|
|
|
case SeparateBytesExpression(h: LhsExpression, l: LhsExpression) =>
|
|
|
|
|
if (simplicity(ctx.env, h) < 'J' || simplicity(ctx.env, l) < 'J') {
|
|
|
|
|
// a[b]:c[d] is the most complex expression that doesn't cause the following warning
|
|
|
|
@@ -883,7 +883,7 @@ object BuiltIns {
|
|
|
|
|
}
|
|
|
|
|
List(
|
|
|
|
|
getStorageForEachByte(ctx, l).head,
|
|
|
|
|
MlCompiler.preserveRegisterIfNeeded(ctx, Register.A, getStorageForEachByte(ctx, h).head))
|
|
|
|
|
MfCompiler.preserveRegisterIfNeeded(ctx, Register.A, getStorageForEachByte(ctx, h).head))
|
|
|
|
|
case _ =>
|
|
|
|
|
???
|
|
|
|
|
}
|
|
|
|
|