make instructions more obvious

This commit is contained in:
Mark Canlas 2022-08-03 00:25:56 -04:00
parent 6199265f26
commit 556c60eccc
3 changed files with 23 additions and 6 deletions

View File

@ -0,0 +1,11 @@
package com.htmlism
package object scratchpad:
type A =
Register.A
type X =
Register.X
type Y =
Register.Y

View File

@ -7,4 +7,10 @@ package object syntax:
class PartiallyAppliedWrite[A: Loadable](reg: WriteAddress, x: A):
def apply[B: Register]: String =
reg.addr.n.toString + summon[Loadable[A]].show(x) + summon[Register[B]].self
val first =
"LD" + summon[Register[B]].self + " " + summon[Loadable[A]].show(x)
val second =
"ST" + summon[Register[B]].self + " " + reg.addr.n.toString
first + " " + second

View File

@ -8,21 +8,21 @@ import com.htmlism.scratchpad.syntax._
class FeatureSpec extends AnyFunSuite with Matchers:
test("zero page address as write only supports writing") {
WriteOnlyAddress(Address.zero(0x01))
.write(2)[Register.A] shouldBe "12A"
.write(2)[A] shouldBe "LDA 2 STA 1"
}
test("zero page address as read/write supports writing") {
ReadWriteAddress(Address.zero(0x01))
.write(2)[Register.A] shouldBe "12A"
.write(2)[A] shouldBe "LDA 2 STA 1"
}
test("writing to an address can use A, X, and Y registers for bouncing ") {
ReadWriteAddress(Address.zero(0x01))
.write(2)[Register.A] shouldBe "12A"
.write(2)[A] shouldBe "LDA 2 STA 1"
ReadWriteAddress(Address.zero(0x01))
.write(2)[Register.X] shouldBe "12X"
.write(2)[X] shouldBe "LDX 2 STX 1"
ReadWriteAddress(Address.zero(0x01))
.write(2)[Register.Y] shouldBe "12Y"
.write(2)[Y] shouldBe "LDY 2 STY 1"
}