aboutsummaryrefslogtreecommitdiff
path: root/scripts
Commit message (Collapse)AuthorAgeFilesLines
* Add the .fallthrough control statementMiquel Sabaté Solà2026-02-021-0/+12
| | | | | | | | | | | | | | | | This is exclusive to 'nasm' and it allows the developer to explicitly tell the assembler than a "fall through" condition is actually desired: it's not a mistake. This comes in two flavors. The first, without arguments, just makes this explicit without much enforcement. The second allows you to pass an argument which is the name of the function or label you are expecting to fall through. The assembler will error out if the fall through address is not the expected one, hence telling the programmer whenever the fall through condition they thought in the past is no longer true (e.g. the function has moved somewhere else in the code). Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Warn on pointless (un)conditional branchingMiquel Sabaté Solà2026-02-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes performing some 'jmp'/'jsr' can be quite pointless, and the programmer might not be fully aware of this because of the layout of the code. Imagine: .proc foo ;; code jmp bar .endproc ;; Documentation, comments, extra space, etc. .proc bar ;; whatever .endproc The 'jmp' in the code above tries to perform a call stack optimization, but it's actually not needed because the next instruction after 'jmp' is the one inside of 'bar', but that's obfuscated because of the layout. In these sort of cases (and also for 'jsr' and branches) warn the programmer about it so it can remove that instruction. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* tests: do not generate dummy out.nes filesMiquel Sabaté Solà2026-02-021-3/+3
| | | | | | | | For tests which the resulting binary is not needed, redirect the output (i.e. the ROM file) to /dev/null. This way we don't litter the workspace with dummy out.nes files. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Allow constants in asan:reserve statementsMiquel Sabaté Solà2025-12-151-0/+5
| | | | | | | | | | | | | | | | This way, if you define a constant like: MY_BUFFER_LEN_IN_BYTES = $10 You can then declare your buffer like so: zp_buffer = $00 ; asan:reserve MY_BUFFER_LEN_IN_BYTES And then further in the code you can rely on just using the constant for bound checking, and then the address sanitizer will check on bound checks via static analysis as well. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.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>
* Add a check for variable namesMiquel Sabaté Solà2025-09-031-0/+5
| | | | | | | 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-031-0/+6
| | | | | | | | | | | | | 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-021-0/+6
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Split the --stats and the --strict flagsMiquel Sabaté Solà2025-09-021-18/+18
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Rebump end-to-end tests to work via git submodulesMiquel Sabaté Solà2025-08-181-18/+103
| | | | | | | | | | 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>
* nasm: Implement the -D flagMiquel Sabaté Solà2025-01-221-0/+11
| | | | | | | 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>
* tests: Add aoc2023.nes to end-to-end testsMiquel Sabaté Solà2025-01-221-0/+12
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* tests: Update code.nes so -Werror can be passedMiquel Sabaté Solà2025-01-131-9/+6
| | | | | | | | | Update the underlying code.nes test data so it uses a tighter configuration for NROM which in turn frees nasm from complaining about empty segments. This makes room to allo for -Werror so we catch warnings that might appear in the future. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* tests: Bundle end-to-end tests into a tarballMiquel Sabaté Solà2025-01-101-8/+19
| | | | | | | | This way I can simply compress all the examples to traverse with a single file, and thus no longer polluting this repository from code from other repositories. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Implement the .include statementMiquel Sabaté Solà2025-01-091-0/+3
| | | | | | | | | | | | | | 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 support for UxROM chipsMiquel Sabaté Solà2024-12-201-0/+3
| | | | | | I have also added an end-to-end test for it. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Introduce end-to-end testsMiquel Sabaté Solà2024-12-202-0/+13
| | | | | | | | | | | For now I have added the most simple example for an NES/Famicom game, which I already had on a private repository (that I plan to open source soonish). Tests simply run `nasm` on known source files and compares the results with an .nes ROM file that has the exact bytes that we expect. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* scripts: Error out on warningsMiquel Sabaté Solà2024-12-191-0/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* scripts: Add a script to perform all tests at onceMiquel Sabaté Solà2024-12-181-0/+16
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>