aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
AgeCommit message (Collapse)Author
2023-10-23src->vm, Makefile is now a bit more abstracted and pretty coloursAryadev Chavali
Changed folder names for sake of clarity (will be introducing a new build target soon), and Makefile can now easily support more targets.
2023-10-23Rearrange what is printed in vm_print_allAryadev Chavali
First the program, then the registers then the stack.
2023-10-23Check for and handle errors when interpreting bytecodeAryadev Chavali
Prints an error message, returns a non zero code based on error code (255 - err). In main, I propagate this exit code.
2023-10-22Simple program which assembles instructions then executes themAryadev Chavali
2023-10-21Added vm_execute_all which executes an entire programAryadev Chavali
Handles OP_HALT
2023-10-21Wrote generalised procedures for interpret and assemblyAryadev Chavali
2023-10-16Added helper functions to read and write bytes from filesAryadev Chavali
Given a filepath, helper function to write a buffer of bytes to a file and to read a file completely as a buffer.
2023-10-16Made a sample program, loaded into VM and executedAryadev Chavali
Seems pretty nice to use, and it works according to GDB.
2023-10-15Moved vm_* code to its own file (runtime.(h|c))Aryadev Chavali
2023-10-15Implemented OP_PUSH_*_REGISTER in vm_executeAryadev Chavali
2023-10-15Make error TODOs specific to routine (for vm_mov_*)Aryadev Chavali
2023-10-15Implemented vm_push_*_register routinesAryadev Chavali
2023-10-15Added a register `ret`, a word, which holds the result of any instructionAryadev Chavali
Allows inspection at runtime of any routines result.
2023-10-15Implemented vm_execute for pop routinesAryadev Chavali
2023-10-15Made vm_pop_* routines more uniform by returning a data_tAryadev Chavali
2023-10-15Added vm_execute support for mov routinesAryadev Chavali
Similar to push routines support. Easy to extend by adding items to the MOV_ROUTINES array.
2023-10-15Move push routines outside of vm_executeAryadev Chavali
2023-10-15Added registers to virtual machineAryadev Chavali
Registers for bytes, words and floats with routines to set them.
2023-10-15Make push opcodes a specific bit set and add a NOOP opcodeAryadev Chavali
By default, a zero initialised set of instructions are NOOPs, which is great. Last two bits of a push opcode is always 01. Rest of the bits are used to distinguish between differing types of push. This makes it easier to inspect on the byte level what type of opcode we have.
2023-10-15Split off instruction structure to its own fileAryadev Chavali
2023-10-15Added an instruction setupAryadev Chavali
op_t provides opcodes, inst_t provides a wrapper with operands. vm_t carries around a pointer to a set of instructions, and vm_execute attempts to execute that one. I do some weird stuff here, and it's definitely not complete.
2023-10-15stack.size -> stack.maxAryadev Chavali
2023-10-15Main now loads a stack allocated byte array for VM stackAryadev Chavali
2023-10-15Added a routine to load a pointer as stack memoryAryadev Chavali
2023-10-15Changed stack data to be a pointerAryadev Chavali
I wouldn't really want this to be malloc'd per se, you could make a byte array on the stack then pass it into the VM?
2023-10-15Split off general types and structures into separate headerAryadev Chavali
2023-10-15Changed stack.pointer->stack.ptrAryadev Chavali
2023-10-15Added floats (64 bit floating point) push and pop routinesAryadev Chavali
Not machine independent, uses the underlying memcpy routine.
2023-10-15Force big endian when pushing wordsAryadev Chavali
This ensures that if one wanted to pop a word byte by byte, they'd go from least to most significance. Machine independent so that's nice.
2023-10-15Add macro for size of a wordAryadev Chavali
Smaller number of changes necessary to change types.
2023-10-15Added macro constructors for union typesAryadev Chavali
2023-10-15Implemented functions to pop a byte and a wordAryadev Chavali
2023-10-15Implemented a union type to make vm_push_* routines uniformAryadev Chavali
Function dispatch
2023-10-15Added functions to push a byte and a wordAryadev Chavali
Maybe I should make a union for the type, so I can dispatch via function pointers?
2023-10-15Defined a simple virtual machine data structureAryadev Chavali
Currently just contains a "stack".
2023-10-15Added some type aliasesAryadev Chavali
Nicer to refer to a byte as "byte" rather than "uint8_t"
2023-10-15First commit!Aryadev Chavali
This is a from the ground rework of an old project of the same name. I'm hoping to be more concerned with runtime efficiency, bytecode size and all those things that should actually matter for something that may host time/space critical code.