mirror of
https://github.com/danbee/8080
synced 2025-03-04 08:39:07 +00:00
Improve mnemonic formatting
This commit is contained in:
parent
86da1e6124
commit
fc4764c5de
27
src/main.rs
27
src/main.rs
@ -1,10 +1,31 @@
|
|||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
|
|
||||||
fn print_mnemonic(mnemonic: &str, bytes: &[u8]) {
|
fn print_mnemonic(mnemonic: &str, bytes: &[u8]) {
|
||||||
|
let split_mnemonic: Vec<&str> = mnemonic.split(" ").collect();
|
||||||
|
|
||||||
|
let mut argument = "";
|
||||||
|
|
||||||
|
let mnemonic = split_mnemonic[0];
|
||||||
|
if split_mnemonic.len() == 2 {
|
||||||
|
argument = split_mnemonic[1];
|
||||||
|
}
|
||||||
|
|
||||||
match bytes.len() {
|
match bytes.len() {
|
||||||
1 => println!("{:02x} {}", bytes[0], mnemonic),
|
1 => println!("{opcode:02x} {mnemonic:6} {arg}",
|
||||||
2 => println!("{:02x} {:02x} {:5} #0x{:02x}", bytes[0], bytes[1], mnemonic, bytes[1]),
|
opcode = bytes[0],
|
||||||
3 => println!("{:02x} {:02x} {:02x} {:5} ${:02x}{:02x}", bytes[0], bytes[1], bytes[2], mnemonic, bytes[2], bytes[1]),
|
mnemonic = mnemonic,
|
||||||
|
arg = argument),
|
||||||
|
2 => println!("{opcode:02x} {byte:02x} {mnemonic:6} {arg}#0x{byte:02x}",
|
||||||
|
opcode = bytes[0],
|
||||||
|
byte = bytes[1],
|
||||||
|
mnemonic = mnemonic,
|
||||||
|
arg = argument),
|
||||||
|
3 => println!("{opcode:02x} {low_byte:02x} {high_byte:02x} {mnemonic:6} {arg}${high_byte:02x}{low_byte:02x}",
|
||||||
|
opcode = bytes[0],
|
||||||
|
low_byte = bytes[1],
|
||||||
|
high_byte = bytes[2],
|
||||||
|
mnemonic = mnemonic,
|
||||||
|
arg = argument),
|
||||||
|
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user