Some problem on opcode
Opcode::LOADF64 => {
let register = self.next_8_bits() as usize;
let number = f64::from(self.next_16_bits());
self.float_registers[register] = number;
},
Opcode::LOAD => {
let register = self.next_8_bits() as usize;
let number = u32::from(self.next_16_bits());
self.registers[register] = number as i32;
}
>>> load $1 #4000000000
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: Overflow }', libcore\result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: process didn't exit successfully: `target\debug\iridium.exe` (exit code: 101)
Some Problems.
- The load can only deal with 16 bits. When we use some bigger numbers, how to load them?
- When adding more types, we should add some corresponding type cast instructions.
- There are no other instruction can deal with string constant.
- Addressing mode, current load is
Immediate addressing
, we need to add such asDirect addressing
,Indirect addressing
,Register addressing
andregister indirect addressing
. And add moredirective
s to store these bigger number just like string constant. - There are no store opcode to store some data to heap or somewhere. You know, we need to call function to do something, like writing new data to desk. The register can't put so much data. We even cannot alter the data in heap.
And some questions.
- Why use different registers to store int and float rather than setting
General purpose register
? We can use rust's low-level api setting memory to avoid type constraints.
Could you share your plan with me? I think some things above need to be determined, otherwise the VM's core may will change frequently.
Edited by yjhmelody