mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-12-22 09:30:45 +00:00
drop names
This commit is contained in:
parent
ca2333ccc5
commit
87be54418f
@ -4,6 +4,6 @@ object Encoded:
|
||||
trait Byte[A]
|
||||
|
||||
object Byte:
|
||||
given intByte: Encoded.Byte[Int] with {}
|
||||
given Encoded.Byte[Int] with {}
|
||||
|
||||
trait Word[A]
|
||||
|
@ -12,4 +12,4 @@ object Load:
|
||||
|
||||
case class Const[R, A: Encoded.Byte](x: A)(using R: Register[R]) extends Asm1[R]:
|
||||
def xs: List[String] =
|
||||
List("LD" + R.name)
|
||||
List(R.load)
|
||||
|
@ -4,6 +4,6 @@ trait Loadable[A]:
|
||||
def show(x: A): String
|
||||
|
||||
object Loadable:
|
||||
given intLoadable: Loadable[Int] with
|
||||
given Loadable[Int] with
|
||||
def show(x: Int): String =
|
||||
x.toString
|
||||
|
@ -5,21 +5,46 @@ package com.htmlism.scratchpad
|
||||
sealed trait Register[A]:
|
||||
def name: String
|
||||
|
||||
def load: String
|
||||
|
||||
def store: String
|
||||
|
||||
object Register:
|
||||
object A:
|
||||
given registerA: Register[A] with
|
||||
def name: String = "A"
|
||||
given Register[A] with
|
||||
def name: String =
|
||||
"A"
|
||||
|
||||
def load: String =
|
||||
"LDA"
|
||||
|
||||
def store: String =
|
||||
"STA"
|
||||
|
||||
class A
|
||||
|
||||
object X:
|
||||
given registerX: Register[X] with
|
||||
def name: String = "X"
|
||||
given Register[X] with
|
||||
def name: String =
|
||||
"X"
|
||||
|
||||
def load: String =
|
||||
"LDX"
|
||||
|
||||
def store: String =
|
||||
"STX"
|
||||
|
||||
class X
|
||||
|
||||
object Y:
|
||||
given registerY: Register[Y] with
|
||||
def name: String = "Y"
|
||||
given Register[Y] with
|
||||
def name: String =
|
||||
"Y"
|
||||
|
||||
def load: String =
|
||||
"LDY"
|
||||
|
||||
def store: String =
|
||||
"STY"
|
||||
|
||||
class Y
|
||||
|
@ -39,20 +39,20 @@ object ScratchPad:
|
||||
class Accumulator
|
||||
|
||||
object Accumulator extends Accumulator:
|
||||
given registerA: Reg[Accumulator] with
|
||||
given Reg[Accumulator] with
|
||||
def hello: Boolean =
|
||||
true
|
||||
|
||||
class RegisterX
|
||||
|
||||
object RegisterX:
|
||||
given registerX: Reg[RegisterX] with
|
||||
given Reg[RegisterX] with
|
||||
def hello: Boolean =
|
||||
true
|
||||
|
||||
class RegisterY
|
||||
|
||||
object RegisterY:
|
||||
given registerY: Reg[RegisterY] with
|
||||
given Reg[RegisterY] with
|
||||
def hello: Boolean =
|
||||
true
|
||||
|
@ -12,4 +12,4 @@ object Store:
|
||||
|
||||
case class Byte[R, A](dest: WriteLease.ByteAddress[A])(using R: Register[R]) extends Asm2[R, A]:
|
||||
def xs: List[String] =
|
||||
List("ST" + R.name)
|
||||
List(R.store)
|
||||
|
@ -14,13 +14,13 @@ package object syntax:
|
||||
summon[Loadable[Addr]].show(x)
|
||||
|
||||
val register =
|
||||
summon[Register[R]].name
|
||||
summon[Register[R]]
|
||||
|
||||
val loadInstruction =
|
||||
"LD" + register // TODO load action needs to interact with encoder
|
||||
register.load // TODO load action needs to interact with encoder
|
||||
|
||||
val storeInstruction =
|
||||
"ST" + register // TODO store action needs to interact with encoder
|
||||
register.store // TODO store action needs to interact with encoder
|
||||
|
||||
val first =
|
||||
s"$loadInstruction $literal"
|
||||
@ -29,6 +29,6 @@ package object syntax:
|
||||
s"$storeInstruction ${reg.n.toString}"
|
||||
|
||||
val desc =
|
||||
s"${reg.alias} = $literal, via $register"
|
||||
s"${reg.alias} = $literal, via ${register.name}"
|
||||
|
||||
s"$first $second ; $desc"
|
||||
|
@ -15,17 +15,18 @@ object ComplicatedResourceSuite extends FunSuite:
|
||||
class PlayerOne extends Player[PlayerOne](40)
|
||||
|
||||
object PlayerOne extends PlayerOne:
|
||||
given write: WriteLease[PlayerOne] with
|
||||
given WriteLease[PlayerOne] with
|
||||
def canon: PlayerOne =
|
||||
PlayerOne
|
||||
|
||||
class PlayerTwo extends Player[PlayerTwo](80)
|
||||
|
||||
object PlayerTwo extends PlayerTwo:
|
||||
given write: WriteLease[PlayerTwo] with
|
||||
given WriteLease[PlayerTwo] with
|
||||
def canon: PlayerTwo =
|
||||
PlayerTwo
|
||||
|
||||
test("use write lease") {
|
||||
expect.eql(List("LDA", "STA"), PlayerOne.setHead(0)(using PlayerOne.write).xs)
|
||||
// TODO actually this doesn't make sense. the lease shouldn't be canonical/globally available. only when lease is given...
|
||||
expect.eql(List("LDA", "STA"), PlayerOne.setHead(0).xs)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user