fn store_value(&mut self, address: InstructionArgument, value: Word) {
        match address {
            // Specification:
            // If any instruction tries to assign a literal value, the assignment fails silently.
            // Other than that, the instruction behaves as normal.
            InstructionArgument::Literal(_) => {
                trace!(
                    "Skipping literal assignment of word {word:04X} to literal {literal:04X}",
                    word = value,
                    literal = address.get_literal().unwrap()
                )
            }
            InstructionArgument::Register(register) => self.registers[register as usize] = value,
            InstructionArgument::Address(address) => self.ram[address as usize] = value,
            InstructionArgument::AddressFromRegister(register) => {
                self.ram[self.registers[register as usize] as usize] = value
            }
            InstructionArgument::AddressOffset { address, register } => {
                let register_value = self.registers[register as usize];
                self.ram[address as usize + register_value as usize] = value
            }
            InstructionArgument::SpecialRegister(register) => match register {
                SpecialRegister::ProgramCounter => self.program_counter = value,
                SpecialRegister::StackPointer => self.stack_pointer = value,
                SpecialRegister::Overflow => self.overflow = value,
            },
            InstructionArgument::StackOperation(register) => match register {
                StackOperation::Peek => {
                    warn!("Detected write to a PEEK");
                    self.ram[self.stack_pointer as usize] = value
                }
                StackOperation::Pop => {
                    warn!("Detected write to a POP");
                    let address = self.stack_pointer;
                    self.stack_pointer += 1;
                    self.ram[address as usize] = value
                }
                StackOperation::Push => {
                    self.stack_pointer -= 1;
                    let address = self.stack_pointer;
                    self.ram[address as usize] = value
                }
            },
        }
    }
/// Stores the value to the specified address.
Stores the value to the specified address.
Stores the value to the specified address .
fn store_value(&mut self, address: InstructionArgument, value: Word) {
        match address {
            // Specification:
            // If any instruction tries to assign a literal value, the assignment fails silently.
            // Other than that, the instruction behaves as normal.
            InstructionArgument::Literal(_) => {
                trace!(
                    "Skipping literal assignment of word {word:04X} to literal {literal:04X}",
                    word = value,
                    literal = address.get_literal().unwrap()
                )
            }
            InstructionArgument::Register(register) => self.registers[register as usize] = value,
            InstructionArgument::Address(address) => self.ram[address as usize] = value,
            InstructionArgument::AddressFromRegister(register) => {
                self.ram[self.registers[register as usize] as usize] = value
            }
            InstructionArgument::AddressOffset { address, register } => {
                let register_value = self.registers[register as usize];
                self.ram[address as usize + register_value as usize] = value
            }
            InstructionArgument::SpecialRegister(register) => match register {
                SpecialRegister::ProgramCounter => self.program_counter = value,
                SpecialRegister::StackPointer => self.stack_pointer = value,
                SpecialRegister::Overflow => self.overflow = value,
            },
            InstructionArgument::StackOperation(register) => match register {
                StackOperation::Peek => {
                    warn!("Detected write to a PEEK");
                    self.ram[self.stack_pointer as usize] = value
                }
                StackOperation::Pop => {
                    warn!("Detected write to a POP");
                    let address = self.stack_pointer;
                    self.stack_pointer += 1;
                    self.ram[address as usize] = value
                }
                StackOperation::Push => {
                    self.stack_pointer -= 1;
                    let address = self.stack_pointer;
                    self.ram[address as usize] = value
                }
            },
        }
    }
fn store_value ( & mut self , address : InstructionArgument , value : Word ) { match address { // Specification: // If any instruction tries to assign a literal value, the assignment fails silently. // Other than that, the instruction behaves as normal. InstructionArgument :: Literal ( _ ) => { trace ! ( " " word value literal address get_literal ( ) unwrap ( ) ) } InstructionArgument :: Register ( register ) => self . registers [ register as usize ] = value , InstructionArgument :: Address ( address ) => self . ram [ address as usize ] = value , InstructionArgument :: AddressFromRegister ( register ) => { self . ram [ self . registers [ register as usize ] as usize ] = value } InstructionArgument :: AddressOffset { address , register } => { let register_value = self . registers [ register as usize ] ; self . ram [ address as usize + register_value as usize ] = value } InstructionArgument :: SpecialRegister ( register ) => match register { SpecialRegister :: ProgramCounter => self . program_counter = value , SpecialRegister :: StackPointer => self . stack_pointer = value , SpecialRegister :: Overflow => self . overflow = value , } , InstructionArgument :: StackOperation ( register ) => match register { StackOperation :: Peek => { warn ! ( " " ) ; self . ram [ self . stack_pointer as usize ] = value } StackOperation :: Pop => { warn ! ( " " ) ; let address = self . stack_pointer ; self . stack_pointer += 1 ; self . ram [ address as usize ] = value } StackOperation :: Push => { self . stack_pointer -= 1 ; let address = self . stack_pointer ; self . ram [ address as usize ] = value } } , } }
Stores the value to the specified address.
Stores the value to the specified address .
&mut self
address
InstructionArgument
value
Word