mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-05-28 21:41:31 +00:00
consume meta intent jump
This commit is contained in:
parent
f1beb9a316
commit
bf3ad70090
|
@ -1,2 +1,3 @@
|
|||
JSR init
|
||||
|
||||
JSR loop
|
||||
|
|
|
@ -103,9 +103,12 @@ object AsmBlock:
|
|||
(code + " " + operand.getOrElse("")).length
|
||||
|
||||
object Instruction:
|
||||
def one(code: String, operand: String, comment: Option[String]): Instruction =
|
||||
def one(code: String, operand: String, comment: Option[String] = None): Instruction =
|
||||
Instruction(code, operand.some, comment)
|
||||
|
||||
def zero(code: String, comment: Option[String] = None): Instruction =
|
||||
Instruction(code, None, comment)
|
||||
|
||||
def toLines(opts: AssemblerOptions.InstructionCase)(x: Intent): List[String] =
|
||||
val comment =
|
||||
x.label.map(toComment).map(withIndent).toList
|
||||
|
|
|
@ -7,6 +7,12 @@ import com.htmlism.firepower.core.*
|
|||
sealed trait MetaIntent
|
||||
|
||||
object MetaIntent:
|
||||
case class Jump(target: String)
|
||||
|
||||
object Jump:
|
||||
def toIntent(j: Jump): AsmBlock.Intent =
|
||||
AsmBlock.Intent(None, List(AsmBlock.Intent.Instruction.one("jsr", j.target)))
|
||||
|
||||
case class Move[A: Definable, B: Definable](src: A, dest: B):
|
||||
def defines: List[Definable.Table] =
|
||||
List(
|
||||
|
|
|
@ -5,8 +5,8 @@ import cats.syntax.all.*
|
|||
import com.htmlism.firepower.core.AsmBlock._
|
||||
|
||||
case class Subroutine(name: String, intents: List[MetaIntent]):
|
||||
def call: Intent.Instruction =
|
||||
Intent.Instruction.one("jsr", name, None)
|
||||
def call: MetaIntent.Jump =
|
||||
MetaIntent.Jump(name)
|
||||
|
||||
def attach: NamedCodeBlock =
|
||||
NamedCodeBlock(name, "this is a named block".some, intents.map(_ => Intent("TODO".some, Nil)))
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.htmlism.firepower.core.AsmBlock.Intent
|
|||
import com.htmlism.firepower.core.*
|
||||
|
||||
object SnakeEasy6502:
|
||||
val program: List[Intent.Instruction] =
|
||||
val program: List[MetaIntent.Jump] =
|
||||
List(
|
||||
init.call,
|
||||
loop.call
|
||||
|
@ -21,11 +21,11 @@ object SnakeEasy6502:
|
|||
lazy val initSnake =
|
||||
Subroutine("initSnake")
|
||||
|
||||
def firstCodeBlock(xs: List[Intent.Instruction]): AsmBlock.AnonymousCodeBlock =
|
||||
def firstCodeBlock(xs: List[MetaIntent.Jump]): AsmBlock.AnonymousCodeBlock =
|
||||
AsmBlock
|
||||
.AnonymousCodeBlock(List(Intent(None, xs)))
|
||||
.AnonymousCodeBlock(xs.map(MetaIntent.Jump.toIntent))
|
||||
|
||||
def callGraph(xs: List[Intent.Instruction]): List[AsmBlock.NamedCodeBlock] =
|
||||
def callGraph(xs: List[MetaIntent.Jump]): List[AsmBlock.NamedCodeBlock] =
|
||||
Nil
|
||||
|
||||
def assemble(opts: AssemblerOptions): List[String] =
|
||||
|
|
Loading…
Reference in New Issue
Block a user