diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs index 105a995..e6d7c45 100644 --- a/crates/nasm/src/main.rs +++ b/crates/nasm/src/main.rs @@ -17,13 +17,8 @@ struct Args { #[arg(short = 'c', long)] config: Option, - /// Disassemble instead of assembling. Disabled by default. - #[arg(short, long, default_value_t = false)] - disassemble: bool, - /// Place the output into the given file. Ignored if the `stdout` flag - /// is provided. Defaults to `out.nes` when assembling, and to `out.s` when - /// disassembling. + /// is provided. Defaults to `out.nes`. #[arg(short = 'o', long)] out: Option, @@ -46,14 +41,7 @@ fn main() -> Result<()> { let mut output: Box = if args.stdout { Box::new(io::stdout()) } else { - match args.out { - Some(file) => Box::new(File::create(file)?), - None => Box::new(File::create(if args.disassemble { - "out.s" - } else { - "out.nes" - })?), - } + Box::new(File::create(args.out.unwrap_or(String::from("out.nes")))?) }; // Select the linker configuration. @@ -70,33 +58,21 @@ fn main() -> Result<()> { None => NROM.to_vec(), }; - // Initialize the assembler with the given linker configuration. + // And assemble. let mut assembler = Assembler::new(mapping); - - // After the parse operation, just print the results. - if args.disassemble { - println!("TBD"); - // let instructions = assembler.disassemble(input)?; - - // for instr in instructions { - // output.write_all(instr.to_human().as_bytes())?; - // output.write_all("\n".as_bytes())?; - // } - } else { - match assembler.assemble(input) { - Ok(bundles) => { - for b in bundles { - for i in 0..b.size { - output.write_all(&[b.bytes[i as usize]])?; - } + match assembler.assemble(input) { + Ok(bundles) => { + for b in bundles { + for i in 0..b.size { + output.write_all(&[b.bytes[i as usize]])?; } } - Err(errors) => { - for err in errors { - println!("{}", err); - } - std::process::exit(1); + } + Err(errors) => { + for err in errors { + println!("{}", err); } + std::process::exit(1); } }