forked from Lea/invadeez
shld and lhld
This commit is contained in:
parent
2fff8d2448
commit
eb993eb1b4
|
@ -1,4 +1,4 @@
|
||||||
use crate::{get_register, set_register, structs::get_register_pair, EmulatorState, Register};
|
use crate::{get_register, get_register_pair, set_register, EmulatorState, Register};
|
||||||
|
|
||||||
/// Move (copy) value from source to destination register
|
/// Move (copy) value from source to destination register
|
||||||
pub fn mov(src: Register, dest: Register, state: &mut EmulatorState) {
|
pub fn mov(src: Register, dest: Register, state: &mut EmulatorState) {
|
||||||
|
@ -22,3 +22,15 @@ pub fn ldax(register: Register, state: &mut EmulatorState) {
|
||||||
let address = get_register_pair(register, state);
|
let address = get_register_pair(register, state);
|
||||||
state.a = state.memory[address as usize];
|
state.a = state.memory[address as usize];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Store a 16-bit word from H and L to the specified address
|
||||||
|
pub fn shld(address: u16, state: &mut EmulatorState) {
|
||||||
|
state.memory[address as usize] = state.l;
|
||||||
|
state.memory[address as usize + 1] = state.h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Load a 16-bit word into H and L from the specified address
|
||||||
|
pub fn lhld(address: u16, state: &mut EmulatorState) {
|
||||||
|
state.l = state.memory[address as usize];
|
||||||
|
state.h = state.memory[address as usize + 1];
|
||||||
|
}
|
||||||
|
|
|
@ -90,6 +90,14 @@ fn tick(state: &mut EmulatorState) {
|
||||||
0x32 => state.memory[state.next_word() as usize] = state.a, // STA
|
0x32 => state.memory[state.next_word() as usize] = state.a, // STA
|
||||||
0x3a => state.a = state.memory[state.next_word() as usize], // LDA
|
0x3a => state.a = state.memory[state.next_word() as usize], // LDA
|
||||||
|
|
||||||
|
// 16-bit transfer instructions
|
||||||
|
0x01 => set_register_pair(Register::B, state.next_word(), state), // LXI B
|
||||||
|
0x11 => set_register_pair(Register::D, state.next_word(), state), // LXI D
|
||||||
|
0x21 => set_register_pair(Register::H, state.next_word(), state), // LXI H
|
||||||
|
0x31 => set_register_pair(Register::SP, state.next_word(), state), // LXI SP
|
||||||
|
0x22 => transfer::shld(state.next_word(), state), // SHLD
|
||||||
|
0x2a => transfer::lhld(state.next_word(), state), // LHLD
|
||||||
|
|
||||||
/* Maths */
|
/* Maths */
|
||||||
// INR
|
// INR
|
||||||
0x04 => arithmetic::inr(Register::B, state),
|
0x04 => arithmetic::inr(Register::B, state),
|
||||||
|
|
Loading…
Reference in a new issue