aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* runrom: simply pass 'args' into run()HEADmainMiquel Sabaté Solà2 days1-26/+8
| | | | | | | | This function already took most of the arguments from the user anyways, and the list of separate arguments was getting crazier to a point that even clippy started to freak out. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf,runrom: detect bad data accessMiquel Sabaté Solà2 days10-6/+259
| | | | | | | | | | | | | | This includes detection for: - Stack underflows (it was theoretically already there but it had never been properly tested). - Load/store out of bounds for a given variable known via the .nasm/ directory. - Load out of bounds on a set of data referenced via a raw label (see commit aa5174fc055d ("xixanta: Add an hint for the ending of data labels")). Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* xixanta: Add an hint for the ending of data labelsMiquel Sabaté Solà2 days1-10/+92
| | | | | | | | | Some raw labels may point at a bunch of data laid out with the .byte family of statements. Add hints for each of these labels so we also have a range for them. This way, tools like 'vnf' might be able to detect bad accesses and these sets of data. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* header: add GTROM supportMiquel Sabaté Solà3 days1-0/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* runrom: regularize the output on reportMiquel Sabaté Solà3 days7-42/+49
| | | | | | | Make the hexadecimal values more cohesive and avoid having a variable-sized line because of them. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* runrom: specify the VALUE in --cycle-limitMiquel Sabaté Solà4 days1-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: accept ranges for the --disassemble flagMiquel Sabaté Solà5 days2-5/+20
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Don't error out on conditional .includeMiquel Sabaté Solà5 days8-27/+36
| | | | | | | | | | | | | | | | The hard requirement that an .include statement cannot be inside of another block was, in the end, a bit short-sighted. Imagine the following block: .ifdef DEBUG .include "debug.s" .endif This is perfectly sound-looking code, and it should not be punished as the developer is doing something that is not bending the assembler in weird ways. Hence, just nuke this check. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: add support for default expansion deviceMiquel Sabaté Solà5 days3-22/+95
| | | | | | | | | | | | The 15th byte from the NES 2.0 header was wilfully ignored, but it can be relevant to the end user. Hence, add support for it in the 'header' library, and add the frontend code into 'readrom'. The point is not to support every single thing out there, but I have added the stuff that I thought was most relevant, and we can add more items to it whenever the need appears. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: also print the raw bytes from the headerMiquel Sabaté Solà5 days1-2/+7
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: add support for MMC3Miquel Sabaté Solà5 days4-16/+226
| | | | | | | In theory it's support for any kind of memory mapper, but in practice only MMC3 has been added. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: don't panic on badly formatted ROMsMiquel Sabaté Solà8 days1-0/+5
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: warn on labels that point out of boundsMiquel Sabaté Solà12 days5-2/+39
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: add documentation for --split-segmentsMiquel Sabaté Solà2026-09-211-0/+12
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: prefer the use of die()Miquel Sabaté Solà2026-09-211-12/+5
| | | | | | | For historical reasons, some points of the code were not using this function, calling eprintln!() and exit() manually instead. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: combine the -o option with --split-segmentsMiquel Sabaté Solà2026-09-211-5/+21
| | | | | | | | Allow these to options to be combined, so each segment file is stored inside the directory specified in the -o option. Note that this can only be done if the -o option does not refer to an existing file. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* header: add Sunsoft's FME-7 mapper chipMiquel Sabaté Solà2026-09-191-0/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* header: add more information on unkown mappersMiquel Sabaté Solà2026-09-191-6/+16
| | | | | | | In particular, allow to optionally add the mapper and submapper ID that was found, so it can be displayed to the user. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* xixanta: simplify evaluate_hexadecimal()Miquel Sabaté Solà2026-09-151-8/+6
| | | | | | | | The 'size' variable can be initialized directly from the value we get from the match statement below. I was probably thinking more on the style of C, but the latest Rust stable channel complained about this. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* fuzz: change names to have dashes instead of underscoreMiquel Sabaté Solà2026-09-156-9/+9
| | | | | | | From the latest update of Rust's stable channel, this was raised as a bad format for fuzz names. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add an option for setting a cycle limitMiquel Sabaté Solà2026-09-082-0/+71
| | | | | | | | This can be quite handy when it comes to checking that a piece of code doesn't exceed a given amount of cycles, or when you are tuning a block of code in order to make it go beyond the current amount of cycles. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: refuse to proceed if the machine is inactiveMiquel Sabaté Solà2026-09-081-1/+13
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* tests: fix break_mark testMiquel Sabaté Solà2026-09-081-0/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: validate the minimum stack valueMiquel Sabaté Solà2026-09-071-5/+10
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: display also the break mark on report()Miquel Sabaté Solà2026-09-074-1/+46
| | | | | | | | When reporting the final instruction, if that was actually a brk (and hence we stopped because of it), show the breaking mark as that could be relevant when debugging. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: add the 'Machine.halt_on_brk' fieldMiquel Sabaté Solà2026-09-073-1/+20
| | | | | | | | This allows developers to use 'brk' as asserts which can then be debugged. This is true by default but it can be turned off via the --no-halting-brk option from runrom. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: convert StatusRegister.break_mark to Option<u8>Miquel Sabaté Solà2026-09-072-12/+14
| | | | | | | Instead of assuming a default value, it's safer to just implement it in Rust's native Option<_> type. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: improve documentationMiquel Sabaté Solà2026-09-073-9/+65
| | | | | | | Provide documentation for the library, and improve the documentation for some of the structs and interfaces. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* tests: add clarification as to what vnf-tests isMiquel Sabaté Solà2026-09-061-0/+6
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* tests: add a test on branching instructionsMiquel Sabaté Solà2026-09-063-0/+205
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: properly document how branching worksMiquel Sabaté Solà2026-09-061-10/+11
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: don't flip the given joypad inputsMiquel Sabaté Solà2026-09-061-5/+1
| | | | | | | | | | I am not sure from where I got this bit flipping part, but I believe things worked because of another bug (see 9c685d5b6ca1 ("vnf: also set the carry on a zero compare")). Fixes: ad77503d9533 ("vnf: add support for standard joypads") Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: also set the carry on a zero compareMiquel Sabaté Solà2026-09-064-1/+62
| | | | | | Add also a test to further check corner cases on compare instructions. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf-tests: set the proper exit code on e2e testsMiquel Sabaté Solà2026-09-061-1/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf-tests: add a visual line for each run testMiquel Sabaté Solà2026-09-061-18/+20
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf-tests: allow to conditionally run testsMiquel Sabaté Solà2026-09-061-4/+19
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf-tests: add support for verbosityMiquel Sabaté Solà2026-09-061-0/+12
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: add support for standard joypadsMiquel Sabaté Solà2026-09-065-21/+256
| | | | | | | | This means adding constants so developers can actually trigger which key presses are available at any given read, as well as a simple interface that allows to add button presses and clear them. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: implement the randomized initialization for memoryMiquel Sabaté Solà2026-09-063-2/+70
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: remove tests modMiquel Sabaté Solà2026-09-061-7/+0
| | | | | | | For now tests on vnf are provided via e2e tests, and via the vnf-tests binary. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Implement the bvc and bvs instructionsMiquel Sabaté Solà2026-09-061-4/+11
| | | | | | They were the last ones marked with the todo!() macro. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Remove the 'affected_on_page' memberMiquel Sabaté Solà2026-09-064-315/+0
| | | | | | | | | | | It was created a long time ago in the hopes that it would be useful whenever I wanted to create an emulator, but when that happened in the form of 'runrom' I've seen that it's really not needed. Remove it as it just pollutes the source code with hundreds of useless lines. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Change the first argument of Machine::from() into a &PathMiquel Sabaté Solà2026-08-273-7/+10
| | | | | | | | This makes for a saner API, and some users (e.g. vnf-tests) don't have to go over backwards to provide a parameter they already had as a PathBuf. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: add support for all stack instructionsMiquel Sabaté Solà2026-08-278-24/+383
| | | | | | | | | | | | This also includes brk and rti, for which we are also storing and exporting the break mark, just in case it can be useful to library users in case they want to add error codes in break marks. This commit also includes a fix for accounting the Z and N flags on transfer instructions, which couldn't easily be split into a separate commit, but it's a fairly simple change. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Implement the Default trait for MemoryInitialValueMiquel Sabaté Solà2026-08-272-12/+13
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix cycle count for the plp instructionMiquel Sabaté Solà2026-08-271-2/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* runrom: use Path instead of PathBuf as a parameterMiquel Sabaté Solà2026-08-271-3/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: don't report stack push/pop twice in verboseMiquel Sabaté Solà2026-08-272-14/+14
| | | | | | | | On situations like jsr or rts, we perform two pushes/pops, but this is not to be reported in verbose mode as it's not that clear. Instead, let's report the full address in a single stack line. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* {read,run}rom: fix format of help messageMiquel Sabaté Solà2026-08-262-9/+9
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: fix help message on --nasmMiquel Sabaté Solà2026-08-261-2/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>