ft(interpreter): impl far jumps with correct CS addressing
This commit is contained in:
@@ -2,21 +2,24 @@ use crate::operands::{Byte, Displacement, ImmediateOperand, MemoryIndex, Word};
|
||||
|
||||
use super::interpreter::InterpreterError;
|
||||
|
||||
/// 2*20 = 1MiB
|
||||
const MEMORY_SIZE: usize = 1048576;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Memory {
|
||||
memory: [Byte; Word::MAX as usize],
|
||||
memory: [Byte; MEMORY_SIZE as usize],
|
||||
}
|
||||
|
||||
impl Memory {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
memory: [0; Word::MAX as usize],
|
||||
memory: [0; MEMORY_SIZE as usize],
|
||||
}
|
||||
}
|
||||
|
||||
/// Safely writes a [`Word`] into an index of memory.
|
||||
pub fn write_raw(&mut self, idx: Word, val: Word) -> Result<(), InterpreterError> {
|
||||
if idx + 1 > Word::MAX {
|
||||
if (idx + 1) as usize > MEMORY_SIZE {
|
||||
return Err(InterpreterError::MemoryOutOfBound(idx));
|
||||
} else {
|
||||
let [low, high] = val.to_le_bytes();
|
||||
|
||||
Reference in New Issue
Block a user