1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-29 02:31:45 +00:00

8080: Some minor improvements

This commit is contained in:
Karol Stasiak 2020-04-06 11:35:14 +02:00
parent b21b04efeb
commit 78346af2ef
3 changed files with 7 additions and 1 deletions

View File

@ -177,6 +177,8 @@ object ZBuiltIns {
}
case NumericConstant(n, _) if n < 0 && !decimal =>
result += ZLine.imm8(SUB, (-n.toInt) & 0xff)
case NumericConstant(0, _) =>
// nothing
case _ =>
result += ZLine.imm8(ADD, const.loByte)
if (decimal) {

View File

@ -1480,7 +1480,10 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
stmt.assemblyParamPassingConvention match {
case ByVariable(name) =>
val zp = pointies(name) // TODO
val allocationMethod = if (pointies(name)) VariableAllocationMethod.Zeropage else if (typ.isPointy) VariableAllocationMethod.Register else VariableAllocationMethod.Auto
val allocationMethod =
if (pointies(name)) VariableAllocationMethod.Zeropage
else if (typ.isPointy && options.platform.cpuFamily == CpuFamily.M6502) VariableAllocationMethod.Register
else VariableAllocationMethod.Auto
val v = UninitializedMemoryVariable(prefix + name, typ, allocationMethod, None, defaultVariableAlignment(options, 2), isVolatile = false)
addThing(v, stmt.position)
registerAddressConstant(v, stmt.position, options, Some(typ))

View File

@ -730,6 +730,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
inlinedFunctions,
options.jobContext))
unoptimizedCodeSize += unoptimized.map(_.sizeInBytes).sum
// unoptimized.foreach(l => log.trace(l.toString))
val code = optimizations.foldLeft(quickSimplify(unoptimized)) { (c, opt) =>
val code = opt.optimize(f, c, OptimizationContext(options, labelMap, env.maybeGet[ThingInMemory]("__reg"), niceFunctionProperties))
if (code eq c) code else quickSimplify(code)