mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-12-23 01:29:47 +00:00
resource as named operand
This commit is contained in:
parent
d42ed22153
commit
5fe085e09a
@ -15,11 +15,23 @@ case class ReadWriteLocation[A: Operand](name: String, address: ZeroAddress) {
|
||||
|
||||
def write(x: A)(implicit ctx: AssemblyContext): Unit = {
|
||||
ctx.push(LDA, x)
|
||||
ctx.push(STA, address) // should be named address
|
||||
ctx.push(STA, this)
|
||||
}
|
||||
}
|
||||
|
||||
object ReadWriteLocation {
|
||||
implicit def operandForReadWriteLocation[A]: Operand[ReadWriteLocation[A]] =
|
||||
new Operand[ReadWriteLocation[A]] {
|
||||
def toAddressLiteral(x: ReadWriteLocation[A]): String =
|
||||
x.name
|
||||
|
||||
def toShow(x: ReadWriteLocation[A]): String =
|
||||
x.name
|
||||
|
||||
def operandType: OperandType =
|
||||
MemoryLocation
|
||||
}
|
||||
|
||||
implicit def namedResourceForReadWriteLocation[A]: NamedResource[ReadWriteLocation[A]] =
|
||||
new NamedResource[ReadWriteLocation[A]] {
|
||||
def toDefinitions(x: ReadWriteLocation[A]): List[Definition[ZeroAddress]] =
|
||||
|
@ -78,8 +78,7 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
|
||||
val initSnake =
|
||||
sub("initSnake") { implicit a =>
|
||||
snakeDirection.write(Right)
|
||||
|
||||
snakeLength.read
|
||||
snakeLength.write(4) // 2 * 2
|
||||
}
|
||||
|
||||
val generateApplePosition =
|
||||
|
Loading…
Reference in New Issue
Block a user