1
0
mirror of https://github.com/KarolS/millfork.git synced 2026-04-21 09:16:34 +00:00

Allow putting pointer variables anywhere

This commit is contained in:
Karol Stasiak
2019-04-15 00:27:34 +02:00
parent 194f79f907
commit 4cd1db0e0f
7 changed files with 146 additions and 29 deletions
@@ -0,0 +1,42 @@
package millfork.test
import millfork.Cpu
import millfork.test.emu.EmuCrossPlatformBenchmarkRun
import org.scalatest.{FunSuite, Matchers}
/**
* @author Karol Stasiak
*/
class PointerSuite extends FunSuite with Matchers {
test("Pointers outside zeropage") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(
"""
| pointer p @$c004
| array output[2] @$c000
| void main() {
| p = output.addr
| output[0] = 45
| p[1] = p[0]
| }
""".stripMargin) { m =>
m.readByte(0xc001) should equal(45)
}
}
test("Pointers on stack") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(
"""
| array output[2] @$c000
| void main() {
| stack pointer p
| p = output.addr
| output[0] = 45
| p[1] = p[0]
| }
""".stripMargin) { m =>
m.readByte(0xc001) should equal(45)
}
}
}