1
0
mirror of https://github.com/KarolS/millfork.git synced 2025-01-01 06:29:53 +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 => case NumericConstant(n, _) if n < 0 && !decimal =>
result += ZLine.imm8(SUB, (-n.toInt) & 0xff) result += ZLine.imm8(SUB, (-n.toInt) & 0xff)
case NumericConstant(0, _) =>
// nothing
case _ => case _ =>
result += ZLine.imm8(ADD, const.loByte) result += ZLine.imm8(ADD, const.loByte)
if (decimal) { if (decimal) {

View File

@ -1480,7 +1480,10 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
stmt.assemblyParamPassingConvention match { stmt.assemblyParamPassingConvention match {
case ByVariable(name) => case ByVariable(name) =>
val zp = pointies(name) // TODO 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) val v = UninitializedMemoryVariable(prefix + name, typ, allocationMethod, None, defaultVariableAlignment(options, 2), isVolatile = false)
addThing(v, stmt.position) addThing(v, stmt.position)
registerAddressConstant(v, stmt.position, options, Some(typ)) registerAddressConstant(v, stmt.position, options, Some(typ))

View File

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