fn read_value(&mut self, address: InstructionArgument) -> Word {
        match address {
            InstructionArgument::Literal(value) => value,
            InstructionArgument::Register(register) => self.registers[register as usize],
            InstructionArgument::Address(address) => self.ram[address as usize],
            InstructionArgument::AddressFromRegister(register) => {
                let address = self.registers[register as usize];
                self.ram[address as usize]
            }
            InstructionArgument::AddressOffset { address, register } => {
                let offset = self.registers[register as usize];
                self.ram[address as usize + offset as usize]
            }
            InstructionArgument::SpecialRegister(register) => match register {
                SpecialRegister::ProgramCounter => self.program_counter,
                SpecialRegister::StackPointer => self.stack_pointer,
                SpecialRegister::Overflow => self.overflow,
            },
            InstructionArgument::StackOperation(operation) => match operation {
                StackOperation::Peek => self.ram[self.stack_pointer as usize],
                StackOperation::Pop => {
                    let address = self.stack_pointer;
                    self.stack_pointer += 1;
                    self.ram[address as usize]
                }
                StackOperation::Push => {
                    warn!("Detected write from a PUSH");
                    self.stack_pointer -= 1;
                    let address = self.stack_pointer;
                    self.ram[address as usize]
                }
            },
        }
    }
/// Reads the value from the specified argument.
Reads the value from the specified argument.
Reads the value from the specified argument .
fn read_value(&mut self, address: InstructionArgument) -> Word {
        match address {
            InstructionArgument::Literal(value) => value,
            InstructionArgument::Register(register) => self.registers[register as usize],
            InstructionArgument::Address(address) => self.ram[address as usize],
            InstructionArgument::AddressFromRegister(register) => {
                let address = self.registers[register as usize];
                self.ram[address as usize]
            }
            InstructionArgument::AddressOffset { address, register } => {
                let offset = self.registers[register as usize];
                self.ram[address as usize + offset as usize]
            }
            InstructionArgument::SpecialRegister(register) => match register {
                SpecialRegister::ProgramCounter => self.program_counter,
                SpecialRegister::StackPointer => self.stack_pointer,
                SpecialRegister::Overflow => self.overflow,
            },
            InstructionArgument::StackOperation(operation) => match operation {
                StackOperation::Peek => self.ram[self.stack_pointer as usize],
                StackOperation::Pop => {
                    let address = self.stack_pointer;
                    self.stack_pointer += 1;
                    self.ram[address as usize]
                }
                StackOperation::Push => {
                    warn!("Detected write from a PUSH");
                    self.stack_pointer -= 1;
                    let address = self.stack_pointer;
                    self.ram[address as usize]
                }
            },
        }
    }
fn read_value ( & mut self , address : InstructionArgument ) -> Word { match address { InstructionArgument :: Literal ( value ) => value , InstructionArgument :: Register ( register ) => self . registers [ register as usize ] , InstructionArgument :: Address ( address ) => self . ram [ address as usize ] , InstructionArgument :: AddressFromRegister ( register ) => { let address = self . registers [ register as usize ] ; self . ram [ address as usize ] } InstructionArgument :: AddressOffset { address , register } => { let offset = self . registers [ register as usize ] ; self . ram [ address as usize + offset as usize ] } InstructionArgument :: SpecialRegister ( register ) => match register { SpecialRegister :: ProgramCounter => self . program_counter , SpecialRegister :: StackPointer => self . stack_pointer , SpecialRegister :: Overflow => self . overflow , } , InstructionArgument :: StackOperation ( operation ) => match operation { StackOperation :: Peek => self . ram [ self . stack_pointer as usize ] , StackOperation :: Pop => { let address = self . stack_pointer ; self . stack_pointer += 1 ; self . ram [ address as usize ] } StackOperation :: Push => { warn ! ( " " ) ; self . stack_pointer -= 1 ; let address = self . stack_pointer ; self . ram [ address as usize ] } } , } }
Reads the value from the specified argument.
Reads the value from the specified argument .
&mut self
address
InstructionArgument