Skip to content

Commit

Permalink
nasm: Remove the option to disassemble a file
Browse files Browse the repository at this point in the history
This never quite worked and since multiple re-writes of the
assembler/parser it was even commented out. Moreover, this functionality
appears to be more suitable to the new `readrom` binary introduced in
commit 407048d ("Add the readrom binary"). Hence, just remove this
altogether.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Dec 18, 2024
1 parent 1da66eb commit da49e5e
Showing 1 changed file with 13 additions and 37 deletions.
50 changes: 13 additions & 37 deletions crates/nasm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ struct Args {
#[arg(short = 'c', long)]
config: Option<String>,

/// Disassemble instead of assembling. Disabled by default.
#[arg(short, long, default_value_t = false)]
disassemble: bool,

/// Place the output into the given <OUT> 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<String>,

Expand All @@ -46,14 +41,7 @@ fn main() -> Result<()> {
let mut output: Box<dyn Write> = 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.
Expand All @@ -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);
}
}

Expand Down

0 comments on commit da49e5e

Please sign in to comment.