tmp
parent
9e785d117c
commit
61f64af4a4
|
@ -1,6 +1,6 @@
|
||||||
//! The `parse` module holds functions that will parse streams of data into an [`crate::instructions::Instruction`]
|
//! The `parse` module holds functions that will parse streams of data into an [`crate::instructions::Instruction`]
|
||||||
|
|
||||||
use crate::memory::View;
|
use crate::memory::{GetViewTuple, View};
|
||||||
|
|
||||||
use super::instructions::Instruction;
|
use super::instructions::Instruction;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -81,11 +81,15 @@ pub fn next_instruction(data: &View) -> ParseResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: support 16bit, too
|
|
||||||
let opcode = get_opcode_from_data(data);
|
let opcode = get_opcode_from_data(data);
|
||||||
Err(Error::UnknownOpcode(opcode))
|
Err(Error::UnknownOpcode(opcode))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_opcode_from_data(data: &View) -> unparsed::Opcode {
|
fn get_opcode_from_data(data: &View) -> unparsed::Opcode {
|
||||||
unparsed::Opcode::EightBit(data.get())
|
let (byte1, byte2) = data.get_tuple();
|
||||||
|
if byte1 == 0xCB {
|
||||||
|
unparsed::Opcode::SixteenBit(u16::from_be_bytes([byte1, byte2]))
|
||||||
|
} else {
|
||||||
|
unparsed::Opcode::EightBit(byte1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue