This commit is contained in:
Nilton Constantino
2026-01-31 01:18:42 +00:00
parent ef8b7b524a
commit 180c7e19e0
8 changed files with 242 additions and 28 deletions
+1
View File
@@ -11,6 +11,7 @@ pub fn operand_size(opcode: OpCode) -> usize {
match opcode {
OpCode::PushConst => 4,
OpCode::PushI32 => 4,
OpCode::PushBounded => 4,
OpCode::PushI64 => 8,
OpCode::PushF64 => 8,
OpCode::PushBool => 1,
+1 -1
View File
@@ -39,7 +39,7 @@ pub fn disasm(rom: &[u8]) -> Result<Vec<Instr>, String> {
let mut operands = Vec::new();
match opcode {
OpCode::PushConst | OpCode::PushI32 | OpCode::Jmp | OpCode::JmpIfFalse | OpCode::JmpIfTrue
OpCode::PushConst | OpCode::PushI32 | OpCode::PushBounded | OpCode::Jmp | OpCode::JmpIfFalse | OpCode::JmpIfTrue
| OpCode::GetGlobal | OpCode::SetGlobal | OpCode::GetLocal | OpCode::SetLocal
| OpCode::PopN | OpCode::Syscall | OpCode::GateLoad | OpCode::GateStore => {
let v = read_u32_le(&mut cursor).map_err(|e| e.to_string())?;
+6
View File
@@ -56,6 +56,10 @@ pub enum OpCode {
/// Removes `n` values from the stack.
/// Operand: n (u32)
PopN = 0x18,
/// Pushes a 16-bit bounded integer literal onto the stack.
/// Operand: value (u32, must be <= 0xFFFF)
/// Stack: [] -> [bounded]
PushBounded = 0x19,
// --- 6.3 Arithmetic ---
@@ -225,6 +229,7 @@ impl TryFrom<u16> for OpCode {
0x16 => Ok(OpCode::PushBool),
0x17 => Ok(OpCode::PushI32),
0x18 => Ok(OpCode::PopN),
0x19 => Ok(OpCode::PushBounded),
0x20 => Ok(OpCode::Add),
0x21 => Ok(OpCode::Sub),
0x22 => Ok(OpCode::Mul),
@@ -290,6 +295,7 @@ impl OpCode {
OpCode::PushF64 => 2,
OpCode::PushBool => 2,
OpCode::PushI32 => 2,
OpCode::PushBounded => 2,
OpCode::Add => 2,
OpCode::Sub => 2,
OpCode::Mul => 4,