1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-11-17 16:05:31 +00:00

Some random stuff

This commit is contained in:
Karol Stasiak 2019-08-05 11:43:51 +02:00
parent 154df77ad3
commit 6b34ddf7f9
3 changed files with 38 additions and 0 deletions

View File

@ -1004,6 +1004,8 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
AssemblyParam(typ, RegisterVariable(reg, typ), AssemblyParameterPassingBehaviour.Copy)
case ByZRegister(reg) =>
AssemblyParam(typ, ZRegisterVariable(reg, typ), AssemblyParameterPassingBehaviour.Copy)
case ByM6809Register(reg) =>
AssemblyParam(typ, M6809RegisterVariable(reg, typ), AssemblyParameterPassingBehaviour.Copy)
case ByConstant(vn) =>
AssemblyParam(typ, Placeholder(vn, typ), AssemblyParameterPassingBehaviour.ByConstant)
case ByReference(vn) =>
@ -1299,6 +1301,7 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
}
case ByMosRegister(_) => ()
case ByZRegister(_) => ()
case ByM6809Register(_) => ()
case ByConstant(name) =>
val v = ConstantThing(prefix + name, UnexpandedConstant(prefix + name, typ.size), typ)
addThing(v, stmt.position)

View File

@ -225,6 +225,11 @@ case class ZRegisterVariable(register: ZRegister.Value, typ: Type) extends Varia
override def isVolatile: Boolean = false
}
case class M6809RegisterVariable(register: M6809Register.Value, typ: Type) extends Variable {
def name: String = register.toString
override def isVolatile: Boolean = false
}
case class Placeholder(name: String, typ: Type) extends Variable {
override def isVolatile: Boolean = false
}

View File

@ -198,4 +198,34 @@ class BooleanSuite extends FunSuite with Matchers {
""".stripMargin
EmuUnoptimizedRun(code).readWord(0xc000) should equal(5)
}
test("Builtin types") {
val code ="""
| byte output @$c000
| noinline asm set_carry f(byte a) {
| #if ARCH_6502
| CLC
| ADC #1
| RTS
| #elseif ARCH_I80
| ADD A,1
| RET
| #elseif ARCH_6809
| ADDA #1
| RTS
| #else
| #error
| #endif
| }
| void main () {
| output = 0
| if f(0) { output += 100 }
| if f($ff) { output += 1 }
| }
|
""".stripMargin
EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)(code){ m =>
m.readByte(0xc000) should equal(1)
}
}
}