aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2024-04-09Done TODO: Comment coverage > lib > base.hAryadev Chavali
Pretty simple
2024-04-09Completed TODO: Rigid EndianAryadev Chavali
Just used the endian.h functions to convert host endian to and from big endian.
2023-11-05Current work on preprocessor implementationAryadev Chavali
Lots to refactor and test
2023-11-03Defined a `program` structureAryadev Chavali
Essentially a "program header", followed by a count, followed by instructions. Provides a stronger format for bytecode files and allows for better bounds checking on instructions.
2023-11-02Fixed bug where deleting a page meant not being able to allocate anotherAryadev Chavali
This was due to the beg or end page being not set correctly (dangling pointer).
2023-11-02Introduced instructions to engage with a call stackAryadev Chavali
Essentially you may "call" an absolute program address, which pushes the current address onto the call stack. CALL_STACK does the same thing but the absolute program address is taken from the data stack. RET pops an address off the call stack then jumps to that address.
2023-11-02Removed instruction OP_JUMP_REGISTERAryadev Chavali
Not necessary when you can just push the relevant word onto the stack then just do OP_JUMP_STACK.
2023-11-02Small fixesAryadev Chavali
2023-11-01Added instructions for MALLOC_STACK and SUBAryadev Chavali
MALLOC_STACK is a stack based version of MALLOC, SUB does subtraction.
2023-11-01Added stack based versions of MSET and MGETAryadev Chavali
Essentially they use the stack for their one and only operand. This allows user level control, in particular it allows for loops to work correctly while using these operands.
2023-11-01Added instruction to get the size of some allocationAryadev Chavali
This will allow for more library level code to be written. For example, say you wanted to write a generic byte level reversal algorithm for dynamically sized allocations. Getting the size of the allocation would be fundamental to this operation.
2023-11-01Added instructions for allocating, setting, getting and deleting heap memoryAryadev Chavali
One may allocate any number of (bytes|hwords|words), set or get some index from allocated memory, and delete heap memory. The idea is that all the relevant datums will be on the stack, so no register usage. This means no instructions should use register space at all (other than POP, which I'm debating about currently). Register space is purely for users.
2023-11-01heap_free_page returns true if page was successfully deletedAryadev Chavali
2023-11-01Heap now maintains a new page per allocationAryadev Chavali
Instead of having each page be an area of memory, where multiple pointers to differing data may lie, we instead have each page being one allocation. This ensures that a deletion algorithm, as provided, would actually work without destroying older pointers which may have been allocated. Great!
2023-11-01Added an arena allocatorAryadev Chavali
A page is a flexibly allocated structure of bytes, with a count of the number of bytes already allocated (used) and number of bytes available overall (available), with a pointer to the next page, if any. heap_t is a linked list of pages. One may allocate a requested size off the heap which causes one of two things: 1) Either a page already exists with enough space for the requested size, in which case that page's pointer is used as the base for the requested pointer 2) No pages satisfy the requested size, so a new page is allocated which is the new end of the heap.
2023-11-01Introduced a new mathematical operator MULTAryadev Chavali
Thankfully multiplication, like addition, is the same under 2s complement as it is for unsigned numbers. So I just need to implement those versions to be fine.
2023-11-01Changed inst bytecode methods for new register systemAryadev Chavali
As registers may be theoretically infinite in number, we should use the largest size possible when referring to them in bytecode (a word).
2023-11-01Set any new data allocated to 0 for clarityAryadev Chavali
This is only new data allocated, so it's a very careful procedure.
2023-11-01Removed OP_EQ signed versions as they're uselessAryadev Chavali
A negative number under 2s complement can never be equal to its positive as the top bit *must* be on. If two numbers are equivalent bit-by-bit then they are equal for both signed and unsigned numbers.
2023-10-31Added flag which forces the printing of hexesAryadev Chavali
Anything other than char (which can just use print.byte to print the hex) and byte (which prints hexes anyway), all other types may be forced to print a hex rather than a number if PRINT_HEX is 1.
2023-10-31Introduced 3 new union members to data_tAryadev Chavali
These new members are just signed versions of the previous members. This makes type punning and usage for signed versions easier than before (no need for memcpy).
2023-10-31Introduced signed versions of common typesAryadev Chavali
For each type T there is the signed version s_T
2023-10-31Moved inst module to libAryadev Chavali
As it has no dependencies on vm specifically, and it's more necessary for any vendors who wish to target the virtual machine, it makes more sense for inst to be a lib module rather than a vm module.
2023-10-29Added a "usage" message and colours for assemblerAryadev Chavali
Prints useful and pretty messages when verbose being at least 1.
2023-10-29Auto-fill copyright notice in examples/fib.cAryadev Chavali
2023-10-28Added macro to do safe subtractions on a wordAryadev Chavali
Default C just lets overflows occur for subtraction, so this macro will default to 0 if the subtraction causes an overflow.
2023-10-26Moved base functions from inst.c to dedicated fileAryadev Chavali
Doesn't make sense for them to be in the VM module when they have a more general purpose now.
2023-10-24Removed assertion in darr_read_fileAryadev Chavali
If an empty file is read, we want to deal with it in later user code rather than just failing immediately.
2023-10-23Added lib folder for general stuff, introduced as target to MakefileAryadev Chavali