This commit is contained in:
Kevin Hamacher 2018-02-17 00:37:36 +01:00
parent 107b901c27
commit 19f6e29518
2 changed files with 17 additions and 5 deletions

View File

@ -206,8 +206,10 @@ impl Instruction {
// LDS32 STS32
pub fn size(&self) -> usize {
match *self {
Instruction::JMP(_) | Instruction::CALL(_) |
Instruction::STS16(_, _) | Instruction::LDS16(_, _) => 4,
Instruction::JMP(_)
| Instruction::CALL(_)
| Instruction::STS16(_, _)
| Instruction::LDS16(_, _) => 4,
_ => 2,
}
}
@ -310,12 +312,18 @@ pub fn decode(data: &[u8]) -> Result<Instruction, DecodingError> {
let b = (v & 0b0111) as u8;
match v & 0b1111_1111_0000_0000 {
0b1001_0110_0000_0000 => {
return Ok(Instruction::ADIW(((d & 0b11) * 2 + 24).into(), u16::from(K)))
return Ok(Instruction::ADIW(
((d & 0b11) * 2 + 24).into(),
u16::from(K),
))
}
0b0000_0001_0000_0000 => return Ok(Instruction::MOVW((d * 2).into(), (r * 2).into())),
0b0000_0010_0000_0000 => return Ok(Instruction::MULS((d + 16).into(), (r + 16).into())),
0b1001_0111_0000_0000 => {
return Ok(Instruction::SBIW(((d & 0b11) * 2 + 24).into(), u16::from(K)))
return Ok(Instruction::SBIW(
((d & 0b11) * 2 + 24).into(),
u16::from(K),
))
}
0b1110_1111_0000_0000 => if r == 0b1111 {
return Ok(Instruction::SER((d + 16).into()));

View File

@ -29,7 +29,11 @@ fn main() {
);
info!(log, "AVREmu starting up");
let rom = read_file(std::env::args().nth(1).unwrap_or_else(|| "rom.bin".to_string())).unwrap();
let rom = read_file(
std::env::args()
.nth(1)
.unwrap_or_else(|| "rom.bin".to_string()),
).unwrap();
let mut chip = chip::Chip::new(log.clone(), rom);