| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
This allows users to define variables directly from the command line,
which is useful for testing purposes.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All three binaries (i.e. readrom, nasm and xa65) used it, and to be
honest rolling our own argument parsing was actually pretty easy to
achieve. This frees us from a big dependency and it also frees us from
inner dependencies such as 'clap_derive' which prevented us from being
able to build binaries purely statically.
As a side effect, we can now display help/version messages which are
more like I'm used to, and certain checks can be moved in the parsing
directly instead of having to be done later. As a cherry on top, there
is some type masturbation that gets removed along the way.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The errors reported from the library had a slightly different format
than those that happened in the main file for nasm. This is because in
these cases we were just returning an Err type and Rust handles that
through a special impl.
Instead of going the route of type masturbation, let's go the C route
and have a 'die' function that simply prints the message and calls
exit(1),
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
| |
Also documented the struct as it is exported.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This needed some heavy lifting when it comes to how files were located.
This means that statements like .include/.incbin now take into
consideration a new list made out of SourceInfo, which holds enough
information to translate from which file a node comes from. This has
also been added into errors, so they are more informative on what went
wrong.
In order to tests this, besides all the regular unit tests, a new e2e
test has been added.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is not safe to store a node index for macros since the list of nodes
that is passed down during assembly might change depending on whether an
inner block is being evaluated. Hence, the previous implementation would
break on a simple macro call inside of a .proc.
This also raised some concerns on the design around the API, since the
lifetime of references for internal assembler data needed an explicit
lifetime now, and as a side-effect functions like `assemble` had to be
moved out of the inner impl Assembler. This is in retrospect also a
better design choice.
Fixes: ec8b709fa24c ("Implement block bodies inside of the assembler").
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
This opens up the door for developers to pass their own configuration
files.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
This will allow the creation of configuration files that can live
outside of this tree, so developers can fine tune configuration files of
their own without having to pick up whatever is currently available.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
| |
I have also added an end-to-end test for it.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
It was weird to show warnings which also showed "Error: " as a message,
and likewise it was weird for errors to display their kind, since users
simply do not care about this kind of information.
Hence, streamline the format to something closer to what it's done by
modern assemblers/compilers.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
Even if there are no errors, if warnings are to be treated as errors
then the output should behave the same as if they were errors. That is,
in case there are warnings and they are to be treated as errors, then do
not spit out any assembled bundle.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Warnings are mere xixanta::error::Error's which are not pushed into the
Err of Result. That is, instead they are accumulated into an internal
`warnings` vector inside of Assembler.
On the binary side we now show warnings as well, and there is an option
to turn warnings into errors.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
This also forced us to add the current working directory to the
`Assembler::assemble` public function, as otherwise this control
statement and others wouldn't know how to resolve relative paths.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
| |
This never quite worked and since multiple re-writes of the
assembler/parser it was even commented out. Moreover, this functionality
appears to be more suitable to the new `readrom` binary introduced in
commit 407048d0037c ("Add the readrom binary"). Hence, just remove this
altogether.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The readrom binary is similar to `readelf` from Linux and it will allow
to display information from an NES/Famicom ROM file. For now the
information being shown is just the header, but in the future we might
also include disassembling parts of the code, or retrieving the "CHARS"
section for a given ROM file, and similar.
In order to implement the header parsing part a new library has been
introduced, simply named "header" which abstracts everything away so you
just need to call `Header::try_from("my bytes")` to fetch the actual
information.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There was a big missunderstanding on how things were to be laid out in
the end file, and so it was needed to create a proper understanding on
what's a Mapping and what's a Segment. These turned out to be
fundamental concepts that I failed to grok up until this commit.
Hence, this commit re-arranges completely how variables and labels are
stored in the Context, and how these objects can then be translated into
bundles that can be spit out to the caller.
This commit, besides introducing the new Mapping struct, also introduced
a more general Object, which abstracts things from the Bundle struct,
and allows us to pass certain metadata about the bundle at hand.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
As of 184c39579227 ("Re-work the parser from scratch") the parser has a
proper AST, and the assembler has to traverse it accordingly.
Moreover, the assembler has been stripped from a lot of unneeded memory
allocations and it's overall more keen on using mere references when
possible.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The initial implementation was incredibly naive on how complex an
assembler can actually be. Because of this, it never bothered to define
and produce a proper AST, and hence it was overall extremely fragile on
(not so) corner cases.
This commit re-writes everything from scratch for the parser, and it
should really be the last fundamental change to the parser other than
minor additions/features here and there.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
Procedures are marked with the '.proc' control statement and work both
as a scoping mechanism and as a label that can be referenced.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
This is a bare bones implementation of it, and there's a lot of nuance
that it's being missed, but at least the fundamentals have been
implemented already.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
Mappings and segments are fundamental blocks on how code is distributed
both on the actual ROM File and in the memory layout.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
|
|
A lot is missing and there is a long road ahead to make the assembler
even work.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|