1
0
Fork 0
forked from koniifer/ableos

Changed magic

This commit is contained in:
Erin 2023-08-01 22:20:11 +02:00
parent 73b998911c
commit 8287b1bdc1
3 changed files with 4 additions and 4 deletions

View file

@ -72,7 +72,7 @@ impl Assembler {
/// Why 12 bytes? That's the size of largest instruction parameter part. /// Why 12 bytes? That's the size of largest instruction parameter part.
pub fn finalise(&mut self) { pub fn finalise(&mut self) {
self.buf.extend([0; 12]); self.buf.extend([0; 12]);
self.buf[0..3].copy_from_slice(&[0xAB, 0x1E, 0x0B]); self.buf[0..4].copy_from_slice(&0xAB1E0B_u32.to_le_bytes());
} }
} }

View file

@ -40,7 +40,7 @@ macro_rules! gen_valider {
/// sound to execute. /// sound to execute.
pub fn validate(mut program: &[u8]) -> Result<(), Error> { pub fn validate(mut program: &[u8]) -> Result<(), Error> {
// Validate magic // Validate magic
if program.get(0..3) != Some(&[0xAB, 0x1E, 0x0B]) { if program.get(0..4) != Some(&0xAB1E0B_u32.to_le_bytes()) {
return Err(Error { return Err(Error {
kind: ErrorKind::MissingMagic, kind: ErrorKind::MissingMagic,
index: 0, index: 0,
@ -67,7 +67,7 @@ macro_rules! gen_valider {
} }
let start = program; let start = program;
program = &program[3..]; program = &program[4..];
loop { loop {
use crate::opcode::*; use crate::opcode::*;
program = match program { program = match program {

View file

@ -73,7 +73,7 @@ impl<'a, PfHandler: HandlePageFault, const TIMER_QUOTIENT: usize>
pfhandler: traph, pfhandler: traph,
pc: 0, pc: 0,
program_len: program.len() - 12, program_len: program.len() - 12,
program: &program[3..], program: &program[4..],
timer: 0, timer: 0,
copier: None, copier: None,
} }