There are two ways in which the assembly process can fail:
1. If there is a really big problem that compromises the whole process,
the assembler has to stop right there and generate an error message.
This happens with unterminated REPT loops, macros, etc.
2. If the problem isn't that big and the process can still continue,
even though the final result is invalid, the assembler can try to
continue and warn the user about all errors it finds in the code.
This patch clarifies the use of each function and replaces the function
used in two places by the correct one.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This is hard to detect in MACROs, as there are legitimate uses for
MACROs that call themselves recursively.
For an EQUS, the problem is that its value may be modified at different
points in the source code, so the only way to detect a possible problem
is by doing an analysis at each usage of the EQUS.
Also, since an EQUS may expand to the name of a MACRO and a MACRO can
use an EQUS, it becomes even harder to check all possible problems that
come out of it. It's better to let this task to the programmer.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
When allocating a section, allocate only the max possible size for that
type (only applies to ROM0 and ROMX).
When finding an overflow, in any kind of section, output an error with
the location of the line of code that caused the overflow.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
The max size of some section types depends on the flags passed to
rgblink. Instead of doing in rgbasm some checks (for the sections with
fixed size) and others in rgblink, all checks are now done in rgblink.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Instead of allocating 0x4000 bytes for all sections and resize them as
needed, allocate 0x8000 bytes and don't let them to be resized. This is
the max possible size (ROM0 when ROMX sections aren't present).
Buffers are not needed for RAM sections, this patch changes the code so
that it only allocates buffers for ROM sections.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Files that weren't found with the absolute path weren't added as
dependencies even if they were found after considering the list of
include directories.
This patch makes rgbasm print the complete path (including the include
directory path) in these cases.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
For some reason, `No` looks weird in the HTML version of the docs.
Some other random fixes.
Tables in src/asm/rgbasm.5 are still broken in the HTML docs.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
When including a linkerscript from a parent one, the lexer didn't
include a newline character because the INCLUDE command was handled
before reaching the newline. This behaviour is needed to parse the last
line of a linkerscript correctly (it doesn't have a newline character).
However, this meant that when the included file was being parsed, the
first line was considered a continuation of the last line of the parent
script (the INCLUDE command), which means that the first line of an
included linkerscript could only contain a comment (or nothing at all).
This patch adds a newline character to the buffer used by the lexer so
that the parser will receive a newline and it will handle the first line
of the included file as expected.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
`LD HL,n16` and `LD SP,n16` are handled in a different rule as
`LD r16,n16`, but they are also part of that rule.
This patch converts the `LD r16,n16` rule into two rules, one for doing
`LD BC,n16` and other one for `LD DE,n16`.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
rgblink option -w has been restored to its previous behaviour: make WRAM
a continous section instead of spliting it into WRAM0 and WRAMX.
To enable DMG mode, option -d has to be used instead. This option
automatically enables -w.
Update tests.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
If the next release is going to break compatibility with older object
file formats it doesn't make sense to keep this.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Added `__TIMESTAMP_ISO_8601_LOCAL__` and `__TIMESTAMP_ISO_8601_UTC__`,
with the correct ISO 8601 representation of time and date from years to
seconds (including local timezone in the local time string).
Also, if the current time cannot be obtained from the OS, it will output
a warning and the time strings will be filled with '?' instead of
numbers and characters.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
If they don't have quotes when passed to sym_AddString() they can't be
used at all by the assembler. I suppose nobody actually used them, they
seem to have been broken forever.
Added a comment to the function to say how to use it correctly for
strings.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>