aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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
2023-10-25Separated lexer from main file in asmAryadev Chavali
2023-10-24Wrote lexer for assemblyAryadev Chavali
Pretty simple tokeniser, doesn't do a lot and needs to error check better.
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-23Starting development on assembly languageAryadev Chavali
2023-10-23Make root directory an include path, set #include's properlyAryadev Chavali
Easier to write includes now just using < with the module name, in comparison to using relative paths.
2023-10-23Reintroduced example fib.c via examples/ folderAryadev Chavali
2023-10-23Added lib folder for general stuff, introduced as target to MakefileAryadev Chavali
2023-10-23Implemented simple example of a for loop in mainAryadev Chavali
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-23Remove unnecessary log messageAryadev Chavali
2023-10-23Added and implemented OP_JUMP_IF_*Aryadev Chavali
Performs a jump when the (BYTE|HWORD|WORD) at the top of the stack is non zero.
2023-10-23Extracted code that performs a jump into its own routineAryadev Chavali
Checks if the operand given is a well defined program address, then performs the jump.
2023-10-23Fixed bug in vm_mov(byte|hword) where registers aren't set properlyAryadev Chavali
This is because we just OR the bits into the specific byte of the word. This means the previous state may leave artefacts as the OR doesn't clear the bits away. To do so, we apply a bit mask to clear the specified byte(s) of the word, then perform the OR.
2023-10-23Moved macros to extract nth (byte|hword) from a word to base.hAryadev Chavali
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-23Added an example program fib.cAryadev Chavali
This is simply a program with an embedded set of instructions which indefinitely computes and prints fibonacci numbers, computing them in pairs. Does it completely through the virtual machine rather than just hard C instructions. Also amended the Makefile to compile it. Required moving the main.c object file into the dependencies of $(DIST)/$(OUT). I should track the dependencies for fib.c and main.c as well.
2023-10-23Fixed bugs with ordering of bytes in some operationsAryadev Chavali
Also fixed an overflow error in vm_dup_word, where I underflow the index of vm->stack.data which causes a buffer overflow.
2023-10-23Added and implemented OP_PRINT*Aryadev Chavali
Here is where we may have differing interpretations of what the bits in the data pile may actually mean. This in particular refers to printing the signed or unsigned versions of the bits given. Also, interpreting some byte as a character or just a raw number.
2023-10-23Fixed bug where vm_print_program listing for program was incorrectAryadev Chavali
Only happens when vm_print_program(STDERR), as STDERR occurs before STDOUT on Emacs. So while the lines would print, no instructions would follow. This fixes that by using fp.