c95d739e16
Updated the parser to handle treating variables as expressions. Updated the symbols table to handle computing the values of variables.
ast
glm942023-09-07 21:29:58 -05:00
21c2bf046e
Wrote the very first part of the tree walking code, more just to make sure the logic is sound.
glm942023-09-01 10:04:21 -05:00
b810d7803c
Updated the parser to create an expression tree for symbols declared via .db directives. Scanner now see some math operators as 'punctuation'.
glm942023-08-31 23:27:33 -05:00
9e178ca3da
Build a quick draft of how the symbol value should be computed.
glm942023-08-25 01:27:22 -05:00
82b2136a69
Started to work on setting up Symbol value resolution which will be based on an abstract syntax tree that can handle undefined values if unknown symbols are used in an expression.
glm942023-08-25 00:21:19 -05:00
4bb90da6df
Make the compiler options a bit more strict about C compliance (in other words I just learned about these flags and they seem to be ideal for this project).
main
glm942023-08-25 00:15:18 -05:00
4af2527806
Updated the structure of symbols and tokens to hopefully help make computing symbol values easier.
glm942023-08-07 01:18:01 -05:00
65383cded2
Updated the way symbols are represented and how they are marked as resolved.
glm942023-07-09 22:04:55 -05:00
9c8fe17c8f
Minor code cleanup and added an extra flag to the compiler. If a symbol is a label it will now hold a reference to the opcode and by extension the offset into the file it points to.
glm942023-07-06 19:39:03 -05:00
2918f2964d
Fixed a bug where words weren't being written to 'memory' correctly.
glm942023-06-24 18:00:13 -05:00
980b0449fc
Fixed a bug with the parse discarding identifier tokens when parsing a COPY instruction. Added the first batch of code to encode the final token array to a binary form.
glm942023-06-22 20:22:20 -05:00
6741dde7ce
Hooked up the program counter in the parser to set the memory offset of symbols, well labels to be more acurrate.
glm942023-06-18 14:51:37 -05:00
c6e6e2c5dc
Fixed a bug in the parser not setting an identifier when one is used with a CMP and fixed a bug in the example assembly program.
glm942023-06-18 12:11:30 -05:00
0eaa5527ea
Updated the parser to be able to handle the changes made to the ISA.
glm942023-06-18 00:50:18 -05:00
403439def4
Updated the opcode listing and 'fixed' the code to at least compile, but obviously I'll need to rework how the new copy instructions are to be parsed. Fixed some errors in the documentation where I skipped some hex numbers and added a copy immediate op.
glm942023-06-17 21:15:08 -05:00
0fd6413d81
Updated the instruction set and mapped out the opcodes as well as wrote a sample program to see if the ISA was complete enough to build a trivial program.
glm942023-06-17 16:56:42 -05:00
a9e57132be
Fixed issue #1 Scanner Bug where the start of comment would become part of an identifier or throw off number parsing.
glm942023-04-14 13:28:44 -05:00
aa3888b578
Fixed up the RemoveCurrentToken function which was causing all sorts of bugs, and added the ability to delcare a data byte, '.db', to have a variable's address as a value. This will be needed for building up an interrupt table at least with the version I have in mind.
glm942023-04-04 22:14:17 -05:00
c3d12da54a
Added some ideas to the encoding scheme to be used by the processor.
glm942023-03-30 13:21:25 -05:00
288ba9f9cb
Updated the docs to include new jump operands and setup the assembler to handle parsing all the jump instructions.
glm942023-03-29 22:30:12 -05:00
a9a50055a4
Updated the parser to validate most of the opcodes. NOP falls through via the default case since it takes no parameters but the jump instructions need some thought before proceeding.
glm942023-03-29 20:57:04 -05:00
2e888913be
Added support for the STORE directive.
glm942023-03-29 12:57:07 -05:00
ee60d14570
Refactored the code and added expect functions to make the code flow a bit nicer.
glm942023-03-29 12:41:53 -05:00
fa12a04bb3
Moved some of the grunt work to their own functions to clean the code up a bit.
glm942023-03-28 22:14:31 -05:00
2d7aad1617
Fixed a bug with labels not advancing the parser after being processed resulting in a redefinition error.
glm942023-03-28 12:41:56 -05:00
ae03991fa5
Fixed some parser bugs processing the syntax for some LOAD instruction types.
glm942023-03-27 22:22:01 -05:00
95ed2143ea
Updated the parser to handle processing a simple load byte instruction. Added the LODB opcode to the opcode enum listing and updated the Scanner to look for 'byte' and mark it as a directive.
glm942023-03-24 23:24:24 -05:00
f96e1c6380
Added grammar checking for DB declarations.
glm942023-03-08 21:38:33 -06:00
4f9f4202b2
Wrote the first batch of directive handling code, so far just handling creating variables.
glm942023-03-08 13:25:46 -06:00
4230708f15
Added a function to remove an item from the generic list, which is mainly used for the tokens.
glm942023-03-07 21:31:14 -06:00
5e9e1bdec4
Massive refactoring to simplify this whole setup. The Token List will be modified in place and reused in the Parser to normalize the list and generate a symbols table. Normalizing the token list will make sure the syntax is valid and the symbols table will have the relative offsets and length of symbol values. At least this is all the plan but one step at a time.
glm942023-03-06 21:51:36 -06:00
1b246e90bc
Started rethinking how this machine should behave. Updated and refactoring some things with a few new ideas.
glm942023-02-23 22:22:07 -06:00
9a602824b6
Added all the instructions supported to a structure to help make validation of parameters easier.
glm942022-10-18 21:14:50 -05:00
6d6bf1cbaf
Wrote the first step for the binary output. Doesn't handle instruction pointer symbols yet since those emit addresses that still need to be computed.
glm942022-10-10 18:36:38 +00:00
bca2ad67f1
Fixed a bug with single parameter instructions that land at the end of a file expecting a comma.
glm942022-10-08 22:02:51 -05:00
fd44e03b1b
Updated the Parser to try and give 'AddressParameter's more meaning depending on the SymbolType.
glm942022-10-08 18:21:11 -05:00
48a77950be
Updated the way string symbols are handled, allowing the programmer to terminate a string with any byte or none at all.
glm942022-10-08 16:35:05 -05:00
8b6edc39be
Updated the Parser to handle the variable declaration directive.
glm942022-10-08 16:15:10 -05:00
c142d2c6d0
Cleaned up the Symbol struct and updated code accordingly.
glm942022-10-08 14:43:00 -05:00
4b08707e67
Cleaned up the list implementation so as to NOT copy items into a new buffer.
glm942022-10-07 20:46:55 +00:00
d3d2b06dbd
Redesigning the way the Symbol's represent string declaration (the .db msg 'Hello World' type of declarations).
glm942022-10-06 21:33:29 -05:00
bdb4d2b241
Updated the way Instructions keep track of symbols. Only their name is important but we need the Symbols to be able to track which Instruction they point to (if they do that is, i.e. a label symbol).
glm942022-10-06 21:11:22 -05:00
d53833c25f
Added some debug print out for the instruction list and a helper function to get a string for any Registers enum.
glm942022-10-06 21:05:57 +00:00
f38da9cc74
A bit of cleanup.
glm942022-10-04 21:05:15 +00:00
33309a2759
Updated the Instruction's structure and updated the Parser accordingly.
glm942022-10-04 20:37:47 +00:00
1f7989533b
Fixed a bug in the SymbolsTable where it wouldn't update its size.
glm942022-10-03 20:11:04 -05:00
cd1258a724
Fixed various Parser bugs.
glm942022-10-03 19:58:44 -05:00
be91e3c112
Updated the parser to better handle parameters, sort of and including a string length assembly program to use as a test for the whole assembler.
glm942022-10-03 21:26:28 +00:00
706f480e31
The Scanner will now check for empty lines (is the previous token and the current token a new line?) and simply not emit a NewLine Token.
glm942022-10-03 19:40:00 +00:00
a949007c75
Updated the ISA so the program will correctly see things like 'load', 'inc' and 'dec'.
glm942022-10-03 16:56:39 +00:00
a0d5d62a34
Fixed a bug in the Scanner when parsing a hex number, still not super robust but it'll work.
glm942022-10-03 15:20:31 +00:00
f7cd87f13f
Started reworking the Parser to simplify how instructions will be represented. It will act like a 'first pass' that will do grammar checks but not verify the parameters of the opcodes.
glm942022-10-02 22:54:18 -05:00
55f4c32764
Missed this for the Scanner fix.
glm942022-10-02 22:12:16 -05:00
097eca383b
Fixed a bug with the Scanner adding a blank line via a single NewLine Token when a file starts with a block of comments.
glm942022-10-01 20:43:55 -05:00
984683bfc5
Minor adjustment to Figure 1.1
glm942022-09-29 22:57:12 -05:00
0f42ad2997
Updated the ISA and added links in the table of contents.
glm942022-09-29 22:11:19 -05:00
63438b551b
Got the scanner running again. Seems to be picking up punctuation, labels, identifiers and strings as expected.
glm942022-09-29 21:32:08 -05:00
e94e486e18
More refinements to the loading data instructions. I am truly bad at this whole thing...
glm942022-09-29 20:42:37 +00:00
2b71ac05a0
Added a note about a proposal regarding assembly language design.
glm942022-09-27 17:46:50 +00:00
02cf72902e
Updated the load instructions.
glm942022-09-26 22:13:48 -05:00
afa84076c8
Added a command to make generating an opcode table a one liner. Updated the ISA.
glm942022-09-23 19:36:27 +00:00
925f7703d6
Updated the ISA, hopefully I can get this all put together in a thought out way.
glm942022-09-22 20:49:20 +00:00
a82a4c23ad
Updated the docs.
glm942022-09-21 21:44:38 -05:00
f5c82d1c36
Added a LaTex document to put in writing how the machine should behave.
glm942022-09-21 16:23:11 +00:00
0b58e0124f
Some refactoring to update everything to use the new structures and some new considerations for how Symbols and Instructions shoudl be represented.
glm942022-09-15 22:14:38 -05:00
2ae60a607c
Incomplete, but I want to make sure the ideas I have here don't get wiped. Sadly this commit won't compile.
glm942022-09-15 21:29:27 +00:00
6d17dffcdf
Added a SymbolTable object (untested at the moment) and redefined the Symbol object. I think when a Symbol is made only the size of it should matter to the code that will assemble the final binary.
glm942022-09-08 20:56:02 +00:00
2518214585
Added a length attribute to the symbol.
glm942022-09-06 14:15:45 +00:00
7004fff659
This feels like a trainwreck but eh. Changed the way the opcodes are managed. Hopefully this is the right direction when I add support for multiple ASM files.
glm942022-09-01 18:46:59 +00:00
dac01ffd0c
Changed the TokenClass from opcode to nomic, a less smoothbrain name IMO and also frees up Opcode for a better use later on.
glm942022-08-30 22:06:50 -05:00
3c7056c5e6
The main function will now write out the output of the parser.
glm942022-08-29 21:23:02 +00:00
6c7b8d5356
Fixed a bug where CMP REG, REG wouldn't get encoded and a disassembler bug related to said CMP bug.
glm942022-08-29 19:29:34 +00:00
5f437b6869
Both the assembler and the disassembler should now support all the instructions I've layed out thus far.
glm942022-08-29 18:51:48 +00:00
e3b4293314
Fixed a bug in the parser where the size of the binary was too big.
glm942022-08-29 18:02:11 +00:00
ae1e73e00f
Fixed a bug to correct the location of symbols in the heap.
glm942022-08-29 16:00:02 +00:00
7385a807a5
Created a basic binary format to help guide the disassembler.
glm942022-08-29 15:57:14 +00:00
0d3f8a460e
Added more instructions for the parser to emit and refactored the code in doing so.
glm942022-08-28 15:37:56 -05:00
c2111e2b88
Added support for the ADD and SUB opcodes to the disassembler.
glm942022-08-28 13:08:18 -05:00
8e9d1aefe8
Fixed some disassembler issues. At least some instuctions are being disassembled correctly.
glm942022-08-26 21:43:03 -05:00
0785f21805
Added a disassembler which is still very buggy. Also fixed some bugs with the opcode mask getting function.
glm942022-08-26 21:41:02 +00:00
e4a191a17e
Refined the encoding some more.
glm942022-08-26 19:00:37 +00:00
eb5e2c506e
Got the start of encoding opcodes.
glm942022-08-26 18:27:41 +00:00
0d060248cb
Forgot about the bloody IN instruction...
glm942022-08-25 21:01:35 -05:00
a96f485da6
I believe I have the bit patterns for my opcodes worked out.
glm942022-08-25 20:45:46 -05:00
88d550f344
Added unconditional jump opcode to my comment section.
glm942022-08-25 20:27:25 -05:00
0e53f9798f
Added a distinction between constant numbers and what are effectively memory addresses (i.e. strings and labels).
glm942022-08-25 19:47:16 -05:00
03d5660677
Seems I fixed the memory offset bugs, so far anyway...
glm942022-08-25 19:54:47 +00:00
4f6d5f652e
Made use of the Symbols Table, and started the proccess of determining the memory location of opcodes and variables.
glm942022-08-25 19:06:05 +00:00
64326937b1
Added a LineEnd token type.
glm942022-08-25 18:37:25 +00:00
89ab951c6a
Refactored the parsing code just a touch.
glm942022-08-24 21:23:14 +00:00
947de1d14c
Added support for declaring a variable with the '.db' directive. Address calculations still need to be done, but at the very least the variable's name is showing up in the symbols table.
glm942022-05-16 15:17:19 +00:00
3c4cce0883
Added assembler directives as a class of token.
glm942022-05-16 14:27:49 +00:00
5265666178
Got the Parser to, so far, correctly (minus memory leaks) parse out and report errors with opcodes and their parameters.
glm942022-05-12 23:16:02 -05:00
2de3538d80
Parser is now mostly setup for the 'peek and advance' pattern. Still having infinite loop issues somewhere though.
glm942022-05-12 21:30:02 +00:00
72525959f6
Reworked the tokens to include a broad class to make parameter matching a bit easier, and removed the hexadecimal distinction.
glm942022-05-12 20:26:14 +00:00
72abf6c4ab
Started work on rewriting the Parser.
glm942022-05-10 21:03:09 +00:00