aboutsummaryrefslogtreecommitdiff
path: root/crates
Commit message (Collapse)AuthorAgeFilesLines
* nasm/xa65: add the --allow-unused optionMiquel Sabaté Solà2026-04-302-0/+10
| | | | | | | | | Since the addition of the check() function in commit 6a9dea943c07 ("Add a new 'check' stage in assemble()"), it can be annoying to some users that the check for unused/unreferenced object applies by default. Hence, add a flag so this can be disabled. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: add documentation on the exit status codeMiquel Sabaté Solà2026-04-281-0/+9
| | | | | | | I apparently never bothered to do so. It's a good idea to have this as it might not be all that expected. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: call exit() right after error detectionMiquel Sabaté Solà2026-04-281-90/+88
| | | | | | | | The 'if error_count == 0' branch came from old code that accumulated over and over. Since this was the only branch taken before exit, let's prefer the other way around so we can remove one indentation level. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: use buffered writing for full ROMs as wellMiquel Sabaté Solà2026-04-281-4/+8
| | | | | | | | This was already implemented for the --split-segments option. Not let's bring this when building full ROM files, as writing things byte by byte is slow. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: avoid an unnecessary loop when writing bytesMiquel Sabaté Solà2026-04-281-5/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: add the --split-segments optionMiquel Sabaté Solà2026-04-281-32/+71
| | | | | | | | | | | | This allows the programmer to tell nasm to leave each segment into its own .out file. This can be useful when writing some specific segments into different chips. The caveat is that filling is not applied, and hence it's up to the programmer to account for that if two or more segments happened to be on the same mapping and needed some alignment in between. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: add a description on the README.md fileMiquel Sabaté Solà2026-04-251-0/+14
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Update the code style to the latest stable RustMiquel Sabaté Solà2026-04-241-1/+1
| | | | | | | | | | This mostly involves applying the collapsible_match rule[1] where appropiate, and using sort_by_key() as pointed out by the latest stable version of clippy. [1] https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#collapsible_match Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* xa65: fix indentation on the help messageMiquel Sabaté Solà2026-04-231-3/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add documentation for asan:stackMiquel Sabaté Solà2026-04-081-0/+23
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix small typoMiquel Sabaté Solà2026-02-271-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Document the __NASM__ and __fallthrough__ featuresMiquel Sabaté Solà2026-02-031-0/+138
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: improve message on the -D flagMiquel Sabaté Solà2026-02-031-1/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* 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>