mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-02-07 22:31:10 +00:00
operand kinda
This commit is contained in:
parent
3f5f6e309d
commit
d42ed22153
@ -25,4 +25,16 @@ object Operand {
|
||||
def toAddressLiteral(x: Int): String =
|
||||
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
|
||||
|
||||
//import com.htmlism.mos6502.model._
|
||||
import com.htmlism.mos6502.model._
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
case class ReadWriteLocation[A](name: String, address: ZeroAddress) {
|
||||
case class ReadWriteLocation[A: Operand](name: String, address: ZeroAddress) {
|
||||
def read(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = ctx
|
||||
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||
}
|
||||
|
||||
def write(x: A)(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = (x, ctx)
|
||||
// ctx.push(STA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||
ctx.push(LDA, x)
|
||||
ctx.push(STA, address) // should be named address
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user