1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-08 08:55:38 +00:00

Language: raw asm { ... } blocks

raw asm {
        LDA #\$42
        STA \$00
    }

Unlike regular \`asm\`, \`raw asm\` does not perform \`{var}\`
substitution — the body is passed to the inline parser verbatim.
Useful for writing completely unmanaged bytes that don't rely on
the analyzer's variable allocations, e.g. mapper init snippets.

Implementation:
- Parser: \`KwRaw\` followed by \`KwAsm\` emits
  \`Statement::RawAsm(body, span)\`.
- IR lowering: prepends a \`\\0RAW\\0\` marker to the body when
  emitting \`IrOp::InlineAsm\` so the codegen can distinguish raw
  from regular without adding a second op variant.
- IR codegen: strips the marker and skips substitution when present.
- AST codegen: same, handling \`Statement::RawAsm\` directly.

https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
Claude 2026-04-12 17:34:17 +00:00
parent a283f87b79
commit a45944e0f9
No known key found for this signature in database
8 changed files with 82 additions and 16 deletions

View file

@ -322,6 +322,26 @@ fn program_with_enums() {
rom::validate_ines(&rom_data).expect("should be valid iNES");
}
#[test]
fn program_with_raw_asm_block() {
// `raw asm` bypasses `{var}` substitution so the body is passed
// to the inline parser unchanged.
let source = r#"
game "RawAsm" { mapper: NROM }
var x: u8 = 0
on frame {
raw asm {
LDA #$42
STA $00
}
wait_frame
}
start Main
"#;
let rom_data = compile(source);
rom::validate_ines(&rom_data).expect("should be valid iNES");
}
#[test]
fn program_with_inline_asm_variable_substitution() {
let source = r#"