2020-08-16 06:28:37 +00:00
|
|
|
package com.htmlism.mos6502.dsl
|
|
|
|
package syntax
|
|
|
|
|
2023-10-03 20:15:10 +00:00
|
|
|
import com.htmlism.mos6502.model.*
|
2020-08-16 16:55:21 +00:00
|
|
|
|
2022-02-14 23:11:45 +00:00
|
|
|
trait AsmSyntax:
|
2023-06-19 09:30:17 +00:00
|
|
|
def label(s: String)(using ctx: AssemblyContext): Unit =
|
2020-08-16 06:28:37 +00:00
|
|
|
ctx
|
2020-08-16 15:33:49 +00:00
|
|
|
.label(s)
|
2020-08-16 16:55:21 +00:00
|
|
|
|
2022-02-14 23:11:45 +00:00
|
|
|
def sub(s: String)(f: AssemblyContext => Unit): Subroutine =
|
2020-08-16 16:55:21 +00:00
|
|
|
val ctx: AssemblyContext =
|
|
|
|
new AssemblyContext
|
|
|
|
|
|
|
|
f(ctx)
|
|
|
|
|
2020-08-21 09:06:09 +00:00
|
|
|
ctx.push(RTS)
|
|
|
|
|
2020-08-21 08:58:07 +00:00
|
|
|
Subroutine(s, ctx.toFragment, ctx.getJumps)
|
2020-08-16 16:55:21 +00:00
|
|
|
|
2023-06-19 09:30:17 +00:00
|
|
|
def jump(s: Subroutine)(using ctx: AssemblyContext): Unit =
|
2020-08-21 07:11:27 +00:00
|
|
|
ctx
|
|
|
|
.addJump(s)
|
|
|
|
|
2020-08-16 16:55:21 +00:00
|
|
|
ctx
|
|
|
|
.branch(JSR, s.name)
|