diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-02-02 23:25:15 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-02-02 23:29:46 +0100 |
| commit | f8230328065eb4049292b15d109b369e2e89746a (patch) | |
| tree | d80d1eef4df4f0806073451bd03186cbd037181d /crates/nasm | |
| parent | 31dd071e927ab4375db6c408c08ab776e4a5c655 (diff) | |
| download | tools.nes-f8230328065eb4049292b15d109b369e2e89746a.tar.gz tools.nes-f8230328065eb4049292b15d109b369e2e89746a.zip | |
nasm: add the --prelude flag
This flag prints to the standard output some helper code that bridges
nasm-exclusive features with ca65.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'crates/nasm')
| -rw-r--r-- | crates/nasm/src/main.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs index 64e88ed..923f89e 100644 --- a/crates/nasm/src/main.rs +++ b/crates/nasm/src/main.rs @@ -32,6 +32,7 @@ fn print_help() { println!(" -D <NAME>(=VALUE)\tDefine an 8-bit variable on the global scope (default: 1)"); println!(" -h, --help\t\tPrint this message."); println!(" -o, --out <FILE>\tFile path where the output should be located after execution."); + println!(" --prelude\t\tPrint the 'prelude' file; a file that can be used for defining default implementations for nasm-only features."); println!(" -s, --stats\t\tPrint the statistics on the final layout of segments and memory."); println!(" --stdout\t\tPrint the output binary to the standard output."); println!(" -v, --version\t\tPrint the version of this program."); @@ -42,6 +43,22 @@ fn print_help() { std::process::exit(0); } +// Print the 'prelude' file, which is a file that provides default +// implementations for nasm-only control statements. These implementations do +// not strive to make things complete in all ways, but at least with this +// another compiler will produce the same binary as nasm. +fn print_prelude() { + println!( + r#";; The __fallthrough__ special statement allows developers to explicitly tell +;; the assembler that a "fall through" situation does not happen by mistake. +.macro __fallthrough__ arg + ;; NOTE: nothing to do :) +.endmacro"# + ); + + std::process::exit(0); +} + // Parse a value from the '-D' flag which is expected to be 'NAME(=VALUE)'. fn parse_define(arg: &str) -> (String, u8) { let mut key_value = arg.split('='); @@ -99,6 +116,7 @@ fn parse_arguments() -> Args { None => die("you need to provide a value for the '-D' flag".to_string()), }, "-h" | "--help" => print_help(), + "--prelude" => print_prelude(), "-o" | "--out" => match res.out { Some(_) => die("only specify the '-o/--out' flag once".to_string()), None => { |
