mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-06-26 01:29:31 +00:00
comments
This commit is contained in:
parent
ebb9588e04
commit
575b5710b7
|
@ -134,6 +134,8 @@ class AssemblyContext {
|
|||
xs.append(InstructionWithOperand(instruction, x: A, s.some))
|
||||
|
||||
def printOut(): Unit = {
|
||||
xs.foreach(println)
|
||||
xs
|
||||
.map(_.toAsm)
|
||||
.foreach(println)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ object GlobalAddress {
|
|||
|
||||
case class GlobalAddress(n: Int) {
|
||||
def write[A](x: A)(implicit ctx: AssemblyContext, ev: Operand[A]): Unit = {
|
||||
ctx.push(LDA, x, s"2: write value ${ev.toString(x)} to address $n")
|
||||
ctx.push(STA, this)
|
||||
ctx.push(LDA, x, s"write value ${ev.toString(x)} to address $n")
|
||||
ctx.push(STA, this, "")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,37 @@ package com.htmlism.mos6502.dsl
|
|||
|
||||
import com.htmlism._
|
||||
|
||||
sealed trait Statement
|
||||
sealed trait Statement {
|
||||
def toAsm: String
|
||||
}
|
||||
|
||||
case class UnaryInstruction(instruction: Instruction, comment: Option[String]) extends Statement
|
||||
case class UnaryInstruction(instruction: Instruction, comment: Option[String]) extends Statement {
|
||||
def toAsm: String = {
|
||||
val left =
|
||||
instruction.toString
|
||||
|
||||
case class InstructionWithOperand[A : Operand](instruction: Instruction, operand: A, comment: Option[String]) extends Statement
|
||||
comment match {
|
||||
case Some(c) =>
|
||||
f"$left%-16s ; " + c
|
||||
case None =>
|
||||
left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case class InstructionWithOperand[A](instruction: Instruction, operand: A, comment: Option[String])(implicit ev: Operand[A]) extends Statement {
|
||||
def toAsm: String = {
|
||||
val left =
|
||||
instruction.toString
|
||||
|
||||
val operandStr =
|
||||
ev.toString(operand)
|
||||
|
||||
comment match {
|
||||
case Some(c) =>
|
||||
f"$left%-5s $operandStr%-11s; " + c
|
||||
case None =>
|
||||
f"$left%-5s $operandStr"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user