aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-10-21Implemented vm routines for OP_AND_*Aryadev Chavali
2023-10-21Implemented vm routines for OP_OR_*Aryadev Chavali
2023-10-21Implemented vm routines for OP_NOT_*Aryadev Chavali
2023-10-21Implemented opcode_as_cstr for NOT,OR,AND,XOR,EQAryadev Chavali
2023-10-21Introduced opcodes for NOT, OR, AND, XOR and EQAryadev Chavali
Does a bit level version of each of these.
2023-10-21Cleaned up and used macro magic to shorten the INST_* macrosAryadev Chavali
Instead of having 3 differing macros for each typed version of each opcode, just supply the type as a symbol to the macro, which will concatenated the type to all the places necessary. Relies on D(BYTE|HWORD|WORD) and OP_*_(BYTE|HWORD|WORD) being a consistent naming style.
2023-10-21Added vm_execute_all which executes an entire programAryadev Chavali
Handles OP_HALT
2023-10-21Wrote a quick tutorial on targeting the virtual machineAryadev Chavali
2023-10-21Wrote generalised procedures for interpret and assemblyAryadev Chavali
2023-10-21Helper functions for read/write instructions from darr or FILE*Aryadev Chavali
2023-10-21Helper darr functions to read/write bytes from FILE *Aryadev Chavali
2023-10-21Switched from floats to halfwordAryadev Chavali
Registers are now just words, with pushing from and moving to registers with specified subtypes just pushing those types into the word registers. That means there are 8 word registers which can act as 16 half word registers, which themselves can act as 64 byte registers.
2023-10-16Implemented vm_print_* routinesAryadev Chavali
Prints each aspect of the vm, and vm_print_all does it all.
2023-10-16Added opcode_as_cstr, opcode_type_as_cstr and inst_printAryadev Chavali
Pretty self explanatory, helps with logging.
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-16Fixed bug with get_opcode_data_typeAryadev Chavali
Pushed the bits one step too far.
2023-10-16Set opcode after reading parameters in inst_read_byteAryadev Chavali
2023-10-16Fixed error with OP_PUSH where bits weren't in the pattern of data_type_tAryadev Chavali
2023-10-16MOV and PUSH_*_REGISTER should only need bytes for their operandAryadev Chavali
We won't have more than 255 registers, so a byte is all that's necessary.
2023-10-16Added functionality to read and write instruction bytecodeAryadev Chavali
Uses some bit hacks to quickly check what data type an opcode may have by shifting down to units then casting it to a data_type_t. Not very well tested yet, we'll need to see now.
2023-10-16Made OP_HALT the only instruction to have the top byte filledAryadev Chavali
2023-10-16MOV now uses the stack, removed register member in inst_tAryadev Chavali
Instead of taking an operand and a register, mov just uses the stack for the operand. Therefore, there's no need for a register member in inst_t. As a result, PUSH_*_REGISTER now uses the operand for the register.
2023-10-15Better checking of opcode typesAryadev Chavali
Introduced an enum (opcode_type_t) for the masks and values of each opcode, which allows defining a single enum which checks an opcode by a opcode_type_t.
2023-10-15Remove parameter for INST_*POPAryadev Chavali
POP instructions do not require an operand: they're a unary operator.
2023-10-15Set register parameter for inst_t to be a byteAryadev Chavali
We at most have 255 registers, so no need to have a word for it.
2023-10-15Implemented a dynamically sized byte arrayAryadev Chavali
Pretty simple, want to ensure amortised constant big O so I use a REALLOC_MULT, which can be redefined if wished.
2023-10-15Added macros for getting the maximum and minimum of two numbersAryadev Chavali
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-15Renamed opcodes PUSH_*REG to PUSH_*_REGISTERAryadev Chavali
More precise in naming
2023-10-15Rearranged opcodes (switched mov with push_reg)Aryadev Chavali
This is so push opcodes are closer together
2023-10-15Added instructions to push register values onto the stackAryadev 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 instructions for popping differing typesAryadev Chavali
Bit mask is 100.
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 opcodes for MOV and ability for instructions to hold registersAryadev Chavali
Pretty simple implementation
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?