forked from Lea/invadeez
move instructions
This commit is contained in:
parent
ed05dd5d30
commit
6abdd5dff3
|
@ -1 +1,2 @@
|
|||
pub mod arithmetic;
|
||||
pub mod transfer;
|
||||
|
|
10
src/emulator/instructions/transfer.rs
Normal file
10
src/emulator/instructions/transfer.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
use crate::{get_register, set_register, EmulatorState, Register};
|
||||
|
||||
pub fn mov(src: Register, dest: Register, state: &mut EmulatorState) {
|
||||
let data = get_register(src, state);
|
||||
set_register(dest, data, state);
|
||||
}
|
||||
|
||||
pub fn mvi(byte: u8, dest: Register, state: &mut EmulatorState) {
|
||||
set_register(dest, byte, state);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
use instructions::arithmetic;
|
||||
use instructions::{arithmetic, transfer};
|
||||
use std::{env, fs};
|
||||
|
||||
use crate::structs::*;
|
||||
|
@ -72,6 +72,21 @@ fn tick(state: &mut EmulatorState) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Data Transfer */
|
||||
// MVI
|
||||
0x06 | 0x0e | 0x16 | 0x1e | 0x26 | 0x2e | 0x36 | 0x3e => transfer::mvi(
|
||||
next_byte(),
|
||||
register_from_num((instruction & 0x38) >> 3),
|
||||
state,
|
||||
),
|
||||
|
||||
// MOV
|
||||
0x40..=0x7f => transfer::mov(
|
||||
register_from_num(instruction & 0x7),
|
||||
register_from_num((instruction & 0x38) >> 3),
|
||||
state,
|
||||
),
|
||||
|
||||
/* Maths */
|
||||
// INR
|
||||
0x04 => arithmetic::inr(Register::B, state),
|
||||
|
|
Loading…
Reference in a new issue