diff --git a/README.md b/README.md index c925b654..b51135c9 100644 --- a/README.md +++ b/README.md @@ -108,8 +108,12 @@ Options: -f, --format FORMAT The format of the output file. Possible formats: binary, annotated, annotatedbin, binstr, hexstr, bindump, hexdump, mif, intelhex, deccomma, hexcomma, - decc, hexc, logisim8, logisim16 + decspace, hexspace, decc, hexc, logisim8, logisim16, + addrspan -o, --output [FILE] The name of the output file. + --symbol-format SYMBOL-FORMAT + The format of the symbol file. Possible formats: + default, mesen-mlb -s, --symbol [FILE] The name of the output symbol file. -t, --iter [NUM] The max number of passes the assembler will attempt (default: 10). diff --git a/src/driver.rs b/src/driver.rs index a0142e46..c17e36f4 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -15,6 +15,8 @@ enum OutputFormat IntelHex, DecComma, HexComma, + DecSpace, + HexSpace, DecC, HexC, LogiSim8, @@ -97,6 +99,8 @@ fn drive_inner( Some("intelhex") => OutputFormat::IntelHex, Some("deccomma") => OutputFormat::DecComma, Some("hexcomma") => OutputFormat::HexComma, + Some("decspace") => OutputFormat::DecSpace, + Some("hexspace") => OutputFormat::HexSpace, Some("decc") => OutputFormat::DecC, Some("hexc") => OutputFormat::HexC, Some("c") => OutputFormat::HexC, @@ -214,18 +218,20 @@ fn drive_inner( { OutputFormat::Binary => binary.format_binary(), - OutputFormat::BinStr => binary.format_binstr () .bytes().collect(), - OutputFormat::HexStr => binary.format_hexstr () .bytes().collect(), - OutputFormat::BinDump => binary.format_bindump () .bytes().collect(), - OutputFormat::HexDump => binary.format_hexdump () .bytes().collect(), - OutputFormat::Mif => binary.format_mif () .bytes().collect(), - OutputFormat::IntelHex => binary.format_intelhex() .bytes().collect(), - OutputFormat::DecComma => binary.format_comma (10).bytes().collect(), - OutputFormat::HexComma => binary.format_comma (16).bytes().collect(), - OutputFormat::DecC => binary.format_c_array (10).bytes().collect(), - OutputFormat::HexC => binary.format_c_array (16).bytes().collect(), - OutputFormat::LogiSim8 => binary.format_logisim (8) .bytes().collect(), - OutputFormat::LogiSim16 => binary.format_logisim (16).bytes().collect(), + OutputFormat::BinStr => binary.format_binstr() .bytes().collect(), + OutputFormat::HexStr => binary.format_hexstr() .bytes().collect(), + OutputFormat::BinDump => binary.format_bindump() .bytes().collect(), + OutputFormat::HexDump => binary.format_hexdump() .bytes().collect(), + OutputFormat::Mif => binary.format_mif() .bytes().collect(), + OutputFormat::IntelHex => binary.format_intelhex() .bytes().collect(), + OutputFormat::DecComma => binary.format_separator(10, ", ").bytes().collect(), + OutputFormat::HexComma => binary.format_separator(16, ", ").bytes().collect(), + OutputFormat::DecSpace => binary.format_separator(10, " ") .bytes().collect(), + OutputFormat::HexSpace => binary.format_separator(16, " ") .bytes().collect(), + OutputFormat::DecC => binary.format_c_array(10) .bytes().collect(), + OutputFormat::HexC => binary.format_c_array(16) .bytes().collect(), + OutputFormat::LogiSim8 => binary.format_logisim(8) .bytes().collect(), + OutputFormat::LogiSim16 => binary.format_logisim(16) .bytes().collect(), OutputFormat::AnnotatedHex => binary.format_annotated_hex(fileserver).bytes().collect(), OutputFormat::AnnotatedBin => binary.format_annotated_bin(fileserver).bytes().collect(), @@ -290,7 +296,7 @@ fn drive_inner( fn make_opts() -> getopts::Options { let mut opts = getopts::Options::new(); - opts.optopt("f", "format", "The format of the output file. Possible formats: binary, annotated, annotatedbin, binstr, hexstr, bindump, hexdump, mif, intelhex, deccomma, hexcomma, decc, hexc, logisim8, logisim16, addrspan", "FORMAT"); + opts.optopt("f", "format", "The format of the output file. Possible formats: binary, annotated, annotatedbin, binstr, hexstr, bindump, hexdump, mif, intelhex, deccomma, hexcomma, decspace, hexspace, decc, hexc, logisim8, logisim16, addrspan", "FORMAT"); opts.opt("o", "output", "The name of the output file.", "FILE", getopts::HasArg::Maybe, getopts::Occur::Optional); opts.optopt("", "symbol-format", "The format of the symbol file. Possible formats: default, mesen-mlb", "SYMBOL-FORMAT"); opts.opt("s", "symbol", "The name of the output symbol file.", "FILE", getopts::HasArg::Maybe, getopts::Occur::Optional); diff --git a/src/util/bitvec_format.rs b/src/util/bitvec_format.rs index 39fb68e5..9e7040a7 100644 --- a/src/util/bitvec_format.rs +++ b/src/util/bitvec_format.rs @@ -252,7 +252,7 @@ impl util::BitVec } - pub fn format_comma(&self, radix: usize) -> String + pub fn format_separator(&self, radix: usize, separator: &str) -> String { let mut result = String::new(); @@ -276,7 +276,7 @@ impl util::BitVec if index < self.len() { - result.push_str(", "); + result.push_str(separator); if (index / 8) % 16 == 0 { result.push('\n'); } diff --git a/src/webasm/mod.rs b/src/webasm/mod.rs index 744b1486..6aa1f81f 100644 --- a/src/webasm/mod.rs +++ b/src/webasm/mod.rs @@ -29,12 +29,14 @@ pub unsafe extern fn wasm_assemble(format: u32, src: *mut String) -> *mut String 5 => Ok(binary.format_binstr ()), 6 => Ok(binary.format_mif ()), 7 => Ok(binary.format_intelhex()), - 8 => Ok(binary.format_comma (10)), - 9 => Ok(binary.format_comma (16)), - 10 => Ok(binary.format_c_array (10)), - 11 => Ok(binary.format_c_array (16)), - 12 => Ok(binary.format_logisim (8)), - 13 => Ok(binary.format_logisim (16)), + 8 => Ok(binary.format_separator(10, ", ")), + 9 => Ok(binary.format_separator(16, ", ")), + 10 => Ok(binary.format_separator(10, " ")), + 11 => Ok(binary.format_separator(16, " ")), + 12 => Ok(binary.format_c_array (10)), + 13 => Ok(binary.format_c_array (16)), + 14 => Ok(binary.format_logisim (8)), + 15 => Ok(binary.format_logisim (16)), _ => unreachable!() } }; diff --git a/web/index.html b/web/index.html index bd0a44cf..948389a7 100644 --- a/web/index.html +++ b/web/index.html @@ -100,6 +100,8 @@ + +