mirror of
https://github.com/KarolS/millfork.git
synced 2025-08-07 12:25:40 +00:00
Interrupt functions in assembly should not have prologue (fixes #62)
This commit is contained in:
@@ -37,7 +37,7 @@ object MosCompiler extends AbstractCompiler[AssemblyLine] {
|
|||||||
List(AssemblyLine.absolute(LDA, ctx.env.get[ThingInMemory]("__sp")), AssemblyLine.implied(PHA))
|
List(AssemblyLine.absolute(LDA, ctx.env.get[ThingInMemory]("__sp")), AssemblyLine.implied(PHA))
|
||||||
} else Nil)
|
} else Nil)
|
||||||
|
|
||||||
val prefix = storeParamsFromRegisters ++ (if (ctx.function.interrupt) {
|
val prefix = storeParamsFromRegisters ++ (if (ctx.function.interrupt && !ctx.function.inAssembly) {
|
||||||
|
|
||||||
if (ctx.options.flag(CompilationFlag.EmitNative65816Opcodes)) {
|
if (ctx.options.flag(CompilationFlag.EmitNative65816Opcodes)) {
|
||||||
if (zpRegisterSize > 0) {
|
if (zpRegisterSize > 0) {
|
||||||
|
@@ -68,7 +68,7 @@ object Z80Compiler extends AbstractCompiler[ZLine] {
|
|||||||
def preserveRegisters(ctx: CompilationContext): List[ZLine] = {
|
def preserveRegisters(ctx: CompilationContext): List[ZLine] = {
|
||||||
import millfork.assembly.z80.ZOpcode._
|
import millfork.assembly.z80.ZOpcode._
|
||||||
import ZRegister._
|
import ZRegister._
|
||||||
if (ctx.function.interrupt) {
|
if (ctx.function.interrupt && !ctx.function.inAssembly) {
|
||||||
if (ctx.options.flag(CompilationFlag.EmitZ80Opcodes)) {
|
if (ctx.options.flag(CompilationFlag.EmitZ80Opcodes)) {
|
||||||
if (ctx.options.flag(CompilationFlag.UseShadowRegistersForInterrupts)) {
|
if (ctx.options.flag(CompilationFlag.UseShadowRegistersForInterrupts)) {
|
||||||
List(
|
List(
|
||||||
|
@@ -1378,6 +1378,7 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
|
|||||||
hasElidedReturnVariable = hasElidedReturnVariable,
|
hasElidedReturnVariable = hasElidedReturnVariable,
|
||||||
interrupt = stmt.interrupt,
|
interrupt = stmt.interrupt,
|
||||||
kernalInterrupt = stmt.kernalInterrupt,
|
kernalInterrupt = stmt.kernalInterrupt,
|
||||||
|
inAssembly = stmt.assembly,
|
||||||
reentrant = stmt.reentrant,
|
reentrant = stmt.reentrant,
|
||||||
isConstPure = stmt.constPure,
|
isConstPure = stmt.constPure,
|
||||||
position = stmt.position,
|
position = stmt.position,
|
||||||
|
1
src/main/scala/millfork/env/Thing.scala
vendored
1
src/main/scala/millfork/env/Thing.scala
vendored
@@ -481,6 +481,7 @@ case class NormalFunction(name: String,
|
|||||||
hasElidedReturnVariable: Boolean,
|
hasElidedReturnVariable: Boolean,
|
||||||
interrupt: Boolean,
|
interrupt: Boolean,
|
||||||
kernalInterrupt: Boolean,
|
kernalInterrupt: Boolean,
|
||||||
|
inAssembly: Boolean,
|
||||||
isConstPure: Boolean,
|
isConstPure: Boolean,
|
||||||
reentrant: Boolean,
|
reentrant: Boolean,
|
||||||
position: Option[Position],
|
position: Option[Position],
|
||||||
|
@@ -460,4 +460,49 @@ class AssemblySuite extends FunSuite with Matchers with AppendedClues {
|
|||||||
m.readByte(0xc001) should equal(1)
|
m.readByte(0xc001) should equal(1)
|
||||||
m.readByte(0xc002) should equal(2)
|
m.readByte(0xc002) should equal(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("Interrupt functions in assembly should not have prologue (6502)") {
|
||||||
|
val m = EmuUnoptimizedRun(
|
||||||
|
"""
|
||||||
|
|byte output @$c000
|
||||||
|
|noinline interrupt asm void i() {
|
||||||
|
| nop
|
||||||
|
| rti
|
||||||
|
|}
|
||||||
|
|void main() {
|
||||||
|
| output = pointer(i.addr)[0]
|
||||||
|
|}
|
||||||
|
|""".stripMargin)
|
||||||
|
m.readByte(0xc000) should equal(0xea)
|
||||||
|
}
|
||||||
|
|
||||||
|
test("Interrupt functions in assembly should not have prologue (Z80)") {
|
||||||
|
val m = EmuUnoptimizedZ80Run(
|
||||||
|
"""
|
||||||
|
|byte output @$c000
|
||||||
|
|noinline interrupt asm void i() {
|
||||||
|
| nop
|
||||||
|
| reti
|
||||||
|
|}
|
||||||
|
|void main() {
|
||||||
|
| output = pointer(i.addr)[0]
|
||||||
|
|}
|
||||||
|
|""".stripMargin)
|
||||||
|
m.readByte(0xc000) should equal(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
test("Interrupt functions in assembly should not have prologue (M6809)") {
|
||||||
|
val m = EmuUnoptimizedM6809Run(
|
||||||
|
"""
|
||||||
|
|byte output @$c000
|
||||||
|
|noinline interrupt asm void i() {
|
||||||
|
| nop
|
||||||
|
| rti
|
||||||
|
|}
|
||||||
|
|void main() {
|
||||||
|
| output = pointer(i.addr)[0]
|
||||||
|
|}
|
||||||
|
|""".stripMargin)
|
||||||
|
m.readByte(0xc000) should equal(0x12)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user