summaryrefslogtreecommitdiff
path: root/lexer.c
AgeCommit message (Collapse)Author
2021-05-08Add support for saving to a string buffer inmrb0nk500
parse_quote(). This allows for replacing the string parsing code in handle_directive() with a call to parse_quote().
2021-05-08Fixed a bug with how local symbols with a depthmrb0nk500
greater than one are handled. It wasn't getting the correct depth when relative local symbols were used. So to account for that, it adds the relative depth (number of '@'s in a row), with the absolute depth (number of '.'s), to get the true scope depth.
2021-02-25- Implemented the multiply expression into the assembler.mrb0nk500
- Implemented support for the SIB addressing mode into the assembler. SIB is short for "Scale Index, and Base", and works much like x86's version of SIB (scale*index+base), although my version supports any scale value between 1, and 256. - Redid the line shifting routine in SuBEditor. It now uses memcpy, and memset to do that, and also supports shifting the line left, or right by any number of characters.
2021-02-13- Reverted back one commit before the previous commit.mrb0nk500
This is because the previous commit actually created a bug, rather than fixing one. - Added JMP, and JSR to the ortho extension, and implemented them both in the assembler, and emulator.
2021-02-11Fixed a bug in the lexer.mrb0nk500
2021-02-11Simplified the expression parser.mrb0nk500
I was finally able to figure out how to implement the expression parser into two functions. It can be done in a single function, but I used two functions to make it easier to read.
2021-02-08Completly rewrote the expression handler.mrb0nk500
It's now separate from the lexer, and was designed to make it both easier to understand, and easier to parse.
2021-01-27- Fixed some bugs in the emulator.mrb0nk500
- Started work on implementing the Super VIA emulation. - Added support for disabling disassembly per instruction, when in debug mode. - Did some more work on rewriting the SuB Suite to work with the new calling convention. - Rewrote the symbol handling code in the emulator's assembler, to make it both simpler, and to add support for arbitrarily deep symbol scopes. - Added support for arbitrarily deep local symbol scopes. For example, to declare a symbol of depth 2, you add two '@' characters to the start of the symbol name. In other words, the number of '@' characters before the symbol name is what determines the scope of that symbol. And to use a symbol thats outside the current scope, you would use the same syntax as using a struct member, so you would do `global.local`.
2020-12-09- Implemented support for the `set` instruction in themrb0nk500
assembler. The main thing I had to do was implement the parsing of the condition code token, but that wasn't hard to do, since I had already done the lexing part already. The next thing to do, will be to design a calling convention for Sux.
2020-12-08- Implemented support for the Orthogonal extension intomrb0nk500
both the assembler, and the emulator. I finally figured out how I could get support for the Ortho extension implemented into the old assembler. The only reason for doing this, is to buy me some while I start work on the new assembler, and to help me get an idea for how to do the same in the new assembler.
2020-11-20- Implemented support for Sux's base extension.mrb0nk500
This is the biggest milestone I've reached for this project, since the base extension changes alot about what Sux can do by default, and now makes it a viable instruction set for modern day use, when compared with other instruction sets.
2020-10-04- Added support for reading, and writing outside themrb0nk500
emulator's memory. All reads outside of the emulator's memory give back $/0xFF bytes, while all writes outside of the emulator's memory are ignored. - Implemented malloc(), and free() in the SuB Suite. In order to do this, I had to add support for a heap, which I did by reserving the first 3 banks of the address space (the first 192K), and by adding a routine that finds the end of the RAM. In this case, I set the starting address for the routine at bank 3 (bank 4 with one indexing), but, the routine's starting address isn't hardcoded, and thus, any starting address can be passed as an argument. The routine uses the fact that we can now read/write outside the emulator's memory, and also uses the fact that writing outside the emulator's memory will be ignored, and that reading outside the emulator's memory will always read $/0xFF bytes, and uses that to signal that it's reached the end of the RAM. - Added a test program for getting the size of RAM starting at address $/0x20000.
2020-09-24- Fixed some more bugs with struct, and union handling.mrb0nk500
2020-09-21- Fixed some issues with how structs, and unions weremrb0nk500
handled. - Added a function called fix_symtree(), which when called. will rearrange the symbol tree based on the order they're declared in by the token stream. The reason I wrote this, was to make sure the symbol tree could be printed correctly. - Optimized print_symtree() to now use tail recursion. - Started adding all of the SuB Suite's structs.
2020-09-18- Added support for structs, and unions to themrb0nk500
emulator's assembler. - Make the symbol table a doublely linked list, in both ways. - Optimized the memcopy() function. - Changed the benchmark timing, to now use a timer, and stops once the timer reaches zero. When the timer hits zero, it sends SIGALRM to the main function, which tells the emulator that the benchmark is done.
2020-08-30- Did some more work on SuBAsm's lexer.mrb0nk500
- Optimized the memory read, and write functions. - Made the emulator faster, and cleaner in general.
2020-08-17- Fixed some bugs in the emulator's assembler.mrb0nk500
- Simplified the effective address functions. - Made SuBEditor a bit faster. - JSR, and RTS now support using the RS prefix, which is used to specify the return address size, with an RS prefix of 0 being a return address size of 64 bits, rather than 8 bits.
2020-08-11- Changed the spacing format to now store the number ofmrb0nk500
spaces, and tabs before the current token. Along with also now storing a sub-token count which is used in case the token's secondary id is meant to be treated as a sub-token. - Added suppor for saving the number of blank lines before the current tokenized line.
2020-08-09Added the bitwise OR, left shift, and right shiftmrb0nk500
expressions to the emulator's assembler.
2020-08-08- Refactored the opcode table, in order to make themrb0nk500
instruction formatting simpler. - Refactored the instruction table of the emulator's assembler, it now has two parts, the addressing mode bits, and the base value. The base value is what's used to generate the actual opcode, with the addressing mode bits telling the assembler what addressing modes this instruction supports. The reason for doing this was to use less space. For comparison, the previous version used 870 bytes for the instruction table, while the new version uses only 222 bytes. The new version is nearly 4 times smaller than the pervious version. - The B register based ALU instructions now use their own addressing mode, and are specified by using 'b' as the operand for those instructions. For example, to add the Accumulator with the B register, you now use "ADC B" instead of "AAB".
2020-08-08Did a ton of stuff.mrb0nk500
- Changed the file structure of the SuB Suite, so that all variable declarations, symbols, and constants are in a single file. - Moved the C library functionss into a separate file, and made them use stack frames. - Added support for using the emulator's assembler for realtime debugging, to enter it, get in to stepping mode by pressing Ctrl+s, press any other key, then press F1, The reason for having to press some other key before pressing F1 is because it only allows entering the assembler when the keyboard is not ready. - Added the ".res" directive to the emulator's assembler, the ".res" directive tells the assembler to reserve however many bytes specified by the operand. - Fixed some bugs in the emulator's assembler.
2020-07-06- Implemented a new opcode table.mrb0nk500
- Added a new preifx called the OF prefix, which adds the contents of a specific register to the current operand. - Added a table generator, which parses opcode table csv files.
2020-06-22Did some more stuff.mrb0nk500
- Fixed some bugs in the emulator's assembler. - Worked on SuBAsm's lexer some more. - Created a new directory for the SuB suite, and moved all of the SuB suite's files in there.
2020-06-13Make the registers single 64 bit uints, and convertmrb0nk500
all the value getting, and setting into macros. This is to make the codebase cleaner.
2020-06-11Did some more stuff.mrb0nk500
- Fix some bugs with strings. - Started to refactor the instruction functions. - Added support for using RS prefixes on the memory based increment, and decrement instructions. - Started work on SuBAsm's lexer. Have fun looking at this, BieHDC. :)
2020-06-01Did some more refactoring to the assembler.mrb0nk500
- Refactored the symbol, and fixup table to now use a linked list - Added support for local symbols to the assembler. - Rewrote SuBEditor, and SuBAsm to use local symbols.
2020-05-30Refactored the assembler a bit more, in order to removemrb0nk500
code duplication. The assembler now uses pre-tokens, which are smaller tokens, that make up the larger tokens.
2020-05-28Refactored the assembler, yet again, and implementedmrb0nk500
support for comma separated values. The assembler now uses a linked list of tokenized lines, each containing a linked list of tokens for that line. I also moved all of the large tables into the higher parts of memory, in order to free up the lower part of memory for the user. Comma sepparated values only work with directives, and only with the byte", word, dword, and qword directives. I also added support for getting the upper, and lower halves of an address. The tokens for both of those are '<', and '>' respectively.
2020-05-18Fixed some more bugs in the assembler.mrb0nk500
2020-05-18Did alot of stuff while I was up at the family trailer.mrb0nk500
- Moved the large enums, and large tables into separate header files. - Added enums for implementing the base extension - Fixed a bug in the assembler. - Worked more on SuBAsm.
2020-05-09Added support for single quote marks to the emulator'smrb0nk500
assembler. Single quote marks works in the assembler just like they do in C, except that it only supports a handful of escaped characters, like '\n', and '\r'.
2020-05-06Removed some duplicate code in the assembler, and mademrb0nk500
the processor status register, a union now.
2020-04-27Added support for including source files to themrb0nk500
emulator's assembler. And removed three pointers, and the linewrap table from zero page, in SuBEditor. I moved the linewrap table to address $1000. And because of finally adding include support to the assembler, I can now start work on SuBAsm!
2020-04-19Removed most of the commented code, and optimized themrb0nk500
emulator some more. I optimized the emulator by replacing the main loop from a conditional while loop, to an unconditional for loop.
2020-04-17Made both the assembly language monitor, and themrb0nk500
emulator smaller, and faster. I am also starting to make SuBEditor's source code more readable.
2020-04-09Completely changed the assembler.mrb0nk500
It now has a lexer/tokenizer, along with a parser. I have also made the emulator even smaller.