mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-09-29 03:56:32 +00:00
add definition literal support
This commit is contained in:
parent
9b60d46e03
commit
45af484839
@ -11,6 +11,9 @@ object ZeroAddress {
|
|||||||
def toShow(x: ZeroAddress): String =
|
def toShow(x: ZeroAddress): String =
|
||||||
String.format("global address 0x%02x", x.n)
|
String.format("global address 0x%02x", x.n)
|
||||||
|
|
||||||
|
def toDefinitionLiteral(x: ZeroAddress): String =
|
||||||
|
toAddressLiteral(x)
|
||||||
|
|
||||||
def toAddressLiteral(x: ZeroAddress): String =
|
def toAddressLiteral(x: ZeroAddress): String =
|
||||||
String.format("$%02x", x.n)
|
String.format("$%02x", x.n)
|
||||||
}
|
}
|
||||||
@ -27,6 +30,9 @@ object GlobalAddress {
|
|||||||
def toShow(x: GlobalAddress): String =
|
def toShow(x: GlobalAddress): String =
|
||||||
String.format("global address 0x%04x", x.n)
|
String.format("global address 0x%04x", x.n)
|
||||||
|
|
||||||
|
def toDefinitionLiteral(x: GlobalAddress): String =
|
||||||
|
toAddressLiteral(x)
|
||||||
|
|
||||||
def toAddressLiteral(x: GlobalAddress): String =
|
def toAddressLiteral(x: GlobalAddress): String =
|
||||||
String.format("$%04x", x.n)
|
String.format("$%04x", x.n)
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class DefinitionGroupContext {
|
|||||||
case class Definition[A: Operand](name: String, x: A) {
|
case class Definition[A: Operand](name: String, x: A) {
|
||||||
lazy val value: String =
|
lazy val value: String =
|
||||||
implicitly[Operand[A]]
|
implicitly[Operand[A]]
|
||||||
.toAddressLiteral(x)
|
.toDefinitionLiteral(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsmBlockContext {
|
class AsmBlockContext {
|
||||||
|
@ -9,6 +9,8 @@ trait Operand[A] {
|
|||||||
|
|
||||||
def operandType: OperandType
|
def operandType: OperandType
|
||||||
|
|
||||||
|
def toDefinitionLiteral(x: A): String
|
||||||
|
|
||||||
def contra[B](f: B => A, show: B => String): Operand[B] =
|
def contra[B](f: B => A, show: B => String): Operand[B] =
|
||||||
new Operand[B] {
|
new Operand[B] {
|
||||||
val operandType: OperandType =
|
val operandType: OperandType =
|
||||||
@ -17,6 +19,9 @@ trait Operand[A] {
|
|||||||
def toShow(x: B): String =
|
def toShow(x: B): String =
|
||||||
show(x)
|
show(x)
|
||||||
|
|
||||||
|
def toDefinitionLiteral(x: B): String =
|
||||||
|
toAddressLiteral(x)
|
||||||
|
|
||||||
def toAddressLiteral(x: B): String =
|
def toAddressLiteral(x: B): String =
|
||||||
self.toAddressLiteral(f(x))
|
self.toAddressLiteral(f(x))
|
||||||
}
|
}
|
||||||
@ -31,6 +36,9 @@ object Operand {
|
|||||||
def toShow(x: Int): String =
|
def toShow(x: Int): String =
|
||||||
x.toString
|
x.toString
|
||||||
|
|
||||||
|
def toDefinitionLiteral(x: Int): String =
|
||||||
|
x.toString
|
||||||
|
|
||||||
def toAddressLiteral(x: Int): String =
|
def toAddressLiteral(x: Int): String =
|
||||||
String.format("#$%02x", x)
|
String.format("#$%02x", x)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user