mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-12-23 01:29:47 +00:00
drop names
This commit is contained in:
parent
ca2333ccc5
commit
87be54418f
@ -4,6 +4,6 @@ object Encoded:
|
|||||||
trait Byte[A]
|
trait Byte[A]
|
||||||
|
|
||||||
object Byte:
|
object Byte:
|
||||||
given intByte: Encoded.Byte[Int] with {}
|
given Encoded.Byte[Int] with {}
|
||||||
|
|
||||||
trait Word[A]
|
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]:
|
case class Const[R, A: Encoded.Byte](x: A)(using R: Register[R]) extends Asm1[R]:
|
||||||
def xs: List[String] =
|
def xs: List[String] =
|
||||||
List("LD" + R.name)
|
List(R.load)
|
||||||
|
@ -4,6 +4,6 @@ trait Loadable[A]:
|
|||||||
def show(x: A): String
|
def show(x: A): String
|
||||||
|
|
||||||
object Loadable:
|
object Loadable:
|
||||||
given intLoadable: Loadable[Int] with
|
given Loadable[Int] with
|
||||||
def show(x: Int): String =
|
def show(x: Int): String =
|
||||||
x.toString
|
x.toString
|
||||||
|
@ -5,21 +5,46 @@ package com.htmlism.scratchpad
|
|||||||
sealed trait Register[A]:
|
sealed trait Register[A]:
|
||||||
def name: String
|
def name: String
|
||||||
|
|
||||||
|
def load: String
|
||||||
|
|
||||||
|
def store: String
|
||||||
|
|
||||||
object Register:
|
object Register:
|
||||||
object A:
|
object A:
|
||||||
given registerA: Register[A] with
|
given Register[A] with
|
||||||
def name: String = "A"
|
def name: String =
|
||||||
|
"A"
|
||||||
|
|
||||||
|
def load: String =
|
||||||
|
"LDA"
|
||||||
|
|
||||||
|
def store: String =
|
||||||
|
"STA"
|
||||||
|
|
||||||
class A
|
class A
|
||||||
|
|
||||||
object X:
|
object X:
|
||||||
given registerX: Register[X] with
|
given Register[X] with
|
||||||
def name: String = "X"
|
def name: String =
|
||||||
|
"X"
|
||||||
|
|
||||||
|
def load: String =
|
||||||
|
"LDX"
|
||||||
|
|
||||||
|
def store: String =
|
||||||
|
"STX"
|
||||||
|
|
||||||
class X
|
class X
|
||||||
|
|
||||||
object Y:
|
object Y:
|
||||||
given registerY: Register[Y] with
|
given Register[Y] with
|
||||||
def name: String = "Y"
|
def name: String =
|
||||||
|
"Y"
|
||||||
|
|
||||||
|
def load: String =
|
||||||
|
"LDY"
|
||||||
|
|
||||||
|
def store: String =
|
||||||
|
"STY"
|
||||||
|
|
||||||
class Y
|
class Y
|
||||||
|
@ -39,20 +39,20 @@ object ScratchPad:
|
|||||||
class Accumulator
|
class Accumulator
|
||||||
|
|
||||||
object Accumulator extends Accumulator:
|
object Accumulator extends Accumulator:
|
||||||
given registerA: Reg[Accumulator] with
|
given Reg[Accumulator] with
|
||||||
def hello: Boolean =
|
def hello: Boolean =
|
||||||
true
|
true
|
||||||
|
|
||||||
class RegisterX
|
class RegisterX
|
||||||
|
|
||||||
object RegisterX:
|
object RegisterX:
|
||||||
given registerX: Reg[RegisterX] with
|
given Reg[RegisterX] with
|
||||||
def hello: Boolean =
|
def hello: Boolean =
|
||||||
true
|
true
|
||||||
|
|
||||||
class RegisterY
|
class RegisterY
|
||||||
|
|
||||||
object RegisterY:
|
object RegisterY:
|
||||||
given registerY: Reg[RegisterY] with
|
given Reg[RegisterY] with
|
||||||
def hello: Boolean =
|
def hello: Boolean =
|
||||||
true
|
true
|
||||||
|
@ -12,4 +12,4 @@ object Store:
|
|||||||
|
|
||||||
case class Byte[R, A](dest: WriteLease.ByteAddress[A])(using R: Register[R]) extends Asm2[R, A]:
|
case class Byte[R, A](dest: WriteLease.ByteAddress[A])(using R: Register[R]) extends Asm2[R, A]:
|
||||||
def xs: List[String] =
|
def xs: List[String] =
|
||||||
List("ST" + R.name)
|
List(R.store)
|
||||||
|
@ -14,13 +14,13 @@ package object syntax:
|
|||||||
summon[Loadable[Addr]].show(x)
|
summon[Loadable[Addr]].show(x)
|
||||||
|
|
||||||
val register =
|
val register =
|
||||||
summon[Register[R]].name
|
summon[Register[R]]
|
||||||
|
|
||||||
val loadInstruction =
|
val loadInstruction =
|
||||||
"LD" + register // TODO load action needs to interact with encoder
|
register.load // TODO load action needs to interact with encoder
|
||||||
|
|
||||||
val storeInstruction =
|
val storeInstruction =
|
||||||
"ST" + register // TODO store action needs to interact with encoder
|
register.store // TODO store action needs to interact with encoder
|
||||||
|
|
||||||
val first =
|
val first =
|
||||||
s"$loadInstruction $literal"
|
s"$loadInstruction $literal"
|
||||||
@ -29,6 +29,6 @@ package object syntax:
|
|||||||
s"$storeInstruction ${reg.n.toString}"
|
s"$storeInstruction ${reg.n.toString}"
|
||||||
|
|
||||||
val desc =
|
val desc =
|
||||||
s"${reg.alias} = $literal, via $register"
|
s"${reg.alias} = $literal, via ${register.name}"
|
||||||
|
|
||||||
s"$first $second ; $desc"
|
s"$first $second ; $desc"
|
||||||
|
@ -15,17 +15,18 @@ object ComplicatedResourceSuite extends FunSuite:
|
|||||||
class PlayerOne extends Player[PlayerOne](40)
|
class PlayerOne extends Player[PlayerOne](40)
|
||||||
|
|
||||||
object PlayerOne extends PlayerOne:
|
object PlayerOne extends PlayerOne:
|
||||||
given write: WriteLease[PlayerOne] with
|
given WriteLease[PlayerOne] with
|
||||||
def canon: PlayerOne =
|
def canon: PlayerOne =
|
||||||
PlayerOne
|
PlayerOne
|
||||||
|
|
||||||
class PlayerTwo extends Player[PlayerTwo](80)
|
class PlayerTwo extends Player[PlayerTwo](80)
|
||||||
|
|
||||||
object PlayerTwo extends PlayerTwo:
|
object PlayerTwo extends PlayerTwo:
|
||||||
given write: WriteLease[PlayerTwo] with
|
given WriteLease[PlayerTwo] with
|
||||||
def canon: PlayerTwo =
|
def canon: PlayerTwo =
|
||||||
PlayerTwo
|
PlayerTwo
|
||||||
|
|
||||||
test("use write lease") {
|
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