aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/opcodes.rs
Commit message (Collapse)AuthorAgeFilesLines
* Implement the .include statementMiquel Sabaté Solà2025-01-091-0/+1
| | | | | | | | | | | | | | This needed some heavy lifting when it comes to how files were located. This means that statements like .include/.incbin now take into consideration a new list made out of SourceInfo, which holds enough information to translate from which file a node comes from. This has also been added into errors, so they are more informative on what went wrong. In order to tests this, besides all the regular unit tests, a new e2e test has been added. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add the .repeat control statementMiquel Sabaté Solà2025-01-071-17/+34
| | | | | | | | | | | | | | | | | | | | | | | | This is a control statement which acts similarly as .proc/.macro/.scope, in which an inner block is allocated for it. Hence, all the previous work from 1f8a6becc7cd ("parser: Implement block bodies") and ec8b709fa24c ("Implement block bodies inside of the assembler") make this one out possible, as .repeat statements don't have an identifier that can be used for hashing. From the parser perspective this introduction raises two new things. First of all this control statement also needed a differentiation between the amount of required arguments, and the allowed ones, since there is a second optional argument to it. And second, even the identifier is not given, we have to generate one so to add a context for it. This was at first not needed, but introducing .repeat-only variables means that we have to have inner contexts which need to be named somehow so we can retrieve the context later when picking up the value for them again. This last thing brought the need for a new dependency: rand. This is used to generate a random string to identify the .repeat block. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Implement the .incbin control statementMiquel Sabaté Solà2024-12-191-0/+1
| | | | | | | | This also forced us to add the current working directory to the `Assembler::assemble` public function, as otherwise this control statement and others wouldn't know how to resolve relative paths. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Re-work the handling of segments in the assemblerMiquel Sabaté Solà2024-12-121-1/+1
| | | | | | | | There were a lot of assumptions on the assembler that stemmed from a fundamental missunderstanding from my side on how segments are laid out on the final file. This commit is the first step to address this. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Don't rely on the identifier for control identityMiquel Sabaté Solà2024-12-121-14/+16
| | | | | | | | | Instead, use a new enum type to identify the control statements that we actually support. This way the assembler is more easily aware on the control that it's dealing with, and can be more sure on certain aspects of the implementation on control support. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Re-work the support on labels, variables and jumpsMiquel Sabaté Solà2024-12-121-0/+1
| | | | | | | | | | | As a way to firstly adapt on the latest changes from the parser since 184c39579227 ("Re-work the parser from scratch"), the assembler had to leave out some features on 16114b2ca358 ("Adapt the assembler to the changes on the parser"). This commit reintroduces support for settings labels, variables and referencing them, while also providing a more robust implementation at that. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Adapt the assembler to the changes on the parserMiquel Sabaté Solà2024-12-121-292/+326
| | | | | | | | | | | As of 184c39579227 ("Re-work the parser from scratch") the parser has a proper AST, and the assembler has to traverse it accordingly. Moreover, the assembler has been stripped from a lot of unneeded memory allocations and it's overall more keen on using mere references when possible. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Re-work the parser from scratchMiquel Sabaté Solà2024-12-121-0/+27
| | | | | | | | | | | | | The initial implementation was incredibly naive on how complex an assembler can actually be. Because of this, it never bothered to define and produce a proper AST, and hence it was overall extremely fragile on (not so) corner cases. This commit re-writes everything from scratch for the parser, and it should really be the last fundamental change to the parser other than minor additions/features here and there. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add support for branchingMiquel Sabaté Solà2024-12-121-17/+58
| | | | | | | | This is a bare bones implementation of it, and there's a lot of nuance that it's being missed, but at least the fundamentals have been implemented already. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Initial commitMiquel Sabaté Solà2024-12-121-0/+631
A lot is missing and there is a long road ahead to make the assembler even work. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>