--- as500-orig/src/main.rs 2025-03-30 22:35:47.000000000 +0100 +++ as500-srom/src/main.rs 2025-08-12 20:46:23.510160425 +0100 @@ -51,7 +51,7 @@ } let mut cmd = Command::new("alpha-linux-gnu-objdump"); - cmd.args(["-b", "binary", "-m", "alpha", "-D"]); + cmd.args(["-b", "binary", "-m", "alpha:ev5", "-D"]); cmd.arg(&outbin_filename); cmd.stdout(Stdio::piped()); let child = cmd.spawn()?; @@ -59,11 +59,11 @@ let asm = std::str::from_utf8(&output.stdout)?; let mut outfile_asm = std::fs::File::create(&outasm_filename)?; for line in asm.lines() { - if let Some(x) = line.find("\u{0009}pal1") { + if let Some(x) = line.find("\u{0009}hw_m") { let instruction = &line[x..]; println!("Decoding {:?}", instruction); let decoded = decode(instruction); - writeln!(outfile_asm, "{} ; {}", line, decoded)?; + writeln!(outfile_asm, "{}\t; {}", line, decoded)?; } else { writeln!(outfile_asm, "{}", line)?; }; @@ -72,39 +72,19 @@ Ok(()) } -fn decode(instruction: &str) -> String { +fn decode(instruction: &str) -> &'static str { let mut i = instruction.split_ascii_whitespace(); - let instruction = i.next().unwrap(); - let arg = i.next().unwrap(); - let arg = if let Some(suffix) = arg.strip_prefix("0x") { - u32::from_str_radix(suffix, 16).unwrap() + i.next(); + if let Some((_reg, ipr)) = i.next().unwrap().split_once(',') { + let ipr = if let Some(suffix) = ipr.strip_prefix("0x") { + u32::from_str_radix(suffix, 16).unwrap() + } else { + u32::from_str_radix(ipr, 10).unwrap() + }; + ipr_decode(ipr as u16) } else { - u32::from_str_radix(arg, 10).unwrap() - }; - match instruction { - "pal19" => { - let ipr = ipr_decode(arg as u16); - let reg = REG_MAP[((arg >> 16) & 0x1F) as usize]; - format!("HW_MFPR: read {ipr} to {reg}") - } - "pal1b" => { - format!("HW_LD") - } - "pal1d" => { - let ipr = ipr_decode(arg as u16); - let reg = REG_MAP[((arg >> 16) & 0x1F) as usize]; - format!("HW_MTPR: write {reg} to {ipr}") - } - "pal1e" => { - format!("HW_REI") - } - "pal1f" => { - format!("HW_ST") - } - _ => { - panic!("Decoding wrong instruction {:?}", instruction); - } - } + "" + } } static REG_MAP: [&str; 32] = [