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 pc : u64,
|
||||
pub sp: usize,
|
||||
pub int_reg : Register<i64>,
|
||||
pub fp_reg : Register<f32>,
|
||||
pub instructions : [u64 ; 100],
|
||||
pub main_memory : [u8 ; MEM_SIZE],
|
||||
pub shiftmask : [u64 ; 64]
|
||||
// futur taille à calculer int memSize = g_cfg->NumPhysPages * g_cfg->PageSize;
|
||||
@ -80,12 +80,9 @@ impl Machine {
|
||||
value >>= 1;
|
||||
}
|
||||
|
||||
// let int_reg = Register::<i64>::init();
|
||||
// let fp_reg = Register::<f32>::init();
|
||||
|
||||
Machine {
|
||||
pc : 0,
|
||||
instructions : [0 ; 100],
|
||||
sp: 0,
|
||||
int_reg : Register::<i64>::init(),
|
||||
fp_reg : Register::<f32>::init(),
|
||||
main_memory : [0 ; MEM_SIZE],
|
||||
@ -167,12 +164,17 @@ impl Machine {
|
||||
float localFloat;
|
||||
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");
|
||||
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 {
|
||||
@ -588,7 +590,7 @@ impl Machine {
|
||||
_ => { panic!("{} opcode non géré", inst.opcode)},
|
||||
}
|
||||
|
||||
machine.pc += 4;
|
||||
machine.pc += 8;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user