(args: &Args)
| 335 | let asm_text = pipeline.compile_ir_to_assembly(&result.ir_program); |
| 336 | write_or_print(args.output.as_deref(), &asm_text)?; |
| 337 | } |
| 338 | |
| 339 | Ok(ExitCode::SUCCESS) |
| 340 | } |
| 341 | |
| 342 | // --- run --- |
| 343 | |
| 344 | fn cmd_run(args: &Args) -> Result<ExitCode, CliError> { |
| 345 | let input = require_single_input(args)?; |
| 346 | |
| 347 | let assembled = if has_extension(input, "s") { |
| 348 | eprintln!( |
| 349 | "fsc: note: loading `.s` as assembly text; \ |
| 350 | instructions not in the built-in parser may be silently skipped" |
| 351 | ); |
| 352 | assemble_from_s_file(input, args.mode)? |
| 353 | } else { |
| 354 | return run_cli_config(input, args.mode, args.max_steps); |
| 355 | }; |
| 356 | |
| 357 | let mut vm = VirtualMachine::new(&assembled); |
| 358 | let result = vm.run(args.max_steps); |
| 359 | |
| 360 | print!("{}", result.uart_output); |
| 361 | |
| 362 | match result.outcome { |
| 363 | StepOutcome::Halted(code) => { |
| 364 | eprintln!("fsc: program exited with code {code}"); |
| 365 | Ok(ExitCode::from((code & 0xFF) as u8)) |
| 366 | } |
| 367 | StepOutcome::Continue => Err(CliError::Timeout(args.max_steps)), |
no test coverage detected