aboutsummaryrefslogtreecommitdiff
path: root/crates
Commit message (Collapse)AuthorAgeFilesLines
* Remove .github directoryMiquel Sabaté Solà2026-07-222-2/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: only read the ROM file onceMiquel Sabaté Solà2026-07-161-15/+14
| | | | | | | | | | | | | | | | | | | Since the implementation grew from disassembling a single subroutine, reading the ROM file from inside print_range() made sense. But since we have disassembling of full segments and files now, this reading would be triggered multiple times. Commit d7b1a895de9e ("readrom: add an option to disassemble the full file") avoided the exhaustion of the input by using seek(), but that's just a hack and it's hiding the fact that we are constantly reading the same thing over and over. Constantly reading ROM files isn't that much of a performance issue given how small they are, but it's embarrasing anyways. Fix this by reading the full file once and passing the slice of bytes to the same functions that used to require the file to be passed. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: add an option to disassemble the full fileMiquel Sabaté Solà2026-07-161-2/+39
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: allow to disassemble a mappingMiquel Sabaté Solà2026-07-161-22/+117
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: fix versioning on the Cargo manifestMiquel Sabaté Solà2026-07-151-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: implement the -d/--disassemble optionMiquel Sabaté Solà2026-07-153-6/+406
| | | | | | | | This option can also be coupled with -n/--nasm-directory, and you can then get a human-readable disassembling of any proc or label you might be thinking on. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Save known addresses into .nasm/addresses.txtMiquel Sabaté Solà2026-07-152-0/+35
| | | | | | | | | This new file contains all the addresses that are known to the assembler, belonging to either proc's or plain labels. For the former we will further be able to tell the "end" of the proc. With that, the file follows a simple CSV format, with the name, start and end. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: code style cleanupMiquel Sabaté Solà2026-07-141-8/+13
| | | | | | | | In the same spirit as commit a012d260db4a ("Minor style fixes from an upgraded clippy"), an update on the toolchain has raised some concerns style-wise. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Generalize MemoryRange into RangeMiquel Sabaté Solà2026-07-141-2/+2
| | | | | | | Leading up to also having address ranges exported to callers, which should be using the same infrastructure. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: print the usual PRG-RAM size if availableMiquel Sabaté Solà2026-07-131-0/+3
| | | | | | | | | | If 'has_persistent_memory' has been set on the ROM header, then we must print it even if bytes 8/10 was never set by the header. In fact, the vast majority of ROM files don't have these bytes set but they report a true value for 'has_persistent_memory'. Hence, assume the usual PRG-RAM size in these cases, which is (I hope) the correct one in all cases. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Minor style fixes from an upgraded clippyMiquel Sabaté Solà2026-07-092-2/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add support for the asan:fixed-segments commentMiquel Sabaté Solà2026-07-091-0/+42
| | | | | | | | This magic comment allows for the definition of segments that are fixed and for which references are always safe. This goes in tandem with the asan:safe comment, which can then be used more sporadically. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add a warning for unknown cross-mapping referencesMiquel Sabaté Solà2026-07-081-1/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some segments, like the 'vectors' one, will reference code that is outside of its mapping. But in some other configurations, segments cannot make these cross-mapping references so happily. Imagine: .segment "SWAPPABLE" .proc foo rts .endproc .segment "FIXED" jsr foo Here the assembler will properly detect the address of 'foo' in the context of the 'SWAPPABLE' segment. But what this assembler doesn't know is that this segment is swappable (e.g. UNROM chip). Hence, if the bank being mapped right now is not the one containing the 'SWAPPABLE' segment, then the address computed for 'foo' and used in that 'jsr' instruction will point to something else entirely. This would be similar to a use-after-free bug. This is something that can only be inspected at runtime, and so the assembler cannot be of much help here. Hence, this commit adds a warning so the programmer can understand the potentially dangerous operation. All of that being said, this commit also adds support for "asan:safe" or "check:safe", which is a magic comment that the programmer can write to re-assure the assembler that this operation is fine (e.g. there is a guarantee that the mapped bank is that one we are expecting). Hence, the code above could now be written like so: jsr foo ; check:safe Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Upgrade to the 2024 edition of RustMiquel Sabaté Solà2026-07-084-6/+4
| | | | | | | And also adjust the code so the clippy from the 2024 edition is fine with it. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* xa65: sort the flags on the help messageMiquel Sabaté Solà2026-04-301-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix tabulation on --allow-unused help's messageMiquel Sabaté Solà2026-04-301-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Rename "raw address" to "label"Miquel Sabaté Solà2026-04-301-1/+1
| | | | | | This is much clearer to the programmer. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: add documentation to the 'unused' checksMiquel Sabaté Solà2026-04-301-0/+23
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* 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>