Remove instructions in favor of memory
This commit is contained in:
parent
5d7b35b9e6
commit
5af3a7e738
@ -58,9 +58,9 @@ impl Register<f32> {
|
|||||||
|
|
||||||
pub struct Machine {
|
pub struct Machine {
|
||||||
pub pc : u64,
|
pub pc : u64,
|
||||||
|
pub sp: usize,
|
||||||
pub int_reg : Register<i64>,
|
pub int_reg : Register<i64>,
|
||||||
pub fp_reg : Register<f32>,
|
pub fp_reg : Register<f32>,
|
||||||
pub instructions : [u64 ; 100],
|
|
||||||
pub main_memory : [u8 ; MEM_SIZE],
|
pub main_memory : [u8 ; MEM_SIZE],
|
||||||
pub shiftmask : [u64 ; 64]
|
pub shiftmask : [u64 ; 64]
|
||||||
// futur taille à calculer int memSize = g_cfg->NumPhysPages * g_cfg->PageSize;
|
// futur taille à calculer int memSize = g_cfg->NumPhysPages * g_cfg->PageSize;
|
||||||
@ -80,12 +80,9 @@ impl Machine {
|
|||||||
value >>= 1;
|
value >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let int_reg = Register::<i64>::init();
|
|
||||||
// let fp_reg = Register::<f32>::init();
|
|
||||||
|
|
||||||
Machine {
|
Machine {
|
||||||
pc : 0,
|
pc : 0,
|
||||||
instructions : [0 ; 100],
|
sp: 0,
|
||||||
int_reg : Register::<i64>::init(),
|
int_reg : Register::<i64>::init(),
|
||||||
fp_reg : Register::<f32>::init(),
|
fp_reg : Register::<f32>::init(),
|
||||||
main_memory : [0 ; MEM_SIZE],
|
main_memory : [0 ; MEM_SIZE],
|
||||||
@ -167,12 +164,17 @@ impl Machine {
|
|||||||
float localFloat;
|
float localFloat;
|
||||||
uint64_t value;*/
|
uint64_t value;*/
|
||||||
|
|
||||||
if machine.instructions.len() <= machine.pc as usize {
|
if machine.main_memory.len() <= machine.pc as usize {
|
||||||
println!("ERROR : number max of instructions rushed");
|
println!("ERROR : number max of instructions rushed");
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
let mut val: [u8; 8] = [0; 8];
|
||||||
|
for i in 0..8 {
|
||||||
|
val[i] = machine.main_memory[machine.pc as usize + i];
|
||||||
|
}
|
||||||
|
|
||||||
let inst : Instruction = decode(machine.instructions[machine.pc as usize]);
|
let val = u64::from_le_bytes(val);
|
||||||
|
let inst : Instruction = decode(val);
|
||||||
|
|
||||||
|
|
||||||
match inst.opcode {
|
match inst.opcode {
|
||||||
@ -588,7 +590,7 @@ impl Machine {
|
|||||||
_ => { panic!("{} opcode non géré", inst.opcode)},
|
_ => { panic!("{} opcode non géré", inst.opcode)},
|
||||||
}
|
}
|
||||||
|
|
||||||
machine.pc += 4;
|
machine.pc += 8;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user