| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
| |
This is much clearer to the programmer.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
| |
Fixes: 8e7993a63e32 ("assembler: Add support for asan:reserve,ignore").
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|