mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-08-09 23:24:59 +00:00
operand kinda
This commit is contained in:
@@ -25,4 +25,16 @@ object Operand {
|
|||||||
def toAddressLiteral(x: Int): String =
|
def toAddressLiteral(x: Int): String =
|
||||||
String.format("#$%02x", x)
|
String.format("#$%02x", x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implicit def operandForMapping[A](implicit ev: Mapping[A]): Operand[A] =
|
||||||
|
new Operand[A] {
|
||||||
|
def toAddressLiteral(x: A): String =
|
||||||
|
"#" + ev.label(x)
|
||||||
|
|
||||||
|
def toShow(x: A): String =
|
||||||
|
ev.label(x)
|
||||||
|
|
||||||
|
def operandType: OperandType =
|
||||||
|
ValueLiteral
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +1,21 @@
|
|||||||
package com.htmlism.mos6502.dsl
|
package com.htmlism.mos6502.dsl
|
||||||
|
|
||||||
//import com.htmlism.mos6502.model._
|
import com.htmlism.mos6502.model._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name A name for this location, used to alias its address
|
* @param name A name for this location, used to alias its address
|
||||||
*
|
*
|
||||||
* @tparam A The input type of the write and the output type of the read
|
* @tparam A The input type of the write and the output type of the read
|
||||||
*/
|
*/
|
||||||
case class ReadWriteLocation[A](name: String, address: ZeroAddress) {
|
case class ReadWriteLocation[A: Operand](name: String, address: ZeroAddress) {
|
||||||
def read(implicit ctx: AssemblyContext): Unit = {
|
def read(implicit ctx: AssemblyContext): Unit = {
|
||||||
val _ = ctx
|
val _ = ctx
|
||||||
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||||
}
|
}
|
||||||
|
|
||||||
def write(x: A)(implicit ctx: AssemblyContext): Unit = {
|
def write(x: A)(implicit ctx: AssemblyContext): Unit = {
|
||||||
val _ = (x, ctx)
|
ctx.push(LDA, x)
|
||||||
// ctx.push(STA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
ctx.push(STA, address) // should be named address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user