chore(interpreter): rewrite displacement memoryindex logic
Previously, the displacement for a MemoryIndex was directly interpreted and saved as a signed value. Change this to the normal unsigned ImmediateOperand version to allow for more flexible usage of this struct for general memoryaccess (future commit) and just interpret the displacement member as signed, only when being interpreted as such (memory access, display, ....
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::operands::{Byte, Displacement, ImmediateOperand, MemoryIndex, Word};
|
||||
use crate::operands::{Byte, ImmediateOperand, ImmediateOperandSigned, MemoryIndex, Word};
|
||||
|
||||
use super::interpreter::InterpreterError;
|
||||
use crate::interpreter::register::{Register, SegmentRegister};
|
||||
@@ -97,7 +97,7 @@ impl Memory {
|
||||
) -> Word {
|
||||
let mut base = ImmediateOperand::Word(0);
|
||||
let mut index = ImmediateOperand::Word(0);
|
||||
let mut disp = Displacement::IWord(0);
|
||||
let mut disp = ImmediateOperandSigned::Word(0);
|
||||
|
||||
if let Some(base_reg) = idx.base {
|
||||
base = regs.read(base_reg);
|
||||
@@ -106,7 +106,7 @@ impl Memory {
|
||||
index = regs.read(index_reg);
|
||||
};
|
||||
if let Some(displacement) = idx.displacement {
|
||||
disp = displacement;
|
||||
disp = ImmediateOperandSigned::from(displacement);
|
||||
}
|
||||
|
||||
Self::addr_offset((base + index + disp).into(), sregs)
|
||||
|
||||
Reference in New Issue
Block a user