aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* header: Add one/four screen nametable supportMiquel Sabaté Solà2025-09-121-13/+74
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Update README on asan:ignore also affecting instructionsMiquel Sabaté Solà2025-09-041-9/+6
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Move and expand the README on nasmMiquel Sabaté Solà2025-09-042-33/+181
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* scripts: Remove the usage of asan in most examplesMiquel Sabaté Solà2025-09-041-18/+22
| | | | | | | | | The examples listed here don't follow the basic rules required by the address sanitizer either for learning purposes or out of simplicity. Hence, let's disable it for all cases and we'll bring it back for future repositories. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* asan: Add fixes on absolute/indirect addressingMiquel Sabaté Solà2025-09-033-1/+11
| | | | | | The check was not being applied on certain conditions. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Apply asan:ignore also when bundlingMiquel Sabaté Solà2025-09-032-1/+15
| | | | | | | This way instructions which might make use of bare memory numbers can freely ignore the address sanitizer when it actually makes sense. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add a check for variable namesMiquel Sabaté Solà2025-09-034-0/+101
| | | | | | | This check ensures that asan-friendly names actually match their expected scope. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Validate that memory access is done via variablesMiquel Sabaté Solà2025-09-035-9/+204
| | | | | | | | | | | | | The address sanitizer is now able to detect whenever in an instruction a memory access is done without using variables. This is now detected for all instructions except for branching, which falls outside of this scope. Moreover, simple arithmetics is allowed and bounds are checked for simple cases. That being said, more involved bound checks should be done with other tools (e.g. emulators). Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add a warning for each unused variableMiquel Sabaté Solà2025-09-027-31/+93
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Split the --stats and the --strict flagsMiquel Sabaté Solà2025-09-023-36/+48
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* assembler: Preserve the original working directoryMiquel Sabaté Solà2025-09-021-0/+10
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* parser: Allow .include inside of .scopeMiquel Sabaté Solà2025-09-021-6/+21
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* parser: Avoid unwrap crash on weird quoted stringsMiquel Sabaté Solà2025-09-021-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* assembler: Add support for asan:reserve,ignoreMiquel Sabaté Solà2025-09-027-115/+536
| | | | | | | | This is the initial support for both directives for the address sanitizer. Note that asan:weak has been moved into asan:ignore, which is not exactly the same but for now it should suffice. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add -h and -v options on the help messageMiquel Sabaté Solà2025-09-023-2/+8
| | | | | | | On all binaries there were these two options missing from the help message. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* parser: Add asan:reserve and asan:weak supportMiquel Sabaté Solà2025-08-282-19/+223
| | | | | | | | | | These are special directives that happen on comments, and hence this parser will no longer simply ignore comments. This feature is not used by the assembler, but following commits should build up address sanitizer strategies from it. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* nasm: Error out when using WRAM when not availableMiquel Sabaté Solà2025-08-284-1/+58
| | | | | | | | | | This commit introduces the ability to inspect the temptative header before producing the actual output, and with that it checks whether the Working RAM is being advertised or not. If it is not being advertised but the assembler detected memory accesses to that region, then we are in trouble and we should error out. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xixanta: Be more mindful on what's being exportedMiquel Sabaté Solà2025-08-271-6/+21
| | | | | | | This means removing a lot of `pub` structs or enums, as well as adding documentation on `pub` structs. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Remove ncount and ngrepMiquel Sabaté Solà2025-08-275-36/+0
| | | | | | | | These were theoretical tools that could be provided, but I have neither had the time, or their perceived functionality has been moved into other crates. Hence, just remove them. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* nasm: Implement the -s/--stats optionMiquel Sabaté Solà2025-08-272-0/+33
| | | | | | | | This option prints further information on how segments are laid out. In particular, for now it prints the amount of space being filled for each segment. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* ci: Work with recursive submodulesMiquel Sabaté Solà2025-08-181-0/+4
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* ci: Ensure cl65 is installedMiquel Sabaté Solà2025-08-181-0/+5
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Rebump end-to-end tests to work via git submodulesMiquel Sabaté Solà2025-08-188-20/+173
| | | | | | | | | | This provides a more up-to-date experience, while also allowing to test more cases. Moreover, the latest flags from 'xa65' are being used. All in all, both 'code.nes' and 'aoc2023.nes' appear to be working after the latest fixes. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Don't get into all blocks when evaluating the contextMiquel Sabaté Solà2025-08-181-4/+51
| | | | | | | | For some control statements like .if/.ifdef/.ifndef this is only desired when the condition is true; otherwise getting into the inner block should be prevented. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Provide a node to the Object structMiquel Sabaté Solà2025-08-182-1/+75
| | | | | | | | | This allows the `evaluate_variable` to pull from it in the crunching stage so to evaluate the original node in cases like macro expansion, where the connection between the macro argument and the original caller might have been lost. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xa65: Introduce the -s/--strict optionMiquel Sabaté Solà2025-08-181-4/+14
| | | | | | | | This further iterates on the previous -e/--error flag and it asks 'xa65' to error out in any case: when 'nasm' errors out, but also when the diff is not empty. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Reset literal mode before left arm of an operationMiquel Sabaté Solà2025-08-181-0/+5
| | | | | | | | On an arithmetical/logical operation, the literal mode needed to be reset before evaluating the left arm since the previous evaluation of the node could have altered it. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xa65: Add the -e/--error flagMiquel Sabaté Solà2025-08-181-5/+17
| | | | | | | | This allows the user to specify that erroring out on a failing 'nasm' execution is actually desired. This is relevant mostly on internal tests. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Include RODATA inside of the default nrom65 configMiquel Sabaté Solà2025-08-181-1/+1
| | | | | | | | This is really not needed from my point of view, but some existing code makes use of this and so it is actually useful to have it in the default configuration. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xixanta: Allow for mapping size larger than 16 bitMiquel Sabaté Solà2025-08-181-3/+10
| | | | | | | In configuration files, the 'size' attribute can actually be larger than a 16-bit value, and that is fine inside of the ROM layout. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xa65: Introduce the -b/--bin optionMiquel Sabaté Solà2025-08-181-7/+24
| | | | | | | This allows to configure an alternative binary for the 'nasm' program, which is convenient for testing development binaries. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Fix shift overflow on certain expressionsMiquel Sabaté Solà2025-08-181-2/+2
| | | | | | | | | I got a report from libfuzz that some cryptic input could make the assembler panic on shifts. It turns out that the check on whether the operator was too big or not had to be explicitely casted to `usize` to avoid signedness issues. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* ci: Add RUST_BACKTRACE to all jobsMiquel Sabaté Solà2025-08-181-0/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Use a buffered reader for incbinMiquel Sabaté Solà2025-08-171-2/+3
| | | | | | | | | Iterating via `bytes()` on a file is inefficient as the default implementation calls `read` on each byte, which can be costly on bytes which are not in memory like files. This is extra important for statements like `incbin` as included files can be rather big. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Apply suggested style fixes from clippyMiquel Sabaté Solà2025-08-179-84/+64
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* parser: Fix disambiguation paren on first argumentMiquel Sabaté Solà2025-08-171-3/+99
| | | | | | | | | | | | | | | | | | | Arguments can be put inside of enclosing parenthesis, but the parser was assuming that if an opening paren was found when parsing the first argument on an argument list, then that was all it was needed to be parsed. This though conflicts with situations like: .byte ($01 << 2) | ($01 << 1) In this case, the parser would have ignored everything past the first closing paren. This commit provides a fix in which if an operation is found past the first enclosing parenthesis, then this assumption is discarded in favor of a parenthesis being used for disambiguating on an arithmetical/logical expression. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xa65: Fix minor style issuesMiquel Sabaté Solà2025-01-231-3/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add a configuration for MMC1Miquel Sabaté Solà2025-01-233-17/+17
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xa65: Create hex dumps for both binariesMiquel Sabaté Solà2025-01-231-0/+49
| | | | | | | This allows to compare both binaries more easily with tools such as vimdiff and the likes. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add support for a single equal sign operatorMiquel Sabaté Solà2025-01-231-1/+4
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Drop lazy_static dependencyMiquel Sabaté Solà2025-01-225-498/+1703
| | | | | | | Apparently the standard library had LazyLock which is enough for what I wanted to achieve with lazy_static. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Implement echo control statementsMiquel Sabaté Solà2025-01-223-2/+48
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* nasm: Implement the -D flagMiquel Sabaté Solà2025-01-228-5/+134
| | | | | | | This allows users to define variables directly from the command line, which is useful for testing purposes. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* github: Add dependabot configurationMiquel Sabaté Solà2025-01-221-0/+6
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Remove dependency on TOMLMiquel Sabaté Solà2025-01-2213-550/+121
| | | | | | | | | | | | | | | | | | | When I introduced this dependency it looked like a good idea to have a better-looking replacement to cl65's cfg format. That being said, the end result wasn't *much* prettier either, and the end result could be even bigger and equally confusing. Since 5f48de69f46d ("Add support for cfg files") there is quite the framework in order to support regular cl65's cfg files. Hence, this commit takes another approach: let's tune this format to a more compressed and simplified one. This is now the current "nasm cfg" format, and it allowed us to re-use a lot of code while also being more to the point for NES/Famicom development than the original cfg format. With this new format, we can now remove the dependency on TOML and all of the inner dependencies which were quite a lot. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Remove the dependency on clapMiquel Sabaté Solà2025-01-227-301/+260
| | | | | | | | | | | | | | | All three binaries (i.e. readrom, nasm and xa65) used it, and to be honest rolling our own argument parsing was actually pretty easy to achieve. This frees us from a big dependency and it also frees us from inner dependencies such as 'clap_derive' which prevented us from being able to build binaries purely statically. As a side effect, we can now display help/version messages which are more like I'm used to, and certain checks can be moved in the parsing directly instead of having to be done later. As a cherry on top, there is some type masturbation that gets removed along the way. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Remove dependency to the rand crateMiquel Sabaté Solà2025-01-226-195/+20
| | | | | | | | This dependency was easily avoidable and it brought with it a lot of inner dependencies of its own, most notably 'zerocopy-derive', which forbid us to compile the affected programs purely statically. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* tests: Add aoc2023.nes to end-to-end testsMiquel Sabaté Solà2025-01-222-0/+12
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Be more explicit on empty identifiersMiquel Sabaté Solà2025-01-211-6/+3
| | | | | | | If the programmer only wrote a single special character for an identifier, then we will consider it empty to avoid shenanigans. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Allow dot characters on identifiersMiquel Sabaté Solà2025-01-211-19/+67
| | | | | | | | In fact, they were always allowed, but they were in kind of grey area, as they could be defined but not used, and sometimes they could be used in the middle of identifiers, which was unexpected. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>