| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| |
|
|
|
|
|
| |
These addresses are merely references to real APU/PPU addresses which
can be used for ease of use.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When evaluating an arithmetic operation, check on whether it
theoretically spans more than one byte, and set it on the resulting
Bundle.size. It's up to the caller to decide on whether that makes sense
or not. This fixes situations in which:
sta $200 + 1
was marked as having 2 bytes for the size as only the "1" was being
considered for the size on this operation. This would then signal the
"sta" evaluation that it was zeropage instead of absolute addressing.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
| |
This is the next step coming from commit d64ed8c531b0 ("Do not allow
empty strings on .include").
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
| |
This allows for reserving memory regions which go outside of the page
boundary.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Negative variables make no sense when it comes to do stuff like:
variable = -1
lda variable
That being said, as an assembler you never know the hacks and nonsense
programmers are willing to endure. But we do know that if the address
sanitizer is enabled, since if it's an "asan-friendly", then an explicit
negative variable can be barred.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
| |
The check was not being applied on certain conditions.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
This way instructions which might make use of bare memory numbers can
freely ignore the address sanitizer when it actually makes sense.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
This check ensures that asan-friendly names actually match their
expected scope.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The address sanitizer is now able to detect whenever in an instruction a
memory access is done without using variables. This is now detected for
all instructions except for branching, which falls outside of this
scope.
Moreover, simple arithmetics is allowed and bounds are checked for
simple cases. That being said, more involved bound checks should be done
with other tools (e.g. emulators).
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
This is the initial support for both directives for the address
sanitizer. Note that asan:weak has been moved into asan:ignore, which is
not exactly the same but for now it should suffice.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
| |
These are special directives that happen on comments, and hence this
parser will no longer simply ignore comments.
This feature is not used by the assembler, but following commits should
build up address sanitizer strategies from it.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
| |
This commit introduces the ability to inspect the temptative header
before producing the actual output, and with that it checks whether the
Working RAM is being advertised or not. If it is not being advertised
but the assembler detected memory accesses to that region, then we are
in trouble and we should error out.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
This means removing a lot of `pub` structs or enums, as well as adding
documentation on `pub` structs.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
| |
For some control statements like .if/.ifdef/.ifndef this is only desired
when the condition is true; otherwise getting into the inner block
should be prevented.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
This allows the `evaluate_variable` to pull from it in the crunching
stage so to evaluate the original node in cases like macro expansion,
where the connection between the macro argument and the original caller
might have been lost.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
On an arithmetical/logical operation, the literal mode needed to be
reset before evaluating the left arm since the previous evaluation of
the node could have altered it.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
This is really not needed from my point of view, but some existing code
makes use of this and so it is actually useful to have it in the default
configuration.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
In configuration files, the 'size' attribute can actually be larger than
a 16-bit value, and that is fine inside of the ROM layout.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
I got a report from libfuzz that some cryptic input could make the
assembler panic on shifts. It turns out that the check on whether the
operator was too big or not had to be explicitely casted to `usize` to
avoid signedness issues.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
Iterating via `bytes()` on a file is inefficient as the default
implementation calls `read` on each byte, which can be costly on bytes
which are not in memory like files. This is extra important for
statements like `incbin` as included files can be rather big.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Arguments can be put inside of enclosing parenthesis, but the parser was
assuming that if an opening paren was found when parsing the first
argument on an argument list, then that was all it was needed to be
parsed. This though conflicts with situations like:
.byte ($01 << 2) | ($01 << 1)
In this case, the parser would have ignored everything past the first
closing paren.
This commit provides a fix in which if an operation is found past the
first enclosing parenthesis, then this assumption is discarded in favor
of a parenthesis being used for disambiguating on an
arithmetical/logical expression.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
Apparently the standard library had LazyLock which is enough for what I
wanted to achieve with lazy_static.
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When I introduced this dependency it looked like a good idea to have a
better-looking replacement to cl65's cfg format. That being said, the
end result wasn't *much* prettier either, and the end result could be
even bigger and equally confusing.
Since 5f48de69f46d ("Add support for cfg files") there is quite the
framework in order to support regular cl65's cfg files. Hence, this
commit takes another approach: let's tune this format to a more
compressed and simplified one. This is now the current "nasm cfg"
format, and it allowed us to re-use a lot of code while also being more
to the point for NES/Famicom development than the original cfg format.
With this new format, we can now remove the dependency on TOML and all
of the inner dependencies which were quite a lot.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
This dependency was easily avoidable and it brought with it a lot of
inner dependencies of its own, most notably 'zerocopy-derive', which
forbid us to compile the affected programs purely statically.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
If the programmer only wrote a single special character for an
identifier, then we will consider it empty to avoid shenanigans.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
In fact, they were always allowed, but they were in kind of grey area,
as they could be defined but not used, and sometimes they could be used
in the middle of identifiers, which was unexpected.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There were certain situations in which syntax ambiguity could arise. For
example, the parser as it stood could treat a valid expression such as
'lda #$80 >> 2' in an unexpected 'lda #$(80 >> 2)'.
This is of course bad, and it came from the fact that literals don't
have enclosing characters, and white spaces are not enough to provide
disambiguation in some cases. Because of this fact, the parser now has a
"look ahead" capability similar to many other parsers, and it's applied
for now only to literals. This looking ahead actually honors
parenthesis, so these can be added if the programmer wants to
explicitely disambiguate an expression.
This involved quite the heavy lifting, and some functions like
'parse_expression_with_identifier' had to be removed with the rewrite.
This had the side effect of having (hopefully) more sane functions all
around, and the parser also has a better capability to differentiate
between regular Values and Calls.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
This is in preparation to some heavy lifting that is to be done to the
parser so it more properly handles nested expressions, but in general
it's a good idea to have some limits to functions that expect to be
called recursively quite heavily.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
| |
Instead of making up a list of characters that end an identifier, do the
other way around since it's far less cumbersome and it prevents from
silly bugs such as "var+1" being considered a single identifier.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
| |
As a remnant of old code, the 'parse_decimal' function was not allowing
for decimal values larger than 8-bits. This was not the case in other
areas such as 'parse_hexadecimal', and in the rest of the code we
already cover that immediates are not too big in instructions. Hence,
this restriction can be lift up and allow up to 16-bit decimal literals.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
They are just synonyms for ".if .defined" and ".if !.defined"
respectively.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
| |
This can be combined with .if/.elsif statements just like any other
expression.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
| |
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Allow for expressions that evaluate to a boolean expression. This in
turn mean that the value is just set to 0 or 1 depending on the given
condition. As with other assemblers, only a value of 0 evaluates to 0,
and others go to 1. So, something like "1 && 2" evaluates to 1 even if
it doesn't make much sense at first glance (as an assembler we just
assume that the programmer knows what it's doing).
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
As with e27a1593c8d8 ("Allow semicolons inside of strings"), the parser
was too naive and regarded any '=' operator as part of an assignment,
despite that it could be art of string literal.
Luckily the fix was already done inside of the parsing of assignments,
we just needed to move it up.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The parser was too naive and assumed that a semicolon immediately
implied an inline comment, and that might not just be the case as it is
with string literals.
Hence, the end of each semantic line has to consider not only whether
there is an inline comment, but also if a string literal is being used
and whether it surrounds or not the given semicolon.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Some control statements (e.g. '.incbin', '.asciiz') only require a
double-quoted string as an argument. In fact, for these functions
there's only one argument required, which is this string one. Given this
fact, the parsing on these functions don't have to go through
the (expensive) general argument parsing function, and they can simply
assume that a double-quoted string will be provided.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
|