aboutsummaryrefslogtreecommitdiff
path: root/lib/vnf/src
Commit message (Collapse)AuthorAgeFilesLines
* vnf: display also the break mark on report()Miquel Sabaté Solà2026-09-071-1/+9
| | | | | | | | 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-071-0/+9
| | | | | | | | 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-071-8/+10
| | | | | | | 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-071-5/+53
| | | | | | | 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>
* 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-061-1/+1
| | | | | | Add also a test to further check corner cases on compare instructions. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: add support for standard joypadsMiquel Sabaté Solà2026-09-061-19/+93
| | | | | | | | 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-061-2/+1
| | | | 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-061-1/+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-271-2/+6
| | | | | | | | 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-271-23/+156
| | | | | | | | | | | | 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-271-0/+11
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: don't report stack push/pop twice in verboseMiquel Sabaté Solà2026-08-271-10/+12
| | | | | | | | 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>
* vnf: fix the accounting of cycles on branchesMiquel Sabaté Solà2026-08-251-2/+10
| | | | | | This was broken since the very beginning. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: push/pop the proper address on jsr/rtsMiquel Sabaté Solà2026-08-251-5/+13
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* vnf: fix documentation on 'page_penalty'Miquel Sabaté Solà2026-08-251-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Do not account for stack reads on 'rts'Miquel Sabaté Solà2026-08-251-10/+14
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Stop execution if not active in until_address()Miquel Sabaté Solà2026-08-251-1/+1
| | | | | | | | | | | Even if the desired thing is to run until the provided address is reached, abort execution as well if the machine stops being active as well. This is a common scenario when running in function mode and the target end address is something passed that. Fixes: e6c41303c2da ("runrom: add the --until-address option") Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* runrom: add the --until-address optionMiquel Sabaté Solà2026-08-251-15/+1
| | | | | | | | | This allows the user to run execution until a given address is reached. This can, like with the --start option, be coupled with the --nasm option in order to be able to provide an identifier instead of a regular hexadecimal value. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add the runrom crate and the vnf libraryMiquel Sabaté Solà2026-08-171-0/+1178
The vnf library supports the runrom crate and they both combined enable users to "run" a ROM file. This is basically an emulator, but with two key differences: 1. It is to be run programatically. That is, you are not expected to play games with this, but to run code by steps, start at a given address, run a function, etc. 2. It is headless: there are no graphics displayed on screen, nor sound being delivered. Thus, the target for both these things are developers, not players. This way developers can validate code paths without needing a full blown emulator. You can write tests with this and be able to run some checks as part of your testing infrastructure. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>