aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-11-01Makefile now has green colours for binaries and yellow for object filesAryadev Chavali
2023-11-01Enable clang-format-mode in dir-localsAryadev Chavali
2023-11-01Clearer VERBOSE messagesAryadev Chavali
2023-11-01Parser now uses updated lexerAryadev Chavali
Much simpler, uses a switch case which is a much faster method of doing the parsing. Though roughly equivalent in terms of LOC, I feel that this is more extensible
2023-11-01Lexer now returns more descriptive tokensAryadev Chavali
More useful tokens, in particular for each opcode possible. This makes parsing a simpler task to reason as now we're just checking against an enum rather than doing a string check in linear time. It makes more sense to do this at the tokeniser as the local data from the buffer will be in the cache most likely as the buffer is contiguously allocated. While it will always be slow to do linear time checks on strings, when doing it at the parser we're having to check strings that may be allocated in a variety of different places. This means caching becomes a harder task, but with this approach we're less likely to have cache misses as long as the buffer stays there.
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 new macro for bitwise comparison constructionAryadev Chavali
This pushes a datum of the same type as the operands, which is why it cannot use the comparator macro as that always pushes bytes.
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-31Allow hex literals for numbersAryadev Chavali
As strto(ul|ll) allow the parsing of hex literals of the form `0x`, we allow lexing of hex literals which start with `x`. They're lexed into C hex literals which work for strtol.
2023-10-31Use macros to stop duplication of codeAryadev Chavali
I've made a single macro which defines a function through some common metric, removing code duplication. Not particularly readable per se, but using a macro expansion in your IDE allows one to inspect the code.
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-31Remove duplicated codeAryadev Chavali
2023-10-31Implemented all the comparatorsAryadev Chavali
So much reused code, I definitely need to find a way to make this cleaner.
2023-10-31Use standardised signed version of word type from base.hAryadev Chavali
2023-10-31Introduced signed versions of common typesAryadev Chavali
For each type T there is the signed version s_T
2023-10-31Fixed README for change in inst moduleAryadev Chavali
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-31Implemented new types of EQ, forced all comparators to push bytesAryadev Chavali
Just need to call their unsigned versions. All comparators should push bytes as it makes return types uniform.
2023-10-31vm_execute_all: Print every cycle on VERBOSE >= 2, just print final state ↵Aryadev Chavali
otherwise Changed VERBOSE checks to ensure a degree of information.
2023-10-31Created routines for new comparator opcodes (not implemented)Aryadev Chavali
Will cause error if used currently, which is fine.
2023-10-31Introduced new instructions for comparisonAryadev Chavali
Comparing signed and unsigned versions of numbers. Same for EQ as well. Notice the irregular pattern of BYTE, CHAR, INT, HWORD,LONG,WORD as OPCODE_IS_TYPE requires the subcodes to be surrounded by BYTE and WORD.
2023-10-31asm/main logs are now indented and look prettierAryadev Chavali
2023-10-31Lexer now returns errors on failureAryadev Chavali
Currently only for invalid character literals, but still a possible problem.
2023-10-31parse_word deals with characters nowAryadev Chavali
Just takes the character literally as a number.
2023-10-31Changed asm/parser instruction push-reg->push.regAryadev Chavali
2023-10-29Make Verbose a universal flagAryadev Chavali
All objects target LIB anyway, so VERBOSE is a universal macro for this code base.
2023-10-29Added a "usage" message and colours for assemblerAryadev Chavali
Prints useful and pretty messages when verbose being at least 1.
2023-10-29Fixed bug where JUMP_REGISTER couldn't be in bytecode readAryadev Chavali
2023-10-29Fixed bug where reading operand bytecode may stop prematurelyAryadev Chavali
This is due to checking for equality instead of just greater than in darr->used against darr->available.
2023-10-29Added some examples to instruction-test for positive/negative literalsAryadev Chavali
Use the push.* instructions to see this.
2023-10-29Introduced an example source file for all instructionsAryadev Chavali
Provides calling conventions, ensures parser and lexer are working correctly. Will be updated as more instructions are introduced and supported in the assembler.
2023-10-29Auto-fill copyright notice in examples/fib.cAryadev Chavali
2023-10-28Introduce error reporting in asm/mainAryadev Chavali
Pretty simple implementation, I've stopped printing the tokens cos I think the lexer is done.
2023-10-28asm/parser supports all opcodes, introduced parse errorsAryadev Chavali
Introduced some functions to parse differing types of opcodes. Use the same style of a.b.c... for namespacing or type specification for certain opcodes. Bit hacky and not tested, but does work. Parse errors can be reported with an exact location using the token column, line.
2023-10-28Ignore comments (using semicolons) in lexerAryadev Chavali
Easier to do it here than at the parser.
2023-10-28Introduced a column and line for each tokenAryadev Chavali
Accurate error reporting can be introduced using this.
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-26Plugged in asm/parser to asm/mainAryadev Chavali
Just prints instructions so far.
2023-10-26Implemented a rudimentary parser with support for 4 instruction typesAryadev Chavali
2023-10-26Added support in lexer for negative numbersAryadev Chavali
Though we deal with unsigned numbers internally, it should be possible to read and manipulate negative numbers through 2s complement. Later on we'll add support for signed operations via 2s complement, so this should be allowed.
2023-10-26Fixed bug where printing hword of an instruction prints number not hexAryadev Chavali
This is an easy fix.
2023-10-26asm/main now uses TOKEN_STREAM_ATAryadev Chavali
2023-10-26Lexer forces uppercase for symbolsAryadev Chavali
2023-10-26Updated README for targeting VMAryadev Chavali
2023-10-26Makefile now prints dependencies on successful compilationAryadev Chavali
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-26vm/main takes a filename as input to execute bytecodeAryadev Chavali
Also prints a usage for incorrect usage.
2023-10-26Auto fill licensesAryadev Chavali
2023-10-26Unified literal for numbers, main program now tokenisesAryadev Chavali
2023-10-25Started working on a parserAryadev Chavali
No implementations yet