aboutsummaryrefslogtreecommitdiff
path: root/crates/nasm
diff options
context:
space:
mode:
Diffstat (limited to 'crates/nasm')
-rw-r--r--crates/nasm/src/main.rs18
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 => {