Age | Commit message (Collapse) | Author | |
---|---|---|---|
2023-10-16 | Added functionality to read and write instruction bytecode | Aryadev 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-16 | Made OP_HALT the only instruction to have the top byte filled | Aryadev Chavali | |
2023-10-16 | MOV now uses the stack, removed register member in inst_t | Aryadev 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-15 | Better checking of opcode types | Aryadev 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-15 | Remove parameter for INST_*POP | Aryadev Chavali | |
POP instructions do not require an operand: they're a unary operator. | |||
2023-10-15 | Set register parameter for inst_t to be a byte | Aryadev Chavali | |
We at most have 255 registers, so no need to have a word for it. | |||
2023-10-15 | Implemented a dynamically sized byte array | Aryadev Chavali | |
Pretty simple, want to ensure amortised constant big O so I use a REALLOC_MULT, which can be redefined if wished. | |||
2023-10-15 | Added macros for getting the maximum and minimum of two numbers | Aryadev Chavali | |
2023-10-15 | Moved vm_* code to its own file (runtime.(h|c)) | Aryadev Chavali | |
2023-10-15 | Implemented OP_PUSH_*_REGISTER in vm_execute | Aryadev Chavali | |
2023-10-15 | Make error TODOs specific to routine (for vm_mov_*) | Aryadev Chavali | |
2023-10-15 | Implemented vm_push_*_register routines | Aryadev Chavali | |
2023-10-15 | Renamed opcodes PUSH_*REG to PUSH_*_REGISTER | Aryadev Chavali | |
More precise in naming | |||
2023-10-15 | Rearranged opcodes (switched mov with push_reg) | Aryadev Chavali | |
This is so push opcodes are closer together | |||
2023-10-15 | Added instructions to push register values onto the stack | Aryadev Chavali | |
2023-10-15 | Added a register `ret`, a word, which holds the result of any instruction | Aryadev Chavali | |
Allows inspection at runtime of any routines result. | |||
2023-10-15 | Implemented vm_execute for pop routines | Aryadev Chavali | |
2023-10-15 | Made vm_pop_* routines more uniform by returning a data_t | Aryadev Chavali | |
2023-10-15 | Added instructions for popping differing types | Aryadev Chavali | |
Bit mask is 100. | |||
2023-10-15 | Added vm_execute support for mov routines | Aryadev Chavali | |
Similar to push routines support. Easy to extend by adding items to the MOV_ROUTINES array. | |||
2023-10-15 | Move push routines outside of vm_execute | Aryadev Chavali | |
2023-10-15 | Added opcodes for MOV and ability for instructions to hold registers | Aryadev Chavali | |
Pretty simple implementation | |||
2023-10-15 | Added registers to virtual machine | Aryadev Chavali | |
Registers for bytes, words and floats with routines to set them. | |||
2023-10-15 | Make push opcodes a specific bit set and add a NOOP opcode | Aryadev 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-15 | Split off instruction structure to its own file | Aryadev Chavali | |
2023-10-15 | Added an instruction setup | Aryadev 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-15 | stack.size -> stack.max | Aryadev Chavali | |
2023-10-15 | Main now loads a stack allocated byte array for VM stack | Aryadev Chavali | |
2023-10-15 | Added a routine to load a pointer as stack memory | Aryadev Chavali | |
2023-10-15 | Changed stack data to be a pointer | Aryadev 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-15 | Split off general types and structures into separate header | Aryadev Chavali | |
2023-10-15 | Changed stack.pointer->stack.ptr | Aryadev Chavali | |
2023-10-15 | Added floats (64 bit floating point) push and pop routines | Aryadev Chavali | |
Not machine independent, uses the underlying memcpy routine. | |||
2023-10-15 | Force big endian when pushing words | Aryadev 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-15 | Add macro for size of a word | Aryadev Chavali | |
Smaller number of changes necessary to change types. | |||
2023-10-15 | Added macro constructors for union types | Aryadev Chavali | |
2023-10-15 | Implemented functions to pop a byte and a word | Aryadev Chavali | |
2023-10-15 | Implemented a union type to make vm_push_* routines uniform | Aryadev Chavali | |
Function dispatch | |||
2023-10-15 | Added functions to push a byte and a word | Aryadev Chavali | |
Maybe I should make a union for the type, so I can dispatch via function pointers? | |||
2023-10-15 | Defined a simple virtual machine data structure | Aryadev Chavali | |
Currently just contains a "stack". | |||
2023-10-15 | Added some type aliases | Aryadev Chavali | |
Nicer to refer to a byte as "byte" rather than "uint8_t" | |||
2023-10-15 | Added a README | Aryadev Chavali | |
2023-10-15 | Remove unit tests from github workflow | Aryadev Chavali | |
We don't *have* unit tests lol. | |||
2023-10-15 | First 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. |