aboutsummaryrefslogtreecommitdiff
path: root/crates
Commit message (Collapse)AuthorAgeFilesLines
* Add __NASM__ protection on the --prelude outputMiquel Sabaté Solà2026-02-031-3/+5
| | | | | | | | The __fallthrough__ macro can only be done when using ca65, not nasm, as that's a protected identifier. Hence, wrap the __fallthrough__ macro definition via an .ifndef __NASM__. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: add the --prelude flagMiquel Sabaté Solà2026-02-021-0/+18
| | | | | | | This flag prints to the standard output some helper code that bridges nasm-exclusive features with ca65. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: define the __NASM__ variableMiquel Sabaté Solà2026-02-021-0/+3
| | | | | | | This variable is defined by default in nasm and it can be used for assembler compatibility code. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* xa65: add -Werror to the --strict flagMiquel Sabaté Solà2026-02-021-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix -a/--asan flag parsingMiquel Sabaté Solà2026-02-021-1/+1
| | | | | | Fixes: 8e7993a63e32 ("assembler: Add support for asan:reserve,ignore"). Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* xa65: use the current timestamp for the tmp directoryMiquel Sabaté Solà2025-12-151-2/+8
| | | | | | | | | | The easy "let's count how many directories there are in /tmp" trick was prone to errors. Hence, let's make things (hopefully) easier by just appending the current timestamp in milliseconds to the directory name. Fixes: 4961b715328d ("xa65: better ensure the name of the tmp directory") Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* xa65: better ensure the name of the tmp directoryMiquel Sabaté Solà2025-12-141-2/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: Better wording on the README fileMiquel Sabaté Solà2025-09-191-5/+19
| | | | | | | | | Instead of only bringing up the pedantic nature of nasm, also note on some of its improvements over ca65. Also, some minor grammar fixes here and there. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: Add detection of RAM, Timing and mirroringMiquel Sabaté Solà2025-09-121-8/+40
| | | | 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-041-0/+174
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Split the --stats and the --strict flagsMiquel Sabaté Solà2025-09-022-18/+30
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* assembler: Add support for asan:reserve,ignoreMiquel Sabaté Solà2025-09-021-19/+145
| | | | | | | | 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>
* nasm: Error out when using WRAM when not availableMiquel Sabaté Solà2025-08-282-1/+31
| | | | | | | | | | 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>
* Remove ncount and ngrepMiquel Sabaté Solà2025-08-274-22/+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-271-0/+24
| | | | | | | | 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>
* 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>
* 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>
* 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>
* Apply suggested style fixes from clippyMiquel Sabaté Solà2025-08-173-20/+18
| | | | 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>
* 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>
* nasm: Implement the -D flagMiquel Sabaté Solà2025-01-221-0/+40
| | | | | | | 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>
* Remove the dependency on clapMiquel Sabaté Solà2025-01-226-88/+244
| | | | | | | | | | | | | | | 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-222-4/+10
| | | | | | | | 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>
* readrom: Print addresses for vectorsMiquel Sabaté Solà2025-01-141-1/+39
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xa65: The config flag should be uppercase on shortMiquel Sabaté Solà2025-01-101-2/+2
| | | | | | | For compatibility with cl65, it's preferrable to keep the short version of the flag as with cl65. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* xa65: Provide the target flagMiquel Sabaté Solà2025-01-101-0/+15
| | | | | | This is meant for compatibility with ca65. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* readrom: Remove the derive feature from clapMiquel Sabaté Solà2025-01-102-14/+18
| | | | | | | This allows us to statically build the 'readrom' binary, as that feature from clap prevented that option. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Remove anyhow from xa65 and readromMiquel Sabaté Solà2025-01-105-38/+71
| | | | | | | | Following in the footsteps of c20c991dded8 ("Make errors from nasm itself more cohesive"), 'anyhow' might provide an easy framework, but it lends towards a less cohesive experience. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Make errors from nasm itself more cohesiveMiquel Sabaté Solà2025-01-101-40/+44
| | | | | | | | | | | | | The errors reported from the library had a slightly different format than those that happened in the main file for nasm. This is because in these cases we were just returning an Err type and Rust handles that through a special impl. Instead of going the route of type masturbation, let's go the C route and have a 'die' function that simply prints the message and calls exit(1), Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Introduce xa65Miquel Sabaté Solà2025-01-102-0/+134
| | | | | | | | This is a bridge between 'nasm' and 'cl65'. That is, it runs the same command on both 'nasm' and 'cl65', compares the resulting binaries, and gives back the binary from 'cl65'. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Rename SourceInfo::working_directory to directoryMiquel Sabaté Solà2025-01-091-2/+2
| | | | | | Also documented the struct as it is exported. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Implement the .include statementMiquel Sabaté Solà2025-01-091-6/+16
| | | | | | | | | | | | | | 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>
* Store a reference for macros instead of an indexMiquel Sabaté Solà2025-01-071-39/+22
| | | | | | | | | | | | | | | | | It is not safe to store a node index for macros since the list of nodes that is passed down during assembly might change depending on whether an inner block is being evaluated. Hence, the previous implementation would break on a simple macro call inside of a .proc. This also raised some concerns on the design around the API, since the lifetime of references for internal assembler data needed an explicit lifetime now, and as a side-effect functions like `assemble` had to be moved out of the inner impl Assembler. This is in retrospect also a better design choice. Fixes: ec8b709fa24c ("Implement block bodies inside of the assembler"). Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* nasm: Also show warnings when there are errorsMiquel Sabaté Solà2024-12-241-0/+8
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* nasm: Allow file paths for the configurationMiquel Sabaté Solà2024-12-221-1/+4
| | | | | | | This opens up the door for developers to pass their own configuration files. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Transform mapping configurations into toml filesMiquel Sabaté Solà2024-12-221-13/+8
| | | | | | | | This will allow the creation of configuration files that can live outside of this tree, so developers can fine tune configuration files of their own without having to pick up whatever is currently available. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add support for UxROM chipsMiquel Sabaté Solà2024-12-201-2/+3
| | | | | | I have also added an end-to-end test for it. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Improve the format of error messagesMiquel Sabaté Solà2024-12-201-3/+3
| | | | | | | | | | | It was weird to show warnings which also showed "Error: " as a message, and likewise it was weird for errors to display their kind, since users simply do not care about this kind of information. Hence, streamline the format to something closer to what it's done by modern assemblers/compilers. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* nasm: Send errors to stderr insteadMiquel Sabaté Solà2024-12-201-3/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Do not spit out bytes if -Werror was passedMiquel Sabaté Solà2024-12-201-9/+13
| | | | | | | | | Even if there are no errors, if warnings are to be treated as errors then the output should behave the same as if they were errors. That is, in case there are warnings and they are to be treated as errors, then do not spit out any assembled bundle. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add support for warningsMiquel Sabaté Solà2024-12-201-2/+25
| | | | | | | | | | | Warnings are mere xixanta::error::Error's which are not pushed into the Err of Result. That is, instead they are accumulated into an internal `warnings` vector inside of Assembler. On the binary side we now show warnings as well, and there is an option to turn warnings into errors. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Implement the .incbin control statementMiquel Sabaté Solà2024-12-191-6/+21
| | | | | | | | 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>
* nasm: Remove the option to disassemble a fileMiquel Sabaté Solà2024-12-181-37/+13
| | | | | | | | | | This never quite worked and since multiple re-writes of the assembler/parser it was even commented out. Moreover, this functionality appears to be more suitable to the new `readrom` binary introduced in commit 407048d0037c ("Add the readrom binary"). Hence, just remove this altogether. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add the readrom binaryMiquel Sabaté Solà2024-12-183-1/+68
| | | | | | | | | | | | | | | The readrom binary is similar to `readelf` from Linux and it will allow to display information from an NES/Famicom ROM file. For now the information being shown is just the header, but in the future we might also include disassembling parts of the code, or retrieving the "CHARS" section for a given ROM file, and similar. In order to implement the header parsing part a new library has been introduced, simply named "header" which abstracts everything away so you just need to call `Header::try_from("my bytes")` to fetch the actual information. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Update the README for open sourcing the projectMiquel Sabaté Solà2024-12-161-0/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Fix the mapping of addresses on labelsMiquel Sabaté Solà2024-12-161-3/+3
| | | | | | | | | | | | | | | | | There was a big missunderstanding on how things were to be laid out in the end file, and so it was needed to create a proper understanding on what's a Mapping and what's a Segment. These turned out to be fundamental concepts that I failed to grok up until this commit. Hence, this commit re-arranges completely how variables and labels are stored in the Context, and how these objects can then be translated into bundles that can be spit out to the caller. This commit, besides introducing the new Mapping struct, also introduced a more general Object, which abstracts things from the Bundle struct, and allows us to pass certain metadata about the bundle at hand. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* nasm: Add a parameter for linker configurationMiquel Sabaté Solà2024-12-121-2/+22
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>