implemented all instructions i think?
This commit is contained in:
parent
072686ea8d
commit
41368e48a6
|
@ -1,6 +1,8 @@
|
|||
use std::fs;
|
||||
use core::slice::Iter;
|
||||
|
||||
const REGISTERS: [&str; 8] = [ "B", "C", "D", "E", "H", "L", "M", "A" ];
|
||||
|
||||
fn main() {
|
||||
let file = fs::read("/home/lea/Downloads/invadeez/invadeez/rom/invaders.h").expect("where file");
|
||||
let mut data = file.iter();
|
||||
|
@ -49,7 +51,7 @@ fn main() {
|
|||
0x1e => format!("MVI E,#0x{}", next(&mut data, 1)),
|
||||
0x1f => format!("RAR"),
|
||||
0x21 => format!("LXI H,#0x{}", next(&mut data, 2)),
|
||||
0x22 => format!("SLHD %0x{}", next(&mut data, 2)),
|
||||
0x22 => format!("SLHD #0x{}", next(&mut data, 2)),
|
||||
0x23 => format!("INX H"),
|
||||
0x24 => format!("INR H"),
|
||||
0x25 => format!("DCR H"),
|
||||
|
@ -76,12 +78,84 @@ fn main() {
|
|||
0x3d => format!("DCR A"),
|
||||
0x3e => format!("MVI A,#0x{}", next(&mut data, 1)),
|
||||
0x3f => format!("CMC"),
|
||||
// -- continue here --
|
||||
0x76 => format!("HLT ; Trigger interrupt"),
|
||||
0x40..=0x7f // Test this!
|
||||
=> format!("JMP {},{}", REGISTERS[(byte & 0b111000) as usize >> 3], REGISTERS[(byte & 0b111) as usize]),
|
||||
0x80..=0x87
|
||||
=> format!("ADD {}", REGISTERS[(byte & 0b111) as usize]),
|
||||
0x88..=0x8f
|
||||
=> format!("ADC {}", REGISTERS[(byte & 0b111) as usize]),
|
||||
0x90..=0x97
|
||||
=> format!("SUB {}", REGISTERS[(byte & 0b111) as usize]),
|
||||
0x98..=0x9f
|
||||
=> format!("ABB {}", REGISTERS[(byte & 0b111) as usize]),
|
||||
0x80..=0xa7
|
||||
=> format!("ANA {}", REGISTERS[(byte & 0b111) as usize]),
|
||||
0xa8..=0xaf
|
||||
=> format!("XRA {}", REGISTERS[(byte & 0b111) as usize]),
|
||||
0xb0..=0xb7
|
||||
=> format!("ANA {}", REGISTERS[(byte & 0b111) as usize]),
|
||||
0xb8..=0xbf
|
||||
=> format!("XRA {}", REGISTERS[(byte & 0b111) as usize]),
|
||||
0xc0 => format!("RNZ"),
|
||||
0xc1 => format!("POP B"),
|
||||
0xc2 => format!("JNZ ${}", next(&mut data, 2)),
|
||||
0xc3 => format!("JMP ${}", next(&mut data, 2)),
|
||||
0xc4 => format!("CNZ ${}", next(&mut data, 2)),
|
||||
0xc5 => format!("PUSH B"),
|
||||
0xc6 => format!("ADI #0x{}", next(&mut data, 1)),
|
||||
0xc7 => format!("RST 0 ; CALL $0"),
|
||||
0xc8 => format!("RZ"),
|
||||
0xc9 => format!("RET"),
|
||||
0xca => format!("JZ ${}", next(&mut data, 2)),
|
||||
0xcc => format!("CZ ${}", next(&mut data, 2)),
|
||||
0xcd => format!("CALL ${}", next(&mut data, 2)),
|
||||
0xce => format!("ACI #0x{}", next(&mut data, 1)),
|
||||
0xcf => format!("RST 1 ; CALL $8"),
|
||||
0xd0 => format!("RNC"),
|
||||
0xd1 => format!("POP D"),
|
||||
0xd2 => format!("JNC ${}", next(&mut data, 2)),
|
||||
0xd3 => format!("OUT #0x{}", next(&mut data, 1)),
|
||||
0xd4 => format!("CNC ${}", next(&mut data, 2)),
|
||||
0xd5 => format!("PUSH D"),
|
||||
0xd6 => format!("SUI #0x{}", next(&mut data, 1)),
|
||||
0xd7 => format!("RST 2 ; CALL $10"),
|
||||
0xd8 => format!("RC"),
|
||||
0xda => format!("JC ${}", next(&mut data, 2)),
|
||||
0xdb => format!("IN #0x{}", next(&mut data, 1)),
|
||||
0xdc => format!("CC ${}", next(&mut data, 2)),
|
||||
0xde => format!("SBI #0x{}", next(&mut data, 1)),
|
||||
0xdf => format!("RST 3 ; $CALL 18"),
|
||||
0xe0 => format!("RPO"),
|
||||
0xe1 => format!("POP H"),
|
||||
0xe2 => format!("JPO ${}", next(&mut data, 2)),
|
||||
0xe3 => format!("XTHL"),
|
||||
0xe4 => format!("CPO ${}", next(&mut data, 2)),
|
||||
0xe5 => format!("PUSH H"),
|
||||
0xe6 => format!("ANI #0x{}", next(&mut data, 1)),
|
||||
0xe7 => format!("RST 4 ; CALL $20"),
|
||||
0xe8 => format!("RPE"),
|
||||
0xe9 => format!("PCHL"),
|
||||
0xea => format!("JPE ${}", next(&mut data, 2)),
|
||||
0xeb => format!("XCHG"),
|
||||
0xec => format!("CPE ${}", next(&mut data, 2)),
|
||||
0xee => format!("XRI #0x{}", next(&mut data, 1)),
|
||||
0xef => format!("RST 5 ; CALL $28"),
|
||||
0xf0 => format!("RP"),
|
||||
0xf1 => format!("POP PSW"),
|
||||
0xf2 => format!("JP ${}", next(&mut data, 2)),
|
||||
0xf3 => format!("DI"),
|
||||
0xf4 => format!("CP ${}", next(&mut data, 2)),
|
||||
0xf5 => format!("PUSH PSW"),
|
||||
0xf6 => format!("ORI #0x{}", next(&mut data, 1)),
|
||||
0xf7 => format!("RST 6 ; CALL $30"),
|
||||
0xf8 => format!("RM"),
|
||||
0xf9 => format!("SPHL"),
|
||||
0xfa => format!("JM ${}", next(&mut data, 2)),
|
||||
0xfb => format!("EI"),
|
||||
0xfc => format!("CM ${}", next(&mut data, 2)),
|
||||
0xfe => format!("CPI #0x{}", next(&mut data, 1)),
|
||||
0xff => format!("RST 7 ; CALL $38"),
|
||||
_ => panic!("Unimplemented instruction {:#x}", byte),
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue