#ifndef OPCODES_H #define OPCODES_H // Define opcodes for the Virtual Machine. // Each opcode is an integer constant used by the VM. enum { OP_HALT = 0, // Stop execution. OP_PUSH, // Push an immediate value onto the stack. (Operand: value) OP_POP, // Pop the top of the stack into a register. (Operand: register index) OP_LOAD, // Load an immediate value into a register. (Operands: register, value) OP_ADD, // Add two registers; store the result in the first register. (Operands: reg_dest, reg_src) OP_SUB, // Subtract second register from first; store result in the first register. (Operands: reg_dest, reg_src) OP_MUL, // Multiply two registers; store result in the first register. (Operands: reg_dest, reg_src) OP_DIV, // Divide first register by second; store result in the first register. (Operands: reg_dest, reg_src) OP_PRINT, // Print the value of a register. (Operand: register index) OP_JMP, // Unconditional jump to a specified program address. (Operand: address) OP_JMPZ, // Jump to a specified address if the given register is zero. (Operands: register, address) OP_CALL, // Call a function: push return address and jump. (Operand: address) OP_RET, // Return from a function call. (No operand) OP_CALL_OS // Enter the nested OS shell. (No operand) }; #endif // OPCODES_H