mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-12-30 14:29:48 +00:00
with instructions
This commit is contained in:
parent
54ffb91104
commit
7bae8fef9a
@ -5,5 +5,19 @@
|
||||
|
||||
; Change direction: W A S D
|
||||
|
||||
lda $00
|
||||
lda $01 ; instruction comment
|
||||
|
||||
; this block has some preamble
|
||||
lda $00
|
||||
lda $01 ; instruction comment
|
||||
|
||||
labeled:
|
||||
; This is a subroutine description
|
||||
|
||||
lda $00
|
||||
lda $01 ; instruction comment
|
||||
|
||||
; this block has some preamble
|
||||
lda $00
|
||||
lda $01 ; instruction comment
|
||||
|
@ -39,15 +39,15 @@ object PrintPrograms extends ZIOAppDefault:
|
||||
AsmBlock.Intent(
|
||||
None,
|
||||
List(
|
||||
AsmBlock.Intent.Instruction("hello", None),
|
||||
AsmBlock.Intent.Instruction("world", "instruction comment".some)
|
||||
AsmBlock.Intent.Instruction("lda $00", None),
|
||||
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
||||
)
|
||||
),
|
||||
AsmBlock.Intent(
|
||||
"this block has some preamble".some,
|
||||
List(
|
||||
AsmBlock.Intent.Instruction("hello", None),
|
||||
AsmBlock.Intent.Instruction("world", "instruction comment".some)
|
||||
AsmBlock.Intent.Instruction("lda $00", None),
|
||||
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -59,15 +59,15 @@ object PrintPrograms extends ZIOAppDefault:
|
||||
AsmBlock.Intent(
|
||||
None,
|
||||
List(
|
||||
AsmBlock.Intent.Instruction("hello", None),
|
||||
AsmBlock.Intent.Instruction("world", "instruction comment".some)
|
||||
AsmBlock.Intent.Instruction("lda $00", None),
|
||||
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
||||
)
|
||||
),
|
||||
AsmBlock.Intent(
|
||||
"this block has some preamble".some,
|
||||
List(
|
||||
AsmBlock.Intent.Instruction("hello", None),
|
||||
AsmBlock.Intent.Instruction("world", "instruction comment".some)
|
||||
AsmBlock.Intent.Instruction("lda $00", None),
|
||||
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -24,25 +24,35 @@ object AsmBlock:
|
||||
Paragraph(ys.map(toComment))
|
||||
)
|
||||
|
||||
case NamedCodeBlock(label, oComment, _) =>
|
||||
case NamedCodeBlock(label, oComment, intents) =>
|
||||
val headerParagraph =
|
||||
Paragraph(
|
||||
List(label + ":") ++ oComment.map(toComment).map(withIndent).toList
|
||||
)
|
||||
|
||||
val intentParagraphs =
|
||||
Nil
|
||||
intents
|
||||
.map(Intent.toParagraph)
|
||||
|
||||
headerParagraph :: intentParagraphs
|
||||
|
||||
case AnonymousCodeBlock(_) =>
|
||||
Nil
|
||||
case AnonymousCodeBlock(intents) =>
|
||||
intents
|
||||
.map(Intent.toParagraph)
|
||||
|
||||
case class Intent(label: Option[String], instructions: List[Intent.Instruction])
|
||||
|
||||
object Intent:
|
||||
case class Instruction(code: String, comment: Option[String])
|
||||
|
||||
def toParagraph(x: Intent): Paragraph =
|
||||
Paragraph(
|
||||
x.label.map(toComment).map(withIndent).toList ++ x
|
||||
.instructions
|
||||
.map(i => i.code + i.comment.map(toComment).map(" " + _).getOrElse(" "))
|
||||
.map(withIndent)
|
||||
)
|
||||
|
||||
object CommentBlock:
|
||||
def fromMultiline(s: String): CommentBlock =
|
||||
CommentBlock(s.split("\\n").toList)
|
||||
|
Loading…
Reference in New Issue
Block a user