initial commit
This commit is contained in:
27
include/vm.h
Normal file
27
include/vm.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef VM_H
|
||||
#define VM_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// Increase registers and memory sizes for advanced programs.
|
||||
#define NUM_REGISTERS 16 // Number of general-purpose registers.
|
||||
#define STACK_SIZE 512 // Maximum stack size.
|
||||
#define PROGRAM_SIZE 2048 // Maximum program size (number of ints).
|
||||
|
||||
// VM structure definition.
|
||||
typedef struct VM {
|
||||
int registers[NUM_REGISTERS]; // General purpose registers.
|
||||
int stack[STACK_SIZE]; // Stack memory.
|
||||
int sp; // Stack pointer (index of next free slot).
|
||||
int program[PROGRAM_SIZE]; // Bytecode program memory.
|
||||
size_t program_size; // Number of ints in the loaded program.
|
||||
size_t pc; // Program counter.
|
||||
} VM;
|
||||
|
||||
// Function prototypes for the VM.
|
||||
void init_vm(VM *vm);
|
||||
int load_program(VM *vm, const int *program, size_t size);
|
||||
void run_vm(VM *vm);
|
||||
|
||||
#endif // VM_H
|
||||
|
||||
Reference in New Issue
Block a user