use zerocopy::{IntoBytes, KnownLayout, TryFromBytes, Unaligned};
pub const CALL: u8 = 0xE8;
pub const JMP: u8 = 0xE9;
#[derive(TryFromBytes, IntoBytes, KnownLayout, Unaligned)]
#[repr(u8)]
pub enum OpCode {
Call = CALL,
Jmp = JMP,
}
#[derive(TryFromBytes, IntoBytes, KnownLayout, Unaligned)]
#[repr(C)]
pub struct Instruction {
opcode: OpCode,
pub(crate) address: [u8; 4],
}
impl Instruction {
pub const fn sign_extension(&self) -> u8 {
self.address[3]
}
pub const fn address(&self) -> u32 {
u32::from_le_bytes(self.address)
}
}