articulate device types

This commit is contained in:
Mark Canlas 2020-08-24 21:15:17 -04:00
parent b0e40b3e36
commit 4859ae575a
4 changed files with 34 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package com.htmlism.mos6502.dsl
sealed trait Address
sealed trait Address {
def n: Int
}
object ZeroAddress {
implicit val operandZero: Operand[ZeroAddress] =

View File

@ -0,0 +1,15 @@
package com.htmlism.mos6502.dsl
//import com.htmlism.mos6502.model._
case class ReadWriteDevice[A](address: Address) {
def read(implicit ctx: AssemblyContext): Unit = {
val _ = ctx
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
}
def write(implicit ctx: AssemblyContext): Unit = {
val _ = ctx
// ctx.push(STA, ev, s"write ${ev.toShow(x)} to $name ($n)")
}
}

View File

@ -0,0 +1,10 @@
package com.htmlism.mos6502.dsl
//import com.htmlism.mos6502.model._
case class VolatileDevice[A](address: Address) {
def read(implicit ctx: AssemblyContext): Unit = {
val _ = ctx
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
}
}

View File

@ -68,6 +68,9 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
}
"snake" should "compile" in {
val sysRandom = VolatileDevice[Int](0xfe.addr)
val sysLastKey = VolatileDevice[AsciiValue](0xff.addr)
val initSnake =
sub("initSnake") { implicit a =>
registers.X.incr
@ -130,6 +133,9 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
mapping[AsciiValue]
asm { implicit a =>
sysRandom.read
sysLastKey.read
jump(init)
jump(loop)
}