aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* {run,read}rom: validate the path from --nasmMiquel Sabaté Solà2026-08-262-9/+27
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* runrom: add tests for --start and --until-addressMiquel Sabaté Solà2026-08-266-0/+1087
| | | | 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>
* Add a couple of notes on contributingMiquel Sabaté Solà2026-08-251-1/+5
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* runrom: add the --until-address optionMiquel Sabaté Solà2026-08-253-47/+80
| | | | | | | | | 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>
* Allow the --start flag to accept identifiersMiquel Sabaté Solà2026-08-242-15/+82
| | | | | | | This is coupled with the new -n/--nasm option, which works in the same way as in `readrom`. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Annotate the no-return from die()Miquel Sabaté Solà2026-08-244-55/+28
| | | | | | | | | | | | In all crates we are using a die() function to print to stderr and quit with a exit status > 0. Apparently in Rust you can annotate the return type with a bang just like the noreturn from the C family. The added bonus is that some useless statements to make the compiler happy without it can be removed altogether as now the compiler is able to understand that it won't return so the returned type is not needed. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: provide a better layout for the README fileMiquel Sabaté Solà2026-08-231-151/+146
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Improve the description of runromMiquel Sabaté Solà2026-08-231-11/+29
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: fix typo on the READMEMiquel Sabaté Solà2026-08-181-2/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Do not mark some valid identifiers as invalidMiquel Sabaté Solà2026-08-181-0/+27
| | | | | | | | | | | | | Some identifiers like "@aa" were marked as invalid as "aa" is a potentially hexadecimal value, but the "@" symbol actually disambiguates this situation. Hence, if a non-alphanumeric character (that the parser liked) is actually found, ensure it cannot be considered as an hexadecimal value. Provide also a test of is_valid_identifier(). The list is certainly not exhaustive, but it should be good enough coupled with end-to-end tests. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Validate labels when walking through the contextMiquel Sabaté Solà2026-08-181-3/+32
| | | | | | | | | | | | | | The parser does not validate label names completely (it only takes care of validating that it something that makes sense syntactically). The assembler can tell whether the label is actually taking a reserved name, or an invalid hexadecimal constant, etc. Before this commit a user would get a cryptic "invalid identifier" message when referencing an invalid label (e.g. "jmp 1234"). Fix this by validating the identifier there, but also when the label was defined before any of this. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add global labelsMiquel Sabaté Solà2026-08-189-21/+190
| | | | | | | | | | | | These are labels that are declared by prefixing a '#' symbol to the name, and it allows the label to be declared at the global scope instead of the current one. This is a feature which is not to be abused so to not make scopes pointless, but it can be quite handy with some optimizations while not abandoning scopes completely. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix the opcode for the 'sed' instructionMiquel Sabaté Solà2026-08-171-2/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* nasm: inherit certain options from the workspaceMiquel Sabaté Solà2026-08-171-2/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add the runrom crate and the vnf libraryMiquel Sabaté Solà2026-08-1712-0/+1622
| | | | | | | | | | | | | | | | | | | 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>
* readrom: read the ROM file right on startMiquel Sabaté Solà2026-07-231-28/+18
| | | | | | | | | | This avoids exhausting the input in other scenarios (thus fixing commit f5549b97bf85 ("readrom: only read the ROM file once")), and it makes everything more cohesive. Fixes: f5549b97bf85 ("readrom: only read the ROM file once") Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* scripts: ensure bash is running themMiquel Sabaté Solà2026-07-233-3/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Update URLs from submodulesMiquel Sabaté Solà2026-07-231-3/+3
| | | | | | | They were taking the SSH version for cloning, which can be troublesome in some environments. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Remove .github directoryMiquel Sabaté Solà2026-07-228-172/+5
| | | | 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-152-2/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: implement the -d/--disassemble optionMiquel Sabaté Solà2026-07-1511-13/+2752
| | | | | | | | 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-153-5/+116
| | | | | | | | | 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-142-67/+71
| | | | | | | 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>
* Use 'full_name' everywhere in check()Miquel Sabaté Solà2026-07-141-5/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* readrom: print the usual PRG-RAM size if availableMiquel Sabaté Solà2026-07-132-1/+4
| | | | | | | | | | 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>