fmt
This commit is contained in:
parent
107b901c27
commit
19f6e29518
@ -206,8 +206,10 @@ impl Instruction {
|
|||||||
// LDS32 STS32
|
// LDS32 STS32
|
||||||
pub fn size(&self) -> usize {
|
pub fn size(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
Instruction::JMP(_) | Instruction::CALL(_) |
|
Instruction::JMP(_)
|
||||||
Instruction::STS16(_, _) | Instruction::LDS16(_, _) => 4,
|
| Instruction::CALL(_)
|
||||||
|
| Instruction::STS16(_, _)
|
||||||
|
| Instruction::LDS16(_, _) => 4,
|
||||||
_ => 2,
|
_ => 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,12 +312,18 @@ pub fn decode(data: &[u8]) -> Result<Instruction, DecodingError> {
|
|||||||
let b = (v & 0b0111) as u8;
|
let b = (v & 0b0111) as u8;
|
||||||
match v & 0b1111_1111_0000_0000 {
|
match v & 0b1111_1111_0000_0000 {
|
||||||
0b1001_0110_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_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())),
|
0b0000_0010_0000_0000 => return Ok(Instruction::MULS((d + 16).into(), (r + 16).into())),
|
||||||
0b1001_0111_0000_0000 => {
|
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 {
|
0b1110_1111_0000_0000 => if r == 0b1111 {
|
||||||
return Ok(Instruction::SER((d + 16).into()));
|
return Ok(Instruction::SER((d + 16).into()));
|
||||||
|
|||||||
@ -29,7 +29,11 @@ fn main() {
|
|||||||
);
|
);
|
||||||
info!(log, "AVREmu starting up");
|
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);
|
let mut chip = chip::Chip::new(log.clone(), rom);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user