From f3247a0007a6c04955b1626e22a75b9a47bdd46d Mon Sep 17 00:00:00 2001 From: hlorenzi Date: Sun, 18 Jun 2023 21:56:45 -0300 Subject: [PATCH] add command-line defines --- src/asm/mod.rs | 54 +++++++++++ src/asm/resolver/constant.rs | 14 +++ src/driver.rs | 94 +++++++++++++++++++ src/expr/expression.rs | 6 ++ src/expr/parser.rs | 2 +- src/syntax/excerpt.rs | 20 ++-- src/test/file.rs | 2 +- src/usage_help.md | 12 ++- tests/driver/err_define_invalid/main.asm | 10 ++ tests/driver/err_define_invalid_name/main.asm | 10 ++ .../driver/err_define_invalid_value/main.asm | 10 ++ .../driver/err_define_no_declaration/main.asm | 8 ++ tests/driver/err_define_unused/main.asm | 10 ++ tests/driver/ok_define_if1/err_no_define.asm | 3 + tests/driver/ok_define_if1/include.asm | 18 ++++ tests/driver/ok_define_if1/ok_variant0.asm | 4 + tests/driver/ok_define_if1/ok_variant1.asm | 4 + tests/driver/ok_define_if1/ok_variant2.asm | 4 + tests/driver/ok_define_if1/ok_variant3.asm | 4 + tests/driver/ok_define_if1/out_variant0.txt | 1 + tests/driver/ok_define_if1/out_variant1.txt | 1 + tests/driver/ok_define_if1/out_variant2.txt | 1 + tests/driver/ok_define_if1/out_variant3.txt | 1 + tests/driver/ok_define_if2/include.asm | 10 ++ .../driver/ok_define_if2/ok_variant_false.asm | 4 + .../ok_define_if2/ok_variant_novalue.asm | 4 + .../ok_define_if2/ok_variant_omitted.asm | 4 + .../driver/ok_define_if2/ok_variant_true.asm | 4 + .../ok_define_if2/out_variant_false.txt | 1 + .../ok_define_if2/out_variant_novalue.txt | 1 + .../ok_define_if2/out_variant_omitted.txt | 1 + .../driver/ok_define_if2/out_variant_true.txt | 1 + tests/driver/ok_define_nested/main.asm | 18 ++++ tests/driver/ok_define_nested/out.txt | 1 + .../driver/ok_define_simple_novalue/main.asm | 12 +++ tests/driver/ok_define_simple_novalue/out.txt | 1 + tests/driver/ok_define_simple_value/main.asm | 16 ++++ tests/driver/ok_define_simple_value/out.txt | 1 + 38 files changed, 360 insertions(+), 12 deletions(-) create mode 100644 tests/driver/err_define_invalid/main.asm create mode 100644 tests/driver/err_define_invalid_name/main.asm create mode 100644 tests/driver/err_define_invalid_value/main.asm create mode 100644 tests/driver/err_define_no_declaration/main.asm create mode 100644 tests/driver/err_define_unused/main.asm create mode 100644 tests/driver/ok_define_if1/err_no_define.asm create mode 100644 tests/driver/ok_define_if1/include.asm create mode 100644 tests/driver/ok_define_if1/ok_variant0.asm create mode 100644 tests/driver/ok_define_if1/ok_variant1.asm create mode 100644 tests/driver/ok_define_if1/ok_variant2.asm create mode 100644 tests/driver/ok_define_if1/ok_variant3.asm create mode 100644 tests/driver/ok_define_if1/out_variant0.txt create mode 100644 tests/driver/ok_define_if1/out_variant1.txt create mode 100644 tests/driver/ok_define_if1/out_variant2.txt create mode 100644 tests/driver/ok_define_if1/out_variant3.txt create mode 100644 tests/driver/ok_define_if2/include.asm create mode 100644 tests/driver/ok_define_if2/ok_variant_false.asm create mode 100644 tests/driver/ok_define_if2/ok_variant_novalue.asm create mode 100644 tests/driver/ok_define_if2/ok_variant_omitted.asm create mode 100644 tests/driver/ok_define_if2/ok_variant_true.asm create mode 100644 tests/driver/ok_define_if2/out_variant_false.txt create mode 100644 tests/driver/ok_define_if2/out_variant_novalue.txt create mode 100644 tests/driver/ok_define_if2/out_variant_omitted.txt create mode 100644 tests/driver/ok_define_if2/out_variant_true.txt create mode 100644 tests/driver/ok_define_nested/main.asm create mode 100644 tests/driver/ok_define_nested/out.txt create mode 100644 tests/driver/ok_define_simple_novalue/main.asm create mode 100644 tests/driver/ok_define_simple_novalue/out.txt create mode 100644 tests/driver/ok_define_simple_value/main.asm create mode 100644 tests/driver/ok_define_simple_value/out.txt diff --git a/src/asm/mod.rs b/src/asm/mod.rs index 6d5f8169..a064d3ef 100644 --- a/src/asm/mod.rs +++ b/src/asm/mod.rs @@ -95,6 +95,15 @@ pub struct AssemblyOptions pub debug_iterations: bool, pub optimize_statically_known: bool, pub optimize_instruction_matching: bool, + + pub driver_symbol_defs: Vec, +} + + +pub struct DriverSymbolDef +{ + pub name: String, + pub value: expr::Value, } @@ -123,6 +132,8 @@ impl AssemblyOptions debug_iterations: false, optimize_statically_known: true, optimize_instruction_matching: true, + + driver_symbol_defs: Vec::new(), } } } @@ -230,6 +241,11 @@ pub fn assemble( assembly.decls.as_ref().unwrap(), assembly.defs.as_ref().unwrap())?); + check_unused_defines( + report, + opts, + assembly.decls.as_ref().unwrap())?; + Ok(()) }; @@ -244,4 +260,42 @@ pub fn assemble( } assembly +} + + +fn check_unused_defines( + report: &mut diagn::Report, + opts: &asm::AssemblyOptions, + decls: &asm::ItemDecls) + -> Result<(), ()> +{ + let mut had_error = false; + + for symbol_def in &opts.driver_symbol_defs + { + let hierarchy = symbol_def.name + .split(".") + .collect::>(); + + let maybe_decl = decls.symbols.try_get_by_name( + &util::SymbolContext::new_global(), + 0, + &hierarchy); + + if let None = maybe_decl + { + report.error( + format!( + "unused define `{}`", + symbol_def.name)); + + had_error = true; + } + } + + match had_error + { + false => Ok(()), + true => Err(()), + } } \ No newline at end of file diff --git a/src/asm/resolver/constant.rs b/src/asm/resolver/constant.rs index b7d5ade7..db834a84 100644 --- a/src/asm/resolver/constant.rs +++ b/src/asm/resolver/constant.rs @@ -62,6 +62,20 @@ fn resolve_constant_simple( let asm::AstSymbolKind::Constant(ref ast_const) = ast_symbol.kind else { unreachable!() }; + + // Overwrite with a value from the command-line, if present + let symbol_decl = decls.symbols.get(item_ref); + if let Some(driver_def) = opts.driver_symbol_defs + .iter() + .find(|s| s.name == symbol_decl.name) + { + let symbol = defs.symbols.get_mut(item_ref); + symbol.value = driver_def.value.clone(); + symbol.resolved = true; + return Ok(asm::ResolutionState::Resolved); + } + + let value = asm::resolver::eval_simple( report, decls, diff --git a/src/driver.rs b/src/driver.rs index 7e88ab11..6df7f106 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -242,6 +242,13 @@ fn make_opts() -> getopts::Options "q", "quiet", "Suppress progress reports."); + opts.opt( + "d", "define", + "Defines a constant.", + "VALUE", + getopts::HasArg::Yes, + getopts::Occur::Multi); + opts.opt( "", "color", "Style the output with colors. [on/off]", @@ -337,6 +344,14 @@ fn parse_command( command.show_version |= parsed.opt_present("v"); command.show_help |= parsed.opt_present("h"); + for define_arg in parsed.opt_strs("d") + { + command.opts.driver_symbol_defs.push( + parse_define_arg( + report, + &define_arg)?); + } + command.opts.debug_iterations |= parsed.opt_present("debug-iters"); @@ -619,6 +634,85 @@ pub fn parse_output_format( } +fn parse_define_arg( + report: &mut diagn::Report, + raw_str: &str) + -> Result +{ + let split = raw_str + .split('=') + .collect::>(); + + let name = split[0].to_string(); + + if split.len() == 1 + { + return Ok(asm::DriverSymbolDef { + name, + value: expr::Value::make_bool(true), + }); + } + + if split.len() != 2 + { + report.error( + format!( + "invalid define argument `{}`", + raw_str)); + + return Err(()); + } + + let value_str = split[1]; + + let value = { + if value_str == "true" + { + expr::Value::make_bool(true) + } + else if value_str == "false" + { + expr::Value::make_bool(false) + } + else + { + let has_negative_sign = split[1].chars().next() == Some('-'); + + let maybe_value = syntax::excerpt_as_bigint( + None, + diagn::Span::new_dummy(), + if has_negative_sign { split[1].get(1..).unwrap() } else { split[1] }); + + + use std::ops::Neg; + + match maybe_value + { + Ok(value) => + expr::Value::make_integer( + if has_negative_sign { value.neg() } else { value }), + + Err(()) => + { + report.error( + format!( + "invalid value for define `{}`", + name)); + + return Err(()); + } + } + } + }; + + + Ok(asm::DriverSymbolDef { + name, + value, + }) +} + + pub fn format_output( fileserver: &dyn util::FileServer, decls: &asm::ItemDecls, diff --git a/src/expr/expression.rs b/src/expr/expression.rs index a46312a2..cee416f9 100644 --- a/src/expr/expression.rs +++ b/src/expr/expression.rs @@ -129,6 +129,12 @@ impl Value } + pub fn make_bool(value: bool) -> Value + { + Value::Bool(value) + } + + pub fn make_string, S: Into>(value: T, encoding: S) -> Value { Value::String(ExprString diff --git a/src/expr/parser.rs b/src/expr/parser.rs index a25bda0e..1f4360a2 100644 --- a/src/expr/parser.rs +++ b/src/expr/parser.rs @@ -574,7 +574,7 @@ impl<'a, 'tokens> ExpressionParser<'a, 'tokens> let number = tk_number.excerpt.clone().unwrap(); let bigint = syntax::excerpt_as_bigint( - self.report, + Some(self.report), tk_number.span, &number)?; diff --git a/src/syntax/excerpt.rs b/src/syntax/excerpt.rs index f921cdec..97ab18a1 100644 --- a/src/syntax/excerpt.rs +++ b/src/syntax/excerpt.rs @@ -169,7 +169,7 @@ pub fn excerpt_as_usize( pub fn excerpt_as_bigint( - report: &mut diagn::Report, + report: Option<&mut diagn::Report>, span: diagn::Span, excerpt: &str) -> Result @@ -195,9 +195,12 @@ pub fn excerpt_as_bigint( Some(d) => d, None => { - report.error_span( - "invalid digits", - span); + if let Some(report) = report + { + report.error_span( + "invalid digits", + span); + } return Err(()); } @@ -211,9 +214,12 @@ pub fn excerpt_as_bigint( if digit_num == 0 { - report.error_span( - "invalid value", - span); + if let Some(report) = report + { + report.error_span( + "invalid value", + span); + } return Err(()); } diff --git a/src/test/file.rs b/src/test/file.rs index c7980520..43e56844 100644 --- a/src/test/file.rs +++ b/src/test/file.rs @@ -49,7 +49,7 @@ pub fn extract_expectations( { let value = syntax::excerpt_as_bigint( - &mut diagn::Report::new(), + None, diagn::Span::new_dummy(), value_str) .unwrap(); diff --git a/src/usage_help.md b/src/usage_help.md index ae4854cb..f88d4192 100644 --- a/src/usage_help.md +++ b/src/usage_help.md @@ -22,9 +22,15 @@ Examples: * `-h, --help` Display this information. * `-t, --iters=NUM` - The max number of resolution iterations to attempt. (Default: 10) + The maximum number of resolution iterations to attempt. + (Default: 10) +* `-dNAME, --define=NAME` +* `-dNAME=VALUE, --define=NAME=VALUE` + Overwrites a constant definition with the given value, + or `true` if none is given. * `--color=on/off` - Whether to style the output with colors. (Default: on) + Whether to style the output with colors. + (Default: on) * `--debug-iters` Print debug info during resolution iterations. * `--debug-no-optimize-static` @@ -54,7 +60,7 @@ Examples: * `binary` * `annotated,base:16,group:2` - Annotate the output data with snippets + Annotates the output data with snippets of the source code. * `annotatedbin` diff --git a/tests/driver/err_define_invalid/main.asm b/tests/driver/err_define_invalid/main.asm new file mode 100644 index 00000000..9a9fbd7a --- /dev/null +++ b/tests/driver/err_define_invalid/main.asm @@ -0,0 +1,10 @@ +#ruledef test +{ + ld {x: u8} => 0x55 @ x +} + +val = 0 +ld val + +; command: main.asm -o out.bin -dval=abc=123 +; error: invalid define argument `val=abc=123` \ No newline at end of file diff --git a/tests/driver/err_define_invalid_name/main.asm b/tests/driver/err_define_invalid_name/main.asm new file mode 100644 index 00000000..261d144f --- /dev/null +++ b/tests/driver/err_define_invalid_name/main.asm @@ -0,0 +1,10 @@ +#ruledef test +{ + ld {x: u8} => 0x55 @ x +} + +val = 0 +ld val + +; command: main.asm -o out.bin -d123=123 +; error: unused define `123` \ No newline at end of file diff --git a/tests/driver/err_define_invalid_value/main.asm b/tests/driver/err_define_invalid_value/main.asm new file mode 100644 index 00000000..9290acb5 --- /dev/null +++ b/tests/driver/err_define_invalid_value/main.asm @@ -0,0 +1,10 @@ +#ruledef test +{ + ld {x: u8} => 0x55 @ x +} + +val = 0 +ld val + +; command: main.asm -o out.bin -dval=abc +; error: invalid value for define `val` \ No newline at end of file diff --git a/tests/driver/err_define_no_declaration/main.asm b/tests/driver/err_define_no_declaration/main.asm new file mode 100644 index 00000000..226ca97a --- /dev/null +++ b/tests/driver/err_define_no_declaration/main.asm @@ -0,0 +1,8 @@ +#ruledef test +{ + ld {x: u8} => 0x55 @ x +} + +ld val ; error: failed / note:_:3: within / error: unknown symbol `val` + +; command: main.asm -o out.bin -dval \ No newline at end of file diff --git a/tests/driver/err_define_unused/main.asm b/tests/driver/err_define_unused/main.asm new file mode 100644 index 00000000..f80e3740 --- /dev/null +++ b/tests/driver/err_define_unused/main.asm @@ -0,0 +1,10 @@ +#ruledef test +{ + ld {x: u8} => 0x55 @ x +} + +val = 0 +ld val + +; command: main.asm -o out.bin -dvalue=0x55 +; error: unused define `value` \ No newline at end of file diff --git a/tests/driver/ok_define_if1/err_no_define.asm b/tests/driver/ok_define_if1/err_no_define.asm new file mode 100644 index 00000000..6ff83b2b --- /dev/null +++ b/tests/driver/ok_define_if1/err_no_define.asm @@ -0,0 +1,3 @@ +#include "include.asm" ; error:include.asm:5: invalid argument types + +; command: err_no_define.asm -o out.bin \ No newline at end of file diff --git a/tests/driver/ok_define_if1/include.asm b/tests/driver/ok_define_if1/include.asm new file mode 100644 index 00000000..1c17ba16 --- /dev/null +++ b/tests/driver/ok_define_if1/include.asm @@ -0,0 +1,18 @@ +#d 0xaa + +variant = {} + +#if variant == 0 +{ + #d 0x00 +} +#elif variant == 1 +{ + #d 0x11 +} +#elif variant == 2 +{ + #d 0x22 +} + +#d 0xff \ No newline at end of file diff --git a/tests/driver/ok_define_if1/ok_variant0.asm b/tests/driver/ok_define_if1/ok_variant0.asm new file mode 100644 index 00000000..57f17db6 --- /dev/null +++ b/tests/driver/ok_define_if1/ok_variant0.asm @@ -0,0 +1,4 @@ +#include "include.asm" + +; command: ok_variant0.asm -fhexstr -o out_variant0.txt -dvariant=0 +; output: out_variant0.txt \ No newline at end of file diff --git a/tests/driver/ok_define_if1/ok_variant1.asm b/tests/driver/ok_define_if1/ok_variant1.asm new file mode 100644 index 00000000..c198491c --- /dev/null +++ b/tests/driver/ok_define_if1/ok_variant1.asm @@ -0,0 +1,4 @@ +#include "include.asm" + +; command: ok_variant1.asm -fhexstr -o out_variant1.txt -dvariant=1 +; output: out_variant1.txt \ No newline at end of file diff --git a/tests/driver/ok_define_if1/ok_variant2.asm b/tests/driver/ok_define_if1/ok_variant2.asm new file mode 100644 index 00000000..2e586769 --- /dev/null +++ b/tests/driver/ok_define_if1/ok_variant2.asm @@ -0,0 +1,4 @@ +#include "include.asm" + +; command: ok_variant2.asm -fhexstr -o out_variant2.txt -dvariant=2 +; output: out_variant2.txt \ No newline at end of file diff --git a/tests/driver/ok_define_if1/ok_variant3.asm b/tests/driver/ok_define_if1/ok_variant3.asm new file mode 100644 index 00000000..59485676 --- /dev/null +++ b/tests/driver/ok_define_if1/ok_variant3.asm @@ -0,0 +1,4 @@ +#include "include.asm" + +; command: ok_variant3.asm -fhexstr -o out_variant3.txt -dvariant=555 +; output: out_variant3.txt \ No newline at end of file diff --git a/tests/driver/ok_define_if1/out_variant0.txt b/tests/driver/ok_define_if1/out_variant0.txt new file mode 100644 index 00000000..4d03318b --- /dev/null +++ b/tests/driver/ok_define_if1/out_variant0.txt @@ -0,0 +1 @@ +aa00ff \ No newline at end of file diff --git a/tests/driver/ok_define_if1/out_variant1.txt b/tests/driver/ok_define_if1/out_variant1.txt new file mode 100644 index 00000000..1c469aab --- /dev/null +++ b/tests/driver/ok_define_if1/out_variant1.txt @@ -0,0 +1 @@ +aa11ff \ No newline at end of file diff --git a/tests/driver/ok_define_if1/out_variant2.txt b/tests/driver/ok_define_if1/out_variant2.txt new file mode 100644 index 00000000..f52c5c54 --- /dev/null +++ b/tests/driver/ok_define_if1/out_variant2.txt @@ -0,0 +1 @@ +aa22ff \ No newline at end of file diff --git a/tests/driver/ok_define_if1/out_variant3.txt b/tests/driver/ok_define_if1/out_variant3.txt new file mode 100644 index 00000000..fe02fb26 --- /dev/null +++ b/tests/driver/ok_define_if1/out_variant3.txt @@ -0,0 +1 @@ +aaff \ No newline at end of file diff --git a/tests/driver/ok_define_if2/include.asm b/tests/driver/ok_define_if2/include.asm new file mode 100644 index 00000000..f4462392 --- /dev/null +++ b/tests/driver/ok_define_if2/include.asm @@ -0,0 +1,10 @@ +#d 0xaa + +variant = false + +#if variant +{ + #d 0x11 +} + +#d 0xff \ No newline at end of file diff --git a/tests/driver/ok_define_if2/ok_variant_false.asm b/tests/driver/ok_define_if2/ok_variant_false.asm new file mode 100644 index 00000000..aef8515e --- /dev/null +++ b/tests/driver/ok_define_if2/ok_variant_false.asm @@ -0,0 +1,4 @@ +#include "include.asm" + +; command: ok_variant_false.asm -fhexstr -o out_variant_false.txt -dvariant=false +; output: out_variant_false.txt \ No newline at end of file diff --git a/tests/driver/ok_define_if2/ok_variant_novalue.asm b/tests/driver/ok_define_if2/ok_variant_novalue.asm new file mode 100644 index 00000000..ea8b6b3b --- /dev/null +++ b/tests/driver/ok_define_if2/ok_variant_novalue.asm @@ -0,0 +1,4 @@ +#include "include.asm" + +; command: ok_variant_novalue.asm -fhexstr -o out_variant_novalue.txt -dvariant +; output: out_variant_novalue.txt \ No newline at end of file diff --git a/tests/driver/ok_define_if2/ok_variant_omitted.asm b/tests/driver/ok_define_if2/ok_variant_omitted.asm new file mode 100644 index 00000000..669f4447 --- /dev/null +++ b/tests/driver/ok_define_if2/ok_variant_omitted.asm @@ -0,0 +1,4 @@ +#include "include.asm" + +; command: ok_variant_omitted.asm -fhexstr -o out_variant_omitted.txt +; output: out_variant_omitted.txt \ No newline at end of file diff --git a/tests/driver/ok_define_if2/ok_variant_true.asm b/tests/driver/ok_define_if2/ok_variant_true.asm new file mode 100644 index 00000000..ed83bccd --- /dev/null +++ b/tests/driver/ok_define_if2/ok_variant_true.asm @@ -0,0 +1,4 @@ +#include "include.asm" + +; command: ok_variant_true.asm -fhexstr -o out_variant_true.txt -dvariant=true +; output: out_variant_true.txt \ No newline at end of file diff --git a/tests/driver/ok_define_if2/out_variant_false.txt b/tests/driver/ok_define_if2/out_variant_false.txt new file mode 100644 index 00000000..fe02fb26 --- /dev/null +++ b/tests/driver/ok_define_if2/out_variant_false.txt @@ -0,0 +1 @@ +aaff \ No newline at end of file diff --git a/tests/driver/ok_define_if2/out_variant_novalue.txt b/tests/driver/ok_define_if2/out_variant_novalue.txt new file mode 100644 index 00000000..1c469aab --- /dev/null +++ b/tests/driver/ok_define_if2/out_variant_novalue.txt @@ -0,0 +1 @@ +aa11ff \ No newline at end of file diff --git a/tests/driver/ok_define_if2/out_variant_omitted.txt b/tests/driver/ok_define_if2/out_variant_omitted.txt new file mode 100644 index 00000000..fe02fb26 --- /dev/null +++ b/tests/driver/ok_define_if2/out_variant_omitted.txt @@ -0,0 +1 @@ +aaff \ No newline at end of file diff --git a/tests/driver/ok_define_if2/out_variant_true.txt b/tests/driver/ok_define_if2/out_variant_true.txt new file mode 100644 index 00000000..1c469aab --- /dev/null +++ b/tests/driver/ok_define_if2/out_variant_true.txt @@ -0,0 +1 @@ +aa11ff \ No newline at end of file diff --git a/tests/driver/ok_define_nested/main.asm b/tests/driver/ok_define_nested/main.asm new file mode 100644 index 00000000..d5a9b86d --- /dev/null +++ b/tests/driver/ok_define_nested/main.asm @@ -0,0 +1,18 @@ +#ruledef test +{ + ld {x: u8} => 0x55 @ x +} + +val1 = 0 +.val1 = 0 +..val1 = 0 +..val2 = 0 +val2 = 0 +ld val1 +ld val1.val1 +ld val1.val1.val1 +ld val1.val1.val2 +ld val2 + +; command: main.asm -fhexstr -o out.txt -dval1=0x55 -dval1.val1.val1=0x61 --define val1.val1.val2=0x62 +; output: out.txt \ No newline at end of file diff --git a/tests/driver/ok_define_nested/out.txt b/tests/driver/ok_define_nested/out.txt new file mode 100644 index 00000000..5023bec0 --- /dev/null +++ b/tests/driver/ok_define_nested/out.txt @@ -0,0 +1 @@ +55555500556155625500 \ No newline at end of file diff --git a/tests/driver/ok_define_simple_novalue/main.asm b/tests/driver/ok_define_simple_novalue/main.asm new file mode 100644 index 00000000..89fe3b7d --- /dev/null +++ b/tests/driver/ok_define_simple_novalue/main.asm @@ -0,0 +1,12 @@ +#ruledef test +{ + ld {x: u8} => 0x55 @ x +} + +val1 = 0 +val2 = {} +ld val1 ? 1 : 0 +ld val2 ? 1 : 0 + +; command: main.asm -fhexstr -o out.txt -dval1 --define val2 +; output: out.txt \ No newline at end of file diff --git a/tests/driver/ok_define_simple_novalue/out.txt b/tests/driver/ok_define_simple_novalue/out.txt new file mode 100644 index 00000000..340bcef0 --- /dev/null +++ b/tests/driver/ok_define_simple_novalue/out.txt @@ -0,0 +1 @@ +55015501 \ No newline at end of file diff --git a/tests/driver/ok_define_simple_value/main.asm b/tests/driver/ok_define_simple_value/main.asm new file mode 100644 index 00000000..46adb52f --- /dev/null +++ b/tests/driver/ok_define_simple_value/main.asm @@ -0,0 +1,16 @@ +#ruledef test +{ + ld {x: i8} => 0x55 @ x +} + +val1 = 0 +val2 = {} +val3 = false +val4 = 1 +ld val1 +ld val2 +ld val3 +ld val4 + +; command: main.asm -fhexstr -o out.txt -dval1=85 --define val2=0x55 -dval3=-1 --define=val4=0xff +; output: out.txt \ No newline at end of file diff --git a/tests/driver/ok_define_simple_value/out.txt b/tests/driver/ok_define_simple_value/out.txt new file mode 100644 index 00000000..e0452e2c --- /dev/null +++ b/tests/driver/ok_define_simple_value/out.txt @@ -0,0 +1 @@ +5555555555ff55ff \ No newline at end of file