mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-12-22 09:30:45 +00:00
specify that resources are byte length
This commit is contained in:
parent
3a7f7b99a1
commit
7ac6d8f831
@ -9,7 +9,7 @@ trait Load[A]:
|
||||
Asm1Instructions(List(instruction))
|
||||
|
||||
// from register
|
||||
def from[B <: Address: ReadAddress]: Asm2Instructions[A, B] =
|
||||
def from[B <: Address: ReadByteAddress]: Asm2Instructions[A, B] =
|
||||
Asm2Instructions(List(instruction))
|
||||
|
||||
object Load:
|
||||
|
@ -9,12 +9,21 @@ class ZeroPageAddress(val n: Int, val alias: String) extends Address
|
||||
|
||||
class AbsoluteAddress(val n: Int, val alias: String) extends Address
|
||||
|
||||
sealed trait ReadAddress[A] extends Address
|
||||
sealed trait ReadByteAddress[A] extends Address
|
||||
|
||||
sealed trait WriteAddress[A] extends Address
|
||||
sealed trait WriteByteAddress[A] extends Address
|
||||
|
||||
trait Volatile[A] extends ReadAddress[A]
|
||||
/**
|
||||
* To be extended by the address companion object, to signify that this is a volatile resource of length byte
|
||||
*/
|
||||
trait VolatileByte[A] extends ReadByteAddress[A]
|
||||
|
||||
trait ReadWriteAddress[A] extends ReadAddress[A] with WriteAddress[A]
|
||||
/**
|
||||
* To be extended by the address companion object, to signify that this is a read/write resource of length byte
|
||||
*/
|
||||
trait ReadWriteByteAddress[A] extends ReadByteAddress[A] with WriteByteAddress[A]
|
||||
|
||||
trait WriteOnlyAddress[A] extends WriteAddress[A]
|
||||
/**
|
||||
* To be extended by the address companion object, to signify that this is a write-only resource of length byte
|
||||
*/
|
||||
trait WriteOnlyByteAddress[A] extends WriteByteAddress[A]
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.htmlism.scratchpad
|
||||
|
||||
package object syntax:
|
||||
implicit class WriteRegisterOps[Addr](reg: WriteAddress[Addr]):
|
||||
implicit class WriteRegisterOps[Addr](reg: WriteByteAddress[Addr]):
|
||||
def writeConst[A: Loadable](x: A): syntax.PartiallyAppliedWrite[A, Addr] =
|
||||
new syntax.PartiallyAppliedWrite(reg, x)
|
||||
|
||||
def writeFrom[R: Store]: Asm2[R, Addr] =
|
||||
StoreTo[R, Addr]()
|
||||
|
||||
class PartiallyAppliedWrite[Addr: Loadable, A](reg: WriteAddress[A], x: Addr):
|
||||
class PartiallyAppliedWrite[Addr: Loadable, A](reg: WriteByteAddress[A], x: Addr):
|
||||
def apply[R: Load: Store: Register]: String =
|
||||
val literal =
|
||||
summon[Loadable[Addr]].show(x)
|
||||
|
@ -5,7 +5,7 @@ import org.scalatest.matchers.should._
|
||||
|
||||
import com.htmlism.scratchpad.syntax._
|
||||
|
||||
object ExampleRegister extends ZeroPageAddress(0x01, "example") with WriteOnlyAddress[ExampleRegister]
|
||||
object ExampleRegister extends ZeroPageAddress(0x01, "example") with WriteOnlyByteAddress[ExampleRegister]
|
||||
|
||||
class ExampleRegister
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user