mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c59cb6a828 | ||
|
|
06aaf5b571 | ||
|
|
65d7909466 | ||
|
|
861192c332 | ||
|
|
c63af05427 | ||
|
|
d07ba6971b | ||
|
|
4b40d63dfd | ||
|
|
a99b7f6902 | ||
|
|
b3391f699f | ||
|
|
5a3c12cc6b | ||
|
|
a05fd9b818 | ||
|
|
6c1ec59a5b | ||
|
|
e25a4b0abc | ||
|
|
a060f135b8 | ||
|
|
f5d3087e9b | ||
|
|
2795404cd7 | ||
|
|
16fac50db4 | ||
|
|
3806eb3139 | ||
|
|
bad66e54fa | ||
|
|
5cb6c4af4b | ||
|
|
69f79f8598 | ||
|
|
573011a99e | ||
|
|
d778b8e71c | ||
|
|
432a7574c9 | ||
|
|
4d2598e7bf | ||
|
|
2e565bcb4e | ||
|
|
62ecb6da0b | ||
|
|
46fcebe2b5 | ||
|
|
ab1901eeac | ||
|
|
29d2fc6ebc | ||
|
|
efe4599bd8 | ||
|
|
4fc1e41b16 | ||
|
|
e771d60ec0 | ||
|
|
e2de106d71 | ||
|
|
adea89f3eb | ||
|
|
361015497c | ||
|
|
5e9c433a24 | ||
|
|
587159448a | ||
|
|
64158cf513 | ||
|
|
a567365d7c | ||
|
|
57bf220e40 | ||
|
|
e6e3cc474d | ||
|
|
33c984e456 | ||
|
|
458f79f44f | ||
|
|
34e04b0327 | ||
|
|
cf7bb9e99f | ||
|
|
1af5343e29 | ||
|
|
a5e3a7cbc9 | ||
|
|
df065dbbcb | ||
|
|
fac7247483 | ||
|
|
60050af186 | ||
|
|
11c47570ce | ||
|
|
f8b4cc52f6 |
@@ -19,6 +19,9 @@
|
|||||||
# Don't expect SPDX tag in the first line of a file
|
# Don't expect SPDX tag in the first line of a file
|
||||||
--ignore SPDX_LICENSE_TAG
|
--ignore SPDX_LICENSE_TAG
|
||||||
|
|
||||||
|
# Don't expect Signed-off-by lines in commit messages
|
||||||
|
--no-signoff
|
||||||
|
|
||||||
# List of ignored rules
|
# List of ignored rules
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
||||||
|
|||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -5,3 +5,7 @@ rgbgfx
|
|||||||
*.o
|
*.o
|
||||||
*.exe
|
*.exe
|
||||||
.checkpatch-camelcase.*
|
.checkpatch-camelcase.*
|
||||||
|
|
||||||
|
test/pokecrystal/*
|
||||||
|
test/pokered/*
|
||||||
|
test/ucity/*
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
if [ $TRAVIS_OS_NAME = "osx" ]; then
|
if [ $TRAVIS_OS_NAME = "osx" ]; then
|
||||||
brew update
|
brew update
|
||||||
brew install libpng pkg-config
|
brew install libpng pkg-config md5sha1sum
|
||||||
else # linux
|
else # linux
|
||||||
sudo apt-get -qq update
|
sudo apt-get -qq update
|
||||||
sudo apt-get install -y -q bison flex libpng-dev pkg-config
|
sudo apt-get install -y -q bison flex libpng-dev pkg-config
|
||||||
|
|||||||
@@ -6,10 +6,14 @@ install:
|
|||||||
- sudo make install
|
- sudo make install
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
|
- osx
|
||||||
compiler:
|
compiler:
|
||||||
- clang
|
- clang
|
||||||
- gcc
|
- gcc
|
||||||
|
script:
|
||||||
|
- cd test && ./run-tests.sh
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- env: _="checkpatch"
|
||||||
script:
|
script:
|
||||||
- ./.travis-checkpatch.sh
|
- ./.travis-checkpatch.sh
|
||||||
- cd test
|
|
||||||
- ./run-tests.sh
|
|
||||||
|
|||||||
@@ -75,24 +75,22 @@ copyright and the reference to the MIT License.
|
|||||||
new warning (but it may be possible to remove some warning checks if it makes
|
new warning (but it may be possible to remove some warning checks if it makes
|
||||||
the code much easier).
|
the code much easier).
|
||||||
|
|
||||||
5. Sign off your commits: ``git commit -s``
|
5. Follow the Linux kernel coding style, which can be found in the file
|
||||||
|
|
||||||
6. Follow the Linux kernel coding style, which can be found in the file
|
|
||||||
``Documentation/process/coding-style.rst`` in the Linux kernel repository.
|
``Documentation/process/coding-style.rst`` in the Linux kernel repository.
|
||||||
Note that the coding style isn't writen on stone, if there is a good reason
|
Note that the coding style isn't written in stone, if there is a good reason
|
||||||
to deviate from it, it should be fine.
|
to deviate from it, it should be fine.
|
||||||
|
|
||||||
7. Download the files ``checkpatch.pl``, ``const_structs.checkpatch`` and
|
6. Download the files ``checkpatch.pl``, ``const_structs.checkpatch`` and
|
||||||
``spelling.txt`` from the folder ``scripts`` in the Linux kernel repository.
|
``spelling.txt`` from the folder ``scripts`` in the Linux kernel repository.
|
||||||
|
|
||||||
8. To use ``checkpatch.pl`` you can use ``make checkpatch``, which will check
|
7. To use ``checkpatch.pl`` you can use ``make checkpatch``, which will check
|
||||||
the coding style of all patches between the current one and the upstream
|
the coding style of all patches between the current one and the upstream
|
||||||
code. By default, the Makefile expects the script (and associate files) to be
|
code. By default, the Makefile expects the script (and associate files) to be
|
||||||
located in ``../linux/scripts/``, but you can place them anywhere you like as
|
located in ``../linux/scripts/``, but you can place them anywhere you like as
|
||||||
long as you specify it when executing the command:
|
long as you specify it when executing the command:
|
||||||
``CHECKPATCH=../path/to/folder make checkpatch``.
|
``CHECKPATCH=../path/to/folder make checkpatch``.
|
||||||
|
|
||||||
9. Create a pull request against the branch ``develop``.
|
8. Create a pull request against the branch ``develop``.
|
||||||
|
|
||||||
10. Be prepared to get some comments about your code and to modify it. Tip: Use
|
9. Be prepared to get some comments about your code and to modify it. Tip: Use
|
||||||
``git rebase -i origin/develop`` to modify chains of commits.
|
``git rebase -i origin/develop`` to modify chains of commits.
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ Other contributors
|
|||||||
|
|
||||||
- Christophe Staïesse <chastai@skynet.be>
|
- Christophe Staïesse <chastai@skynet.be>
|
||||||
|
|
||||||
|
- David Brotz <dbrotz007@gmail.com>
|
||||||
|
|
||||||
- The Musl C library <http://www.musl-libc.org>
|
- The Musl C library <http://www.musl-libc.org>
|
||||||
|
|
||||||
- obskyr <powpowd@gmail.com>
|
- obskyr <powpowd@gmail.com>
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -48,6 +48,7 @@ all: rgbasm rgblink rgbfix rgbgfx
|
|||||||
rgbasm_obj := \
|
rgbasm_obj := \
|
||||||
src/asm/asmy.o \
|
src/asm/asmy.o \
|
||||||
src/asm/charmap.o \
|
src/asm/charmap.o \
|
||||||
|
src/asm/constexpr.o \
|
||||||
src/asm/fstack.o \
|
src/asm/fstack.o \
|
||||||
src/asm/globlex.o \
|
src/asm/globlex.o \
|
||||||
src/asm/lexer.o \
|
src/asm/lexer.o \
|
||||||
@@ -61,7 +62,7 @@ rgbasm_obj := \
|
|||||||
src/version.o
|
src/version.o
|
||||||
|
|
||||||
src/asm/asmy.h: src/asm/asmy.c
|
src/asm/asmy.h: src/asm/asmy.c
|
||||||
src/asm/locallex.o src/asm/globlex.o src/asm/lexer.o: src/asm/asmy.h
|
src/asm/locallex.o src/asm/globlex.o src/asm/lexer.o src/asm/constexpr.o: src/asm/asmy.h
|
||||||
|
|
||||||
rgblink_obj := \
|
rgblink_obj := \
|
||||||
src/link/assign.o \
|
src/link/assign.o \
|
||||||
|
|||||||
11
README.rst
11
README.rst
@@ -56,7 +56,16 @@ To install RGBDS with all of the current changes in development (as seen on the
|
|||||||
|
|
||||||
brew install rgbds --HEAD
|
brew install rgbds --HEAD
|
||||||
|
|
||||||
1.3 Other UNIX-like systems
|
1.3 Arch Linux
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
To install RGBDS through the AUR run
|
||||||
|
|
||||||
|
.. code:: sh
|
||||||
|
|
||||||
|
yaourt -S rgbds
|
||||||
|
|
||||||
|
1.4 Other UNIX-like systems
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
No official binaries of RGBDS are distributed for these systems, you must follow
|
No official binaries of RGBDS are distributed for these systems, you must follow
|
||||||
|
|||||||
@@ -1148,7 +1148,17 @@ Cycles: 3
|
|||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
Bytes: 1
|
Bytes: 1
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
Flags: None affected.
|
Flags:
|
||||||
|
<ul class="Bl-bullet Bl-compact">
|
||||||
|
<li class="It-bullet"><b class="Sy" title="Sy">Z</b>: Set from bit 7 of the
|
||||||
|
popped low byte.</li>
|
||||||
|
<li class="It-bullet"><b class="Sy" title="Sy">N</b>: Set from bit 6 of the
|
||||||
|
popped low byte.</li>
|
||||||
|
<li class="It-bullet"><b class="Sy" title="Sy">H</b>: Set from bit 5 of the
|
||||||
|
popped low byte.</li>
|
||||||
|
<li class="It-bullet"><b class="Sy" title="Sy">C</b>: Set from bit 4 of the
|
||||||
|
popped low byte.</li>
|
||||||
|
</ul>
|
||||||
<h2 class="Ss" title="Ss" id="POP_r16"><a class="selflink" href="#POP_r16">POP
|
<h2 class="Ss" title="Ss" id="POP_r16"><a class="selflink" href="#POP_r16">POP
|
||||||
r16</a></h2>
|
r16</a></h2>
|
||||||
Pop register <var class="Ar" title="Ar">r16</var> from the stack.
|
Pop register <var class="Ar" title="Ar">r16</var> from the stack.
|
||||||
@@ -1160,7 +1170,11 @@ Bytes: 1
|
|||||||
Flags: None affected.
|
Flags: None affected.
|
||||||
<h2 class="Ss" title="Ss" id="PUSH_AF"><a class="selflink" href="#PUSH_AF">PUSH
|
<h2 class="Ss" title="Ss" id="PUSH_AF"><a class="selflink" href="#PUSH_AF">PUSH
|
||||||
AF</a></h2>
|
AF</a></h2>
|
||||||
Push register <b class="Sy" title="Sy">AF</b> into the stack.
|
Push register <b class="Sy" title="Sy">AF</b> into the stack. The low byte's bit
|
||||||
|
7 corresponds to the <b class="Sy" title="Sy">Z</b> flag, its bit 6 to the
|
||||||
|
<b class="Sy" title="Sy">N</b> flag, bit 5 to the
|
||||||
|
<b class="Sy" title="Sy">H</b> flag, and bit 4 to the
|
||||||
|
<b class="Sy" title="Sy">C</b> flag. Bits 3 to 0 are reset.
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
Cycles: 4
|
Cycles: 4
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
|
|||||||
@@ -49,10 +49,11 @@ All pseudo‐ops, mnemonics and registers (reserved keywords) are
|
|||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
There are two syntaxes for comments. In both cases, a comment ends at the end of
|
There are two syntaxes for comments. In both cases, a comment ends at the end of
|
||||||
the line. The most common one is: anything that follows a semicolon
|
the line. The most common one is: anything that follows a semicolon
|
||||||
";" (that isn't inside a string) is a comment. There is another
|
‘<code class="Li">;</code>’ (that isn't inside a string) is a
|
||||||
format: anything that follows a "*" that is placed right at the
|
comment. There is another format: anything that follows a
|
||||||
start of a line is a comment. The assembler removes all comments from the code
|
‘<code class="Li">*</code>’ that is placed right at the start of
|
||||||
before doing anything else.
|
a line is a comment. The assembler removes all comments from the code before
|
||||||
|
doing anything else.
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
Sometimes lines can be too long and it may be necessary to split them. The
|
Sometimes lines can be too long and it may be necessary to split them. The
|
||||||
syntax to do so is the following one:
|
syntax to do so is the following one:
|
||||||
@@ -65,7 +66,7 @@ Sometimes lines can be too long and it may be necessary to split them. The
|
|||||||
</div>
|
</div>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
This works anywhere in the code except inside of strings. To split strings it is
|
This works anywhere in the code except inside of strings. To split strings it is
|
||||||
needed to use <b class="Sy" title="Sy">STRCAT</b> like this:
|
needed to use <b class="Fn" title="Fn">STRCAT</b>() like this:
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
<div class="Bd" style="margin-left: 5.00ex;">
|
<div class="Bd" style="margin-left: 5.00ex;">
|
||||||
<pre class="Li">
|
<pre class="Li">
|
||||||
@@ -74,99 +75,140 @@ This works anywhere in the code except inside of strings. To split strings it is
|
|||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="Ss" title="Ss" id="Sections"><a class="selflink" href="#Sections">Sections</a></h2>
|
<h2 class="Ss" title="Ss" id="Sections"><a class="selflink" href="#Sections">Sections</a></h2>
|
||||||
|
<b class="Ic" title="Ic">SECTION</b> <var class="Ar" title="Ar">name</var>,
|
||||||
|
<var class="Ar" title="Ar">type</var>
|
||||||
|
<div class="Pp"></div>
|
||||||
|
<b class="Ic" title="Ic">SECTION</b> <var class="Ar" title="Ar">name</var>,
|
||||||
|
<var class="Ar" title="Ar">type</var>,
|
||||||
|
<var class="Ar" title="Ar">options</var>
|
||||||
|
<div class="Pp"></div>
|
||||||
|
<b class="Ic" title="Ic">SECTION</b> <var class="Ar" title="Ar">name</var>,
|
||||||
|
<var class="Ar" title="Ar">type</var>[<var class="Ar" title="Ar">addr</var>]
|
||||||
|
<div class="Pp"></div>
|
||||||
|
<b class="Ic" title="Ic">SECTION</b> <var class="Ar" title="Ar">name</var>,
|
||||||
|
<var class="Ar" title="Ar">type</var>[<var class="Ar" title="Ar">addr</var>],
|
||||||
|
<var class="Ar" title="Ar">options</var>
|
||||||
|
<div class="Pp"></div>
|
||||||
Before you can start writing code, you must define a section. This tells the
|
Before you can start writing code, you must define a section. This tells the
|
||||||
assembler what kind of information follows and, if it is code, where to put
|
assembler what kind of information follows and, if it is code, where to put
|
||||||
it.
|
it.
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
<div class="Bd" style="margin-left: 5.00ex;">
|
<var class="Ar" title="Ar">name</var> is a string enclosed in double quotes and
|
||||||
<pre class="Li">
|
can be a new name or the name of an existing section. All sections assembled
|
||||||
SECTION "CoolStuff",ROMX
|
at the same time that have the same name and type are considered to be the
|
||||||
</pre>
|
same section, and their code is put together in the object file generated by
|
||||||
</div>
|
the assembler. All other sections must have a unique name, even in different
|
||||||
|
source files, or the linker will treat it as an error.
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
This switches to the section called "CoolStuff" (or creates it if it
|
Possible section <var class="Ar" title="Ar">type</var>s are as follows:
|
||||||
doesn't already exist) and it defines it as a code section. All sections
|
|
||||||
assembled at the same time that have the same name, type, etc, are considered
|
|
||||||
to be the same one, and their code is put together in the object file
|
|
||||||
generated by the assembler. All other sections must have a unique name, even
|
|
||||||
in different source files, or the linker will treat it as an error.
|
|
||||||
<div class="Pp"></div>
|
|
||||||
Possible section types are as follows:
|
|
||||||
<dl class="Bl-tag">
|
<dl class="Bl-tag">
|
||||||
<dt class="It-tag"> </dt>
|
<dt class="It-tag"> </dt>
|
||||||
<dd class="It-tag"> </dd>
|
<dd class="It-tag"> </dd>
|
||||||
<dt class="It-tag"><b class="Sy" title="Sy">ROM0</b></dt>
|
<dt class="It-tag"><a class="selflink" href="#ROM0"><b class="Cm" title="Cm" id="ROM0">ROM0</b></a></dt>
|
||||||
<dd class="It-tag">A ROM section. Mapped to memory at $0000–$3FFF (or
|
<dd class="It-tag">A ROM section. <var class="Ar" title="Ar">addr</var> can
|
||||||
$0000-$7FFF if tiny ROM mode is enabled in
|
range from $0000–$3FFF (or $0000–$7FFF if tiny ROM mode is
|
||||||
<a class="Xr" title="Xr">rgblink(1)</a>).</dd>
|
enabled in <a class="Xr" title="Xr">rgblink(1)</a>).</dd>
|
||||||
<dt class="It-tag"> </dt>
|
<dt class="It-tag"> </dt>
|
||||||
<dd class="It-tag"> </dd>
|
<dd class="It-tag"> </dd>
|
||||||
<dt class="It-tag"><b class="Sy" title="Sy">ROMX</b></dt>
|
<dt class="It-tag"><a class="selflink" href="#ROMX"><b class="Cm" title="Cm" id="ROMX">ROMX</b></a></dt>
|
||||||
<dd class="It-tag">A banked ROM section. Mapped to memory at
|
<dd class="It-tag">A banked ROM section. <var class="Ar" title="Ar">addr</var>
|
||||||
$4000–$7FFF. Valid banks range from 1 to 511. Not available if tiny
|
can range from $4000–$7FFF. <var class="Ar" title="Ar">bank</var>
|
||||||
ROM mode is enabled in <a class="Xr" title="Xr">rgblink(1)</a>.</dd>
|
can range from 1 to 511. Not available if tiny ROM mode is enabled in
|
||||||
<dt class="It-tag"> </dt>
|
|
||||||
<dd class="It-tag"> </dd>
|
|
||||||
<dt class="It-tag"><b class="Sy" title="Sy">VRAM</b></dt>
|
|
||||||
<dd class="It-tag">A banked video RAM section. Mapped to memory at
|
|
||||||
$8000–$9FFF. Can only allocate memory, not fill it. Valid banks are
|
|
||||||
0 and 1 but bank 1 isn't available if DMG mode is enabled in
|
|
||||||
<a class="Xr" title="Xr">rgblink(1)</a>.</dd>
|
<a class="Xr" title="Xr">rgblink(1)</a>.</dd>
|
||||||
<dt class="It-tag"> </dt>
|
<dt class="It-tag"> </dt>
|
||||||
<dd class="It-tag"> </dd>
|
<dd class="It-tag"> </dd>
|
||||||
<dt class="It-tag"><b class="Sy" title="Sy">SRAM</b></dt>
|
<dt class="It-tag"><a class="selflink" href="#VRAM"><b class="Cm" title="Cm" id="VRAM">VRAM</b></a></dt>
|
||||||
<dd class="It-tag">A banked external (save) RAM section. Mapped to memory at
|
<dd class="It-tag">A banked video RAM section.
|
||||||
$A000–$BFFF. Can only allocate memory, not fill it. Valid banks
|
<var class="Ar" title="Ar">addr</var> can range from $8000–$9FFF.
|
||||||
range from 0 to 15.</dd>
|
<var class="Ar" title="Ar">bank</var> can be 0 or 1 but bank 1 is
|
||||||
|
unavailable if DMG mode is enabled in
|
||||||
|
<a class="Xr" title="Xr">rgblink(1)</a>. Memory in this section can only
|
||||||
|
be allocated with <b class="Sy" title="Sy">DS</b>, not filled with
|
||||||
|
data.</dd>
|
||||||
<dt class="It-tag"> </dt>
|
<dt class="It-tag"> </dt>
|
||||||
<dd class="It-tag"> </dd>
|
<dd class="It-tag"> </dd>
|
||||||
<dt class="It-tag"><b class="Sy" title="Sy">WRAM0</b></dt>
|
<dt class="It-tag"><a class="selflink" href="#SRAM"><b class="Cm" title="Cm" id="SRAM">SRAM</b></a></dt>
|
||||||
<dd class="It-tag">A general-purpose RAM section. Mapped to memory at
|
<dd class="It-tag">A banked external (save) RAM section.
|
||||||
$C000–$CFFF, or $C000-$DFFF if DMG mode is enabled in
|
<var class="Ar" title="Ar">addr</var> can range from $A000–$BFFF.
|
||||||
<a class="Xr" title="Xr">rgblink(1)</a>. Can only allocate memory, not
|
<var class="Ar" title="Ar">bank</var> can range from 0 to 15. Memory in
|
||||||
fill it.</dd>
|
this section can only be allocated with <b class="Sy" title="Sy">DS</b>,
|
||||||
|
not filled with data.</dd>
|
||||||
<dt class="It-tag"> </dt>
|
<dt class="It-tag"> </dt>
|
||||||
<dd class="It-tag"> </dd>
|
<dd class="It-tag"> </dd>
|
||||||
<dt class="It-tag"><b class="Sy" title="Sy">WRAMX</b></dt>
|
<dt class="It-tag"><a class="selflink" href="#WRAM0"><b class="Cm" title="Cm" id="WRAM0">WRAM0</b></a></dt>
|
||||||
<dd class="It-tag">A banked general-purpose RAM section. Mapped to memory at
|
<dd class="It-tag">A general-purpose RAM section.
|
||||||
$D000–$DFFF. Can only allocate memory, not fill it. Valid banks
|
<var class="Ar" title="Ar">addr</var> can range from $C000–$CFFF,
|
||||||
range from 1 to 7. Not available if DMG mode is enabled in
|
or $C000–$DFFF if DMG mode is enabled in
|
||||||
|
<a class="Xr" title="Xr">rgblink(1)</a>. Memory in this section can only
|
||||||
|
be allocated with <b class="Sy" title="Sy">DS</b>, not filled with
|
||||||
|
data.</dd>
|
||||||
|
<dt class="It-tag"> </dt>
|
||||||
|
<dd class="It-tag"> </dd>
|
||||||
|
<dt class="It-tag"><a class="selflink" href="#WRAMX"><b class="Cm" title="Cm" id="WRAMX">WRAMX</b></a></dt>
|
||||||
|
<dd class="It-tag">A banked general-purpose RAM section.
|
||||||
|
<var class="Ar" title="Ar">addr</var> can range from $D000–$DFFF.
|
||||||
|
<var class="Ar" title="Ar">bank</var> can range from 1 to 7. Memory in
|
||||||
|
this section can only be allocated with <b class="Sy" title="Sy">DS</b>,
|
||||||
|
not filled with data. Not available if DMG mode is enabled in
|
||||||
<a class="Xr" title="Xr">rgblink(1)</a>.</dd>
|
<a class="Xr" title="Xr">rgblink(1)</a>.</dd>
|
||||||
<dt class="It-tag"> </dt>
|
<dt class="It-tag"> </dt>
|
||||||
<dd class="It-tag"> </dd>
|
<dd class="It-tag"> </dd>
|
||||||
<dt class="It-tag"><b class="Sy" title="Sy">OAM</b></dt>
|
<dt class="It-tag"><a class="selflink" href="#OAM"><b class="Cm" title="Cm" id="OAM">OAM</b></a></dt>
|
||||||
<dd class="It-tag">An object attributes RAM section. Mapped to memory at
|
<dd class="It-tag">An object attributes RAM section.
|
||||||
$FE00-$FE9F. Can only allocate memory, not fill it.</dd>
|
<var class="Ar" title="Ar">addr</var> can range from $FE00-$FE9F. Memory
|
||||||
|
in this section can only be allocated with
|
||||||
|
<b class="Sy" title="Sy">DS</b>, not filled with data.</dd>
|
||||||
<dt class="It-tag"> </dt>
|
<dt class="It-tag"> </dt>
|
||||||
<dd class="It-tag"> </dd>
|
<dd class="It-tag"> </dd>
|
||||||
<dt class="It-tag"><b class="Sy" title="Sy">HRAM</b></dt>
|
<dt class="It-tag"><a class="selflink" href="#HRAM"><b class="Cm" title="Cm" id="HRAM">HRAM</b></a></dt>
|
||||||
<dd class="It-tag">A high RAM section. Mapped to memory at $FF80–$FFFE.
|
<dd class="It-tag">A high RAM section. <var class="Ar" title="Ar">addr</var>
|
||||||
Can only allocate memory, not fill it.
|
can range from $FF80–$FFFE. Memory in this section can only be
|
||||||
|
allocated with <b class="Sy" title="Sy">DS</b>, not filled with data.
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
NOTE: If you use this method of allocating HRAM the assembler will NOT
|
<b class="Sy" title="Sy">Note</b>: If you use this method of allocating HRAM
|
||||||
choose the short addressing mode in the LD instructions
|
the assembler will <i class="Em" title="Em">not</i> choose the short
|
||||||
<b class="Sy" title="Sy">LD [$FF00+n8],A</b> and
|
addressing mode in the LD instructions <b class="Sy" title="Sy">LD
|
||||||
<b class="Sy" title="Sy">LD A,[$FF00+n8]</b> because the actual address
|
[$FF00+n8],A</b> and <b class="Sy" title="Sy">LD A,[$FF00+n8]</b> because
|
||||||
calculation is done by the linker. If you find this undesirable you can
|
the actual address calculation is done by the linker. If you find this
|
||||||
use <b class="Ic" title="Ic">RSSET</b> <span class="No">/</span>
|
undesirable you can use <b class="Ic" title="Ic">RSSET</b>,
|
||||||
<b class="Ic" title="Ic">RB</b> <span class="No">/</span>
|
<b class="Ic" title="Ic">RB</b>, or <b class="Ic" title="Ic">RW</b>
|
||||||
<b class="Ic" title="Ic">RW</b> instead or use the
|
instead or use the <b class="Sy" title="Sy">LDH [$FF00+n8],A</b> and
|
||||||
<b class="Sy" title="Sy">LDH [$FF00+n8],A</b> and
|
|
||||||
<b class="Sy" title="Sy">LDH A,[$FF00+n8]</b> syntax instead. This forces
|
<b class="Sy" title="Sy">LDH A,[$FF00+n8]</b> syntax instead. This forces
|
||||||
the assembler to emit the correct instruction and the linker to check if
|
the assembler to emit the correct instruction and the linker to check if
|
||||||
the value is in the correct range. This optimization can be disabled by
|
the value is in the correct range. This optimization can be disabled by
|
||||||
passing the <b class="Fl" title="Fl">-L</b> flag to
|
passing the <b class="Fl" title="Fl">-L</b> flag to
|
||||||
<b class="Sy" title="Sy">rgbasm</b> as explained in
|
|
||||||
<a class="Xr" title="Xr">rgbasm(1)</a>.</dd>
|
<a class="Xr" title="Xr">rgbasm(1)</a>.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
A section is usually defined as a floating one, but the code can restrict where
|
<var class="Ar" title="Ar">option</var>s are comma separated and may include:
|
||||||
the linker can place it.
|
<dl class="Bl-tag">
|
||||||
|
<dt class="It-tag"> </dt>
|
||||||
|
<dd class="It-tag"> </dd>
|
||||||
|
<dt class="It-tag"><a class="selflink" href="#BANK"><b class="Cm" title="Cm" id="BANK">BANK</b></a>[<var class="Ar" title="Ar">bank</var>]</dt>
|
||||||
|
<dd class="It-tag">Specify which <var class="Ar" title="Ar">bank</var> for the
|
||||||
|
linker to place the section.</dd>
|
||||||
|
<dt class="It-tag"> </dt>
|
||||||
|
<dd class="It-tag"> </dd>
|
||||||
|
<dt class="It-tag"><a class="selflink" href="#ALIGN"><b class="Cm" title="Cm" id="ALIGN">ALIGN</b></a>[<var class="Ar" title="Ar">align</var>]</dt>
|
||||||
|
<dd class="It-tag">Place the section at an address whose
|
||||||
|
<var class="Ar" title="Ar">align</var> least‐significant bits are
|
||||||
|
zero. It is a syntax error to use this option with
|
||||||
|
<var class="Ar" title="Ar">addr</var>.</dd>
|
||||||
|
</dl>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
If a section is defined with no indications, it is a floating section. The
|
If [<var class="Ar" title="Ar">addr</var>] is not specified, the section is
|
||||||
linker will decide where to place it in the final binary and it has no
|
considered “floating”; the linker will automatically calculate
|
||||||
obligation to follow any specific rules. The following example defines a
|
an appropriate address for the section. Similarly, if
|
||||||
section that can be placed anywhere in any ROMX bank:
|
<b class="Cm" title="Cm">BANK</b>[<var class="Ar" title="Ar">bank</var>] is
|
||||||
|
not specified, the linker will automatically find a bank with enough space.
|
||||||
|
<div class="Pp"></div>
|
||||||
|
Sections can also be placed by using a linkerscript file. The format is
|
||||||
|
described in <a class="Xr" title="Xr">rgblink(5)</a>. They allow the user to
|
||||||
|
place floating sections in the desired bank in the order specified in the
|
||||||
|
script. This is useful if the sections can't be placed at an address manually
|
||||||
|
because the size may change, but they have to be together.
|
||||||
|
<div class="Pp"></div>
|
||||||
|
Section examples:
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
<div class="Bd" style="margin-left: 5.00ex;">
|
<div class="Bd" style="margin-left: 5.00ex;">
|
||||||
<pre class="Li">
|
<pre class="Li">
|
||||||
@@ -174,8 +216,19 @@ If a section is defined with no indications, it is a floating section. The
|
|||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
If it is needed, the following syntax can be used to fix the base address of the
|
This switches to the section called “CoolStuff” (or creates it if
|
||||||
section:
|
it doesn't already exist) and defines it as a code section.
|
||||||
|
<div class="Pp"></div>
|
||||||
|
The following example defines a section that can be placed anywhere in any ROMX
|
||||||
|
bank:
|
||||||
|
<div class="Pp"></div>
|
||||||
|
<div class="Bd" style="margin-left: 5.00ex;">
|
||||||
|
<pre class="Li">
|
||||||
|
SECTION "CoolStuff",ROMX
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<div class="Pp"></div>
|
||||||
|
If it is needed, the the base address of the section can be specified:
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
<div class="Bd" style="margin-left: 5.00ex;">
|
<div class="Bd" style="margin-left: 5.00ex;">
|
||||||
<pre class="Li">
|
<pre class="Li">
|
||||||
@@ -183,8 +236,7 @@ If it is needed, the following syntax can be used to fix the base address of the
|
|||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
It won't, however, fix the bank number, which is left to the linker. If you also
|
An example with a fixed bank:
|
||||||
want to specify the bank you can do:
|
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
<div class="Bd" style="margin-left: 5.00ex;">
|
<div class="Bd" style="margin-left: 5.00ex;">
|
||||||
<pre class="Li">
|
<pre class="Li">
|
||||||
@@ -201,11 +253,7 @@ And if you only want to force the section into a certain bank, and not it's
|
|||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
In addition, you can specify byte alignment for a section. This ensures that the
|
Alignment examples: one use could be when using DMA to copy data or when it is
|
||||||
section starts at a memory address where the given number of least-significant
|
|
||||||
bits are 0. This can be used along with <b class="Ic" title="Ic">BANK</b>, if
|
|
||||||
desired. However, if an alignment is specified, the base address must be left
|
|
||||||
unassigned. This can be useful when using DMA to copy data or when it is
|
|
||||||
needed to align the start of an array to 256 bytes to optimize the code that
|
needed to align the start of an array to 256 bytes to optimize the code that
|
||||||
accesses it.
|
accesses it.
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
@@ -217,26 +265,23 @@ In addition, you can specify byte alignment for a section. This ensures that the
|
|||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
HINT: If you think this is a lot of typing for doing a simple
|
<b class="Sy" title="Sy">Hint</b>: If you think this is a lot of typing for
|
||||||
<b class="Ic" title="Ic">ORG</b> type thing you can quite easily write an
|
doing a simple “org” type thing you can quite easily write an
|
||||||
intelligent macro (called <b class="Ic" title="Ic">ORG</b> for example) that
|
intelligent macro (called <b class="Ic" title="Ic">ORG</b> for example) that
|
||||||
uses <b class="Ic" title="Ic">@</b> for the section name and determines
|
uses <b class="Ic" title="Ic">@</b> for the section name and determines
|
||||||
correct section type etc as arguments for
|
correct section type etc as arguments for
|
||||||
<b class="Ic" title="Ic">SECTION</b>.
|
<b class="Ic" title="Ic">SECTION</b>.
|
||||||
<div class="Pp"></div>
|
<h2 class="Ss" title="Ss" id="Section_Stack"><a class="selflink" href="#Section_Stack">Section
|
||||||
|
Stack</a></h2>
|
||||||
<b class="Ic" title="Ic">POPS</b> and <b class="Ic" title="Ic">PUSHS</b> provide
|
<b class="Ic" title="Ic">POPS</b> and <b class="Ic" title="Ic">PUSHS</b> provide
|
||||||
the interface to the section stack. <b class="Ic" title="Ic">PUSHS</b> will
|
the interface to the section stack.
|
||||||
push the current section context on the section stack.
|
|
||||||
<b class="Ic" title="Ic">POPS</b> can then later be used to restore it. Useful
|
|
||||||
for defining sections in included files when you don't want to destroy the
|
|
||||||
section context for the program that included your file. The number of entries
|
|
||||||
in the stack is limited only by the amount of memory in your machine.
|
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
Sections can also be placed by using a linkerscript file. The format is
|
<b class="Ic" title="Ic">PUSHS</b> will push the current section context on the
|
||||||
described in <a class="Xr" title="Xr">rgblink(5)</a>. They allow the user to
|
section stack. <b class="Ic" title="Ic">POPS</b> can then later be used to
|
||||||
place floating sections in the desired bank in the order specified in the
|
restore it. Useful for defining sections in included files when you don't want
|
||||||
script. This is useful if the sections can't be placed at an address manually
|
to destroy the section context for the program that included your file. The
|
||||||
because the size may change, but they have to be together.
|
number of entries in the stack is limited only by the amount of memory in your
|
||||||
|
machine.
|
||||||
<h1 class="Sh" title="Sh" id="SYMBOLS"><a class="selflink" href="#SYMBOLS">SYMBOLS</a></h1>
|
<h1 class="Sh" title="Sh" id="SYMBOLS"><a class="selflink" href="#SYMBOLS">SYMBOLS</a></h1>
|
||||||
<h2 class="Ss" title="Ss" id="Symbols"><a class="selflink" href="#Symbols">Symbols</a></h2>
|
<h2 class="Ss" title="Ss" id="Symbols"><a class="selflink" href="#Symbols">Symbols</a></h2>
|
||||||
RGBDS supports several types of symbols:
|
RGBDS supports several types of symbols:
|
||||||
@@ -254,7 +299,7 @@ RGBDS supports several types of symbols:
|
|||||||
<dt class="It-hang"><b class="Sy" title="Sy">String equate</b>
|
<dt class="It-hang"><b class="Sy" title="Sy">String equate</b>
|
||||||
(<b class="Sy" title="Sy">EQUS</b>)</dt>
|
(<b class="Sy" title="Sy">EQUS</b>)</dt>
|
||||||
<dd class="It-hang">Give a frequently used string a name. Can also be used as
|
<dd class="It-hang">Give a frequently used string a name. Can also be used as
|
||||||
a mini-macro, like #define in C.</dd>
|
a mini-macro, like <b class="Fd" title="Fd">#define</b> in C.</dd>
|
||||||
<dt class="It-hang"><b class="Sy" title="Sy">MACRO</b></dt>
|
<dt class="It-hang"><b class="Sy" title="Sy">MACRO</b></dt>
|
||||||
<dd class="It-hang">A block of code or pseudo instructions that you invoke
|
<dd class="It-hang">A block of code or pseudo instructions that you invoke
|
||||||
like any other mnemonic. You can give them arguments too.</dd>
|
like any other mnemonic. You can give them arguments too.</dd>
|
||||||
@@ -370,18 +415,14 @@ str_SIZEOF = 259
|
|||||||
There are four commands in the RS group of commands:
|
There are four commands in the RS group of commands:
|
||||||
<table class="Bl-column">
|
<table class="Bl-column">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 15.00ex;"/>
|
<col style="min-width: 15.00ex;"/>
|
||||||
<col style="min-width: 10.00ex;"/>
|
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Command</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Command</b></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Meaning</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Meaning</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#RSRESET"><b class="Ic" title="Ic" id="RSRESET">RSRESET</b></a></td>
|
<td class="It-column"><a class="selflink" href="#RSRESET"><b class="Ic" title="Ic" id="RSRESET">RSRESET</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Resets the _RS counter to zero.</td>
|
<td class="It-column">Resets the _RS counter to zero.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
@@ -425,7 +466,7 @@ str_SIZEOF = 259
|
|||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
EQUS is used to define string-symbols. Wherever the assembler meets a string
|
EQUS is used to define string-symbols. Wherever the assembler meets a string
|
||||||
symbol its name is replaced with its value. If you are familiar with C you
|
symbol its name is replaced with its value. If you are familiar with C you
|
||||||
can think of it as the same as #define.
|
can think of it as the same as <b class="Fd" title="Fd">#define .</b>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
<div class="Bd" style="margin-left: 5.00ex;">
|
<div class="Bd" style="margin-left: 5.00ex;">
|
||||||
<pre class="Li">
|
<pre class="Li">
|
||||||
@@ -604,11 +645,10 @@ ENDM
|
|||||||
</div>
|
</div>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
<b class="Ic" title="Ic">SHIFT</b> is a special command only available in
|
<b class="Ic" title="Ic">SHIFT</b> is a special command only available in
|
||||||
macros. Very useful in REPT-blocks. It will "shift" the
|
macros. Very useful in REPT-blocks. It will shift the arguments by one to
|
||||||
arguments by one "to the left". <b class="Ic" title="Ic">\1</b>
|
the left. <b class="Ic" title="Ic">\1</b> will get the value of
|
||||||
will get the value of <b class="Ic" title="Ic">\2</b>,
|
<b class="Ic" title="Ic">\2</b>, <b class="Ic" title="Ic">\2</b> will get
|
||||||
<b class="Ic" title="Ic">\2</b> will get the value in
|
the value in <b class="Ic" title="Ic">\3</b> and so forth.
|
||||||
<b class="Ic" title="Ic">\3</b> and so forth.
|
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
This is the only way of accessing the value of arguments from 10 to
|
This is the only way of accessing the value of arguments from 10 to
|
||||||
256.</dd>
|
256.</dd>
|
||||||
@@ -658,62 +698,52 @@ Note that string symbols that are part of a <b class="Ic" title="Ic">PURGE</b>
|
|||||||
The following symbols are defined by the assembler:
|
The following symbols are defined by the assembler:
|
||||||
<table class="Bl-column" style="margin-left: 6.00ex;">
|
<table class="Bl-column" style="margin-left: 6.00ex;">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 15.00ex;"/>
|
<col style="width: 7.80ex;"/>
|
||||||
<col style="width: 15.00ex;"/>
|
<col style="min-width: 18.00ex;"/>
|
||||||
<col style="min-width: 10.00ex;"/>
|
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Type</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Type</b></td>
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Name</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Name</b></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Contents</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Contents</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#@"><b class="Ic" title="Ic" id="@">@</b></a></td>
|
<td class="It-column"><a class="selflink" href="#@"><b class="Ic" title="Ic" id="@">@</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">PC value</td>
|
<td class="It-column">PC value</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#_PI"><b class="Ic" title="Ic" id="_PI">_PI</b></a></td>
|
<td class="It-column"><a class="selflink" href="#_PI"><b class="Ic" title="Ic" id="_PI">_PI</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Fixed point π</td>
|
<td class="It-column">Fixed point π</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#SET"><b class="Ic" title="Ic" id="SET">SET</b></a></td>
|
<td class="It-column"><a class="selflink" href="#SET"><b class="Ic" title="Ic" id="SET">SET</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#_RS"><b class="Ic" title="Ic" id="_RS">_RS</b></a></td>
|
<td class="It-column"><a class="selflink" href="#_RS"><b class="Ic" title="Ic" id="_RS">_RS</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">_RS Counter</td>
|
<td class="It-column">_RS Counter</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#_NARG"><b class="Ic" title="Ic" id="_NARG">_NARG</b></a></td>
|
<td class="It-column"><a class="selflink" href="#_NARG"><b class="Ic" title="Ic" id="_NARG">_NARG</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Number of arguments passed to macro</td>
|
<td class="It-column">Number of arguments passed to macro</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__LINE__"><b class="Ic" title="Ic" id="__LINE__">__LINE__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__LINE__"><b class="Ic" title="Ic" id="__LINE__">__LINE__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">The current line number</td>
|
<td class="It-column">The current line number</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQUS"><b class="Ic" title="Ic" id="EQUS">EQUS</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQUS"><b class="Ic" title="Ic" id="EQUS">EQUS</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__FILE__"><b class="Ic" title="Ic" id="__FILE__">__FILE__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__FILE__"><b class="Ic" title="Ic" id="__FILE__">__FILE__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">The current filename</td>
|
<td class="It-column">The current filename</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQUS"><b class="Ic" title="Ic" id="EQUS">EQUS</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQUS"><b class="Ic" title="Ic" id="EQUS">EQUS</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__DATE__"><b class="Ic" title="Ic" id="__DATE__">__DATE__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__DATE__"><b class="Ic" title="Ic" id="__DATE__">__DATE__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Today's date</td>
|
<td class="It-column">Today's date</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQUS"><b class="Ic" title="Ic" id="EQUS">EQUS</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQUS"><b class="Ic" title="Ic" id="EQUS">EQUS</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__TIME__"><b class="Ic" title="Ic" id="__TIME__">__TIME__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__TIME__"><b class="Ic" title="Ic" id="__TIME__">__TIME__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">The current time</td>
|
<td class="It-column">The current time</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
@@ -729,55 +759,46 @@ The following symbols are defined by the assembler:
|
|||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__UTC_YEAR__"><b class="Ic" title="Ic" id="__UTC_YEAR__">__UTC_YEAR__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__UTC_YEAR__"><b class="Ic" title="Ic" id="__UTC_YEAR__">__UTC_YEAR__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Today's year</td>
|
<td class="It-column">Today's year</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__UTC_MONTH__"><b class="Ic" title="Ic" id="__UTC_MONTH__">__UTC_MONTH__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__UTC_MONTH__"><b class="Ic" title="Ic" id="__UTC_MONTH__">__UTC_MONTH__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Today's month number, 1-12</td>
|
<td class="It-column">Today's month number, 1-12</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__UTC_DAY__"><b class="Ic" title="Ic" id="__UTC_DAY__">__UTC_DAY__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__UTC_DAY__"><b class="Ic" title="Ic" id="__UTC_DAY__">__UTC_DAY__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Today's day of the month, 1-31</td>
|
<td class="It-column">Today's day of the month, 1-31</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__UTC_HOUR__"><b class="Ic" title="Ic" id="__UTC_HOUR__">__UTC_HOUR__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__UTC_HOUR__"><b class="Ic" title="Ic" id="__UTC_HOUR__">__UTC_HOUR__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Current hour, 0-23</td>
|
<td class="It-column">Current hour, 0-23</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__UTC_MINUTE__"><b class="Ic" title="Ic" id="__UTC_MINUTE__">__UTC_MINUTE__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__UTC_MINUTE__"><b class="Ic" title="Ic" id="__UTC_MINUTE__">__UTC_MINUTE__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Current minute, 0-59</td>
|
<td class="It-column">Current minute, 0-59</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__UTC_SECOND__"><b class="Ic" title="Ic" id="__UTC_SECOND__">__UTC_SECOND__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__UTC_SECOND__"><b class="Ic" title="Ic" id="__UTC_SECOND__">__UTC_SECOND__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Current second, 0-59</td>
|
<td class="It-column">Current second, 0-59</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__RGBDS_MAJOR__"><b class="Ic" title="Ic" id="__RGBDS_MAJOR__">__RGBDS_MAJOR__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__RGBDS_MAJOR__"><b class="Ic" title="Ic" id="__RGBDS_MAJOR__">__RGBDS_MAJOR__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Major version number of RGBDS.</td>
|
<td class="It-column">Major version number of RGBDS.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__RGBDS_MINOR__"><b class="Ic" title="Ic" id="__RGBDS_MINOR__">__RGBDS_MINOR__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__RGBDS_MINOR__"><b class="Ic" title="Ic" id="__RGBDS_MINOR__">__RGBDS_MINOR__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Minor version number of RGBDS.</td>
|
<td class="It-column">Minor version number of RGBDS.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
<td class="It-column"><a class="selflink" href="#EQU"><b class="Ic" title="Ic" id="EQU">EQU</b></a></td>
|
||||||
<td class="It-column"><a class="selflink" href="#__RGBDS_PATCH__"><b class="Ic" title="Ic" id="__RGBDS_PATCH__">__RGBDS_PATCH__</b></a></td>
|
<td class="It-column"><a class="selflink" href="#__RGBDS_PATCH__"><b class="Ic" title="Ic" id="__RGBDS_PATCH__">__RGBDS_PATCH__</b></a></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column">Patch version number of RGBDS.</td>
|
<td class="It-column">Patch version number of RGBDS.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1039,15 +1060,15 @@ A great number of operators you can use in expressions are available (listed in
|
|||||||
order of precedence):
|
order of precedence):
|
||||||
<table class="Bl-column" style="margin-left: 6.00ex;">
|
<table class="Bl-column" style="margin-left: 6.00ex;">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 15.00ex;"/>
|
<col style="min-width: 8.00ex;"/>
|
||||||
<col style="min-width: 10.00ex;"/>
|
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Operator</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Operator</b></td>
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Meaning</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Meaning</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column">()</td>
|
<td class="It-column"><a class="selflink" href="#(_)"><code class="Li" id="(_)">(
|
||||||
|
)</code></a></td>
|
||||||
<td class="It-column">Precedence override</td>
|
<td class="It-column">Precedence override</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
@@ -1070,8 +1091,8 @@ A great number of operators you can use in expressions are available (listed in
|
|||||||
<td class="It-column">Shift left/right</td>
|
<td class="It-column">Shift left/right</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#&"><code class="Li" id="&">&</code></a>
|
<td class="It-column"><a class="selflink" href="#&_|_^"><code class="Li" id="&_|_^">&
|
||||||
| <a class="selflink" href="#^"><code class="Li" id="^">^</code></a></td>
|
| ^</code></a></td>
|
||||||
<td class="It-column">Binary and/or/xor</td>
|
<td class="It-column">Binary and/or/xor</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
@@ -1096,7 +1117,7 @@ A great number of operators you can use in expressions are available (listed in
|
|||||||
<td class="It-column">Boolean and/or</td>
|
<td class="It-column">Boolean and/or</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column">!</td>
|
<td class="It-column"><a class="selflink" href="#!"><code class="Li" id="!">!</code></a></td>
|
||||||
<td class="It-column">Unary Boolean not</td>
|
<td class="It-column">Unary Boolean not</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1127,57 +1148,90 @@ Some things are different for fixed-point math, though, which is why you have
|
|||||||
the following functions to use:
|
the following functions to use:
|
||||||
<table class="Bl-column" style="margin-left: 6.00ex;">
|
<table class="Bl-column" style="margin-left: 6.00ex;">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 15.00ex;"/>
|
<col style="min-width: 11.00ex;"/>
|
||||||
<col style="min-width: 10.00ex;"/>
|
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Name</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Name</b></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Operation</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Operation</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#DIV(x,y)"><code class="Li" id="DIV(x,y)">DIV(x,y)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">DIV</b>(<var class="Fa" title="Fa">x</var>,
|
||||||
<td class="It-column"></td>
|
<var class="Fa" title="Fa">y</var>)</td>
|
||||||
<td class="It-column">x/y</td>
|
<td class="It-column">
|
||||||
|
<math class="eqn">
|
||||||
|
<mrow><mi>x</mi><mo>÷</mo><mi>y</mi></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#MUL(x,y)"><code class="Li" id="MUL(x,y)">MUL(x,y)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">MUL</b>(<var class="Fa" title="Fa">x</var>,
|
||||||
<td class="It-column"></td>
|
<var class="Fa" title="Fa">y</var>)</td>
|
||||||
<td class="It-column">x*y</td>
|
<td class="It-column">
|
||||||
|
<math class="eqn">
|
||||||
|
<mrow><mi>x</mi><mo>×</mo><mi>y</mi></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#SIN(x)"><code class="Li" id="SIN(x)">SIN(x)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">SIN</b>(<var class="Fa" title="Fa">x</var>)</td>
|
||||||
<td class="It-column"></td>
|
<td class="It-column">
|
||||||
<td class="It-column">sin(x)</td>
|
<math class="eqn">
|
||||||
|
<mrow><mi>sin</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#COS(x)"><code class="Li" id="COS(x)">COS(x)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">COS</b>(<var class="Fa" title="Fa">x</var>)</td>
|
||||||
<td class="It-column"></td>
|
<td class="It-column">
|
||||||
<td class="It-column">cos(x)</td>
|
<math class="eqn">
|
||||||
|
<mrow><mi>cos</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#TAN(x)"><code class="Li" id="TAN(x)">TAN(x)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">TAN</b>(<var class="Fa" title="Fa">x</var>)</td>
|
||||||
<td class="It-column"></td>
|
<td class="It-column">
|
||||||
<td class="It-column">tan(x)</td>
|
<math class="eqn">
|
||||||
|
<mrow><mi>tan</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#ASIN(x)"><code class="Li" id="ASIN(x)">ASIN(x)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">ASIN</b>(<var class="Fa" title="Fa">x</var>)</td>
|
||||||
<td class="It-column"></td>
|
<td class="It-column">
|
||||||
<td class="It-column">arcsin(x)</td>
|
<math class="eqn">
|
||||||
|
<mrow><mi>asin</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#ACOS(x)"><code class="Li" id="ACOS(x)">ACOS(x)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">ACOS</b>(<var class="Fa" title="Fa">x</var>)</td>
|
||||||
<td class="It-column"></td>
|
<td class="It-column">
|
||||||
<td class="It-column">arccos(x)</td>
|
<math class="eqn">
|
||||||
|
<mrow><mi>acos</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#ATAN(x)"><code class="Li" id="ATAN(x)">ATAN(x)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">ATAN</b>(<var class="Fa" title="Fa">x</var>)</td>
|
||||||
<td class="It-column"></td>
|
<td class="It-column">
|
||||||
<td class="It-column">arctan(x)</td>
|
<math class="eqn">
|
||||||
|
<mrow><mi>atan</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#ATAN2(x,y)"><code class="Li" id="ATAN2(x,y)">ATAN2(x,y)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">ATAN2</b>(<var class="Fa" title="Fa">x</var>,
|
||||||
<td class="It-column">Angle between (x,y) and (1,0)</td>
|
<var class="Fa" title="Fa">y</var>)</td>
|
||||||
|
<td class="It-column">Angle between
|
||||||
|
<math class="eqn">
|
||||||
|
<mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo></mrow>
|
||||||
|
</math>
|
||||||
|
and
|
||||||
|
<math class="eqn">
|
||||||
|
<mrow><mo>(</mo><mn>1</mn><mo>,</mo><mn>0</mn><mo>)</mo></mrow>
|
||||||
|
</math>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
@@ -1203,8 +1257,7 @@ The most basic string expression is any number of characters contained in double
|
|||||||
there are a number of commands you can use within a string:
|
there are a number of commands you can use within a string:
|
||||||
<table class="Bl-column" style="margin-left: 6.00ex;">
|
<table class="Bl-column" style="margin-left: 6.00ex;">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 15.00ex;"/>
|
<col style="min-width: 6.00ex;"/>
|
||||||
<col style="min-width: 10.00ex;"/>
|
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><b class="Sy" title="Sy">String</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">String</b></td>
|
||||||
@@ -1250,7 +1303,7 @@ The most basic string expression is any number of characters contained in double
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
A funky feature is <b class="Sy" title="Sy">{symbol}</b> withing a string. This
|
A funky feature is <b class="Sy" title="Sy">{symbol}</b> within a string. This
|
||||||
will examine the type of the symbol and insert its value accordingly. If
|
will examine the type of the symbol and insert its value accordingly. If
|
||||||
symbol is a string symbol, the symbols value is simply copied. If it's a
|
symbol is a string symbol, the symbols value is simply copied. If it's a
|
||||||
numeric symbol, the value is converted to hexadecimal notation and inserted as
|
numeric symbol, the value is converted to hexadecimal notation and inserted as
|
||||||
@@ -1258,7 +1311,7 @@ A funky feature is <b class="Sy" title="Sy">{symbol}</b> withing a string. This
|
|||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
HINT: The <b class="Sy" title="Sy">{symbol}</b> construct can also be used
|
HINT: The <b class="Sy" title="Sy">{symbol}</b> construct can also be used
|
||||||
outside strings. The symbol's value is again inserted as a string. This is
|
outside strings. The symbol's value is again inserted as a string. This is
|
||||||
just a short way of doing "{symbol}".
|
just a short way of doing “{symbol}”.
|
||||||
<div class="Pp"></div>
|
<div class="Pp"></div>
|
||||||
Whenever the macro-language expects a string you can actually use a string
|
Whenever the macro-language expects a string you can actually use a string
|
||||||
expression. This consists of one or more of these function (yes, you can nest
|
expression. This consists of one or more of these function (yes, you can nest
|
||||||
@@ -1266,45 +1319,47 @@ Whenever the macro-language expects a string you can actually use a string
|
|||||||
used as part of an integer expression!
|
used as part of an integer expression!
|
||||||
<table class="Bl-column">
|
<table class="Bl-column">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 15.00ex;"/>
|
<col style="min-width: 20.00ex;"/>
|
||||||
<col style="min-width: 10.00ex;"/>
|
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Name</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Name</b></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Operation</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Operation</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#STRLEN(string)"><code class="Li" id="STRLEN(string)">STRLEN(string)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">STRLEN</b>(<var class="Fa" title="Fa">string</var>)</td>
|
||||||
<td class="It-column">Returns the number of characters in string</td>
|
<td class="It-column">Returns the number of characters in string</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#STRCAT(str1,str2)"><code class="Li" id="STRCAT(str1,str2)">STRCAT(str1,str2)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">STRCAT</b>(<var class="Fa" title="Fa">str1</var>,
|
||||||
|
<var class="Fa" title="Fa">str2</var>)</td>
|
||||||
<td class="It-column">Appends str2 to str1.</td>
|
<td class="It-column">Appends str2 to str1.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#STRCMP(str1,str2)"><code class="Li" id="STRCMP(str1,str2)">STRCMP(str1,str2)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">STRCMP</b>(<var class="Fa" title="Fa">str1</var>,
|
||||||
|
<var class="Fa" title="Fa">str2</var>)</td>
|
||||||
<td class="It-column">Returns negative if str1 is alphabetically lower than
|
<td class="It-column">Returns negative if str1 is alphabetically lower than
|
||||||
str2, zero if they match, positive if str1 is greater than str2.</td>
|
str2, zero if they match, positive if str1 is greater than str2.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#STRIN(str1,str2)"><code class="Li" id="STRIN(str1,str2)">STRIN(str1,str2)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">STRIN</b>(<var class="Fa" title="Fa">str1</var>,
|
||||||
|
<var class="Fa" title="Fa">str2</var>)</td>
|
||||||
<td class="It-column">Returns the position of str2 in str1 or zero if it's
|
<td class="It-column">Returns the position of str2 in str1 or zero if it's
|
||||||
not present (first character is position 1).</td>
|
not present (first character is position 1).</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#STRSUB(str,pos,len)"><code class="Li" id="STRSUB(str,pos,len)">STRSUB(str,pos,len)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">STRSUB</b>(<var class="Fa" title="Fa">str</var>,
|
||||||
|
<var class="Fa" title="Fa">pos</var>,
|
||||||
|
<var class="Fa" title="Fa">len</var>)</td>
|
||||||
<td class="It-column">Returns a substring from str starting at pos (first
|
<td class="It-column">Returns a substring from str starting at pos (first
|
||||||
character is position 1) and with len characters.</td>
|
character is position 1) and with len characters.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#STRUPR(str)"><code class="Li" id="STRUPR(str)">STRUPR(str)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">STRUPR</b>(<var class="Fa" title="Fa">str</var>)</td>
|
||||||
<td class="It-column">Converts all characters in str to capitals and returns
|
<td class="It-column">Converts all characters in str to capitals and returns
|
||||||
the new string.</td>
|
the new string.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#STRLWR(str)"><code class="Li" id="STRLWR(str)">STRLWR(str)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">STRLWR</b>(<var class="Fa" title="Fa">str</var>)</td>
|
||||||
<td class="It-column">Converts all characters in str to lower case and
|
<td class="It-column">Converts all characters in str to lower case and
|
||||||
returns the new string.</td>
|
returns the new string.</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -1340,38 +1395,40 @@ CHARMAP "A", 128
|
|||||||
There are a few other functions that do various useful things:
|
There are a few other functions that do various useful things:
|
||||||
<table class="Bl-column">
|
<table class="Bl-column">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 15.00ex;"/>
|
<col style="min-width: 9.00ex;"/>
|
||||||
<col style="min-width: 10.00ex;"/>
|
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Name</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Name</b></td>
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column"></td>
|
|
||||||
<td class="It-column"><b class="Sy" title="Sy">Operation</b></td>
|
<td class="It-column"><b class="Sy" title="Sy">Operation</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#BANK(@/str/lbl)"><code class="Li" id="BANK(@/str/lbl)">BANK(@/str/lbl)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">BANK</b>(<var class="Fa" title="Fa">arg</var>)</td>
|
||||||
<td class="It-column">Returns a bank number. If the argument is the symbol
|
<td class="It-column">Returns a bank number. If
|
||||||
<b class="Ic" title="Ic">@,</b> this function returns the bank of the
|
<var class="Ar" title="Ar">arg</var> is the symbol
|
||||||
current section. If the argument is a string, it returns the bank of the
|
<b class="Ic" title="Ic">@</b>, this function returns the bank of the
|
||||||
section that has that name. If the argument is a label, it returns the
|
current section. If <var class="Ar" title="Ar">arg</var> is a string, it
|
||||||
bank number the label is in. For labels, as the linker has to resolve
|
returns the bank of the section that has that name. If
|
||||||
this, it can't be used when the expression has to be constant.</td>
|
<var class="Ar" title="Ar">arg</var> is a label, it returns the bank
|
||||||
|
number the label is in. For labels, as the linker has to resolve this, it
|
||||||
|
can't be used when the expression has to be constant.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#DEF(label)"><code class="Li" id="DEF(label)">DEF(label)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">DEF</b>(<var class="Fa" title="Fa">label</var>)</td>
|
||||||
<td class="It-column">Returns TRUE if label has been defined.</td>
|
<td class="It-column">Returns TRUE if <var class="Ar" title="Ar">label</var>
|
||||||
|
has been defined.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#HIGH(r16/cnst/lbl)"><code class="Li" id="HIGH(r16/cnst/lbl)">HIGH(r16/cnst/lbl)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">HIGH</b>(<var class="Fa" title="Fa">arg</var>)</td>
|
||||||
<td class="It-column">Returns the top 8 bits of the operand if it is a label
|
<td class="It-column">Returns the top 8 bits of the operand if
|
||||||
or constant, or the top 8-bit register if it is a 16-bit register.</td>
|
<var class="Ar" title="Ar">arg</var> is a label or constant, or the top
|
||||||
|
8-bit register if it is a 16-bit register.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="It-column">
|
<tr class="It-column">
|
||||||
<td class="It-column"><a class="selflink" href="#LOW(r16/cnst/lbl)"><code class="Li" id="LOW(r16/cnst/lbl)">LOW(r16/cnst/lbl)</code></a></td>
|
<td class="It-column"><b class="Fn" title="Fn">LOW</b>(<var class="Fa" title="Fa">arg</var>)</td>
|
||||||
<td class="It-column">Returns the bottom 8 bits of the operand if it is a
|
<td class="It-column">Returns the bottom 8 bits of the operand if
|
||||||
label or constant, or the bottom 8-bit register if it is a 16-bit register
|
<var class="Ar" title="Ar">arg</var> is a label or constant, or the bottom
|
||||||
(AF isn't a valid register for this function).</td>
|
8-bit register if it is a 16-bit register (AF isn't a valid register for
|
||||||
|
this function).</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h1 class="Sh" title="Sh" id="MISCELLANEOUS"><a class="selflink" href="#MISCELLANEOUS">MISCELLANEOUS</a></h1>
|
<h1 class="Sh" title="Sh" id="MISCELLANEOUS"><a class="selflink" href="#MISCELLANEOUS">MISCELLANEOUS</a></h1>
|
||||||
@@ -1404,180 +1461,6 @@ The options that OPT can modify are currently: <b class="Sy" title="Sy">b</b>,
|
|||||||
want to destroy the options set by the program that included your file. The
|
want to destroy the options set by the program that included your file. The
|
||||||
stacks number of entries is limited only by the amount of memory in your
|
stacks number of entries is limited only by the amount of memory in your
|
||||||
machine.
|
machine.
|
||||||
<h1 class="Sh" title="Sh" id="ALPHABETICAL_LIST_OF_KEYWORDS"><a class="selflink" href="#ALPHABETICAL_LIST_OF_KEYWORDS">ALPHABETICAL
|
|
||||||
LIST OF KEYWORDS</a></h1>
|
|
||||||
<dl class="Bl-inset Bl-compact">
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#@">@</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__DATE__">__DATE__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__FILE__">__FILE__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__ISO_8601_LOCAL__">__ISO_8601_LOCAL__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__ISO_8601_UTC__">__ISO_8601_UTC__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__LINE__">__LINE__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__TIME__">__TIME__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__RGBDS_MAJOR__">__RGBDS_MAJOR__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__RGBDS_MINOR__">__RGBDS_MINOR__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__RGBDS_PATCH__">__RGBDS_PATCH__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__UTC_YEAR__">__UTC_YEAR__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__UTC_MONTH__">__UTC_MONTH__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__UTC_DAY__">__UTC_DAY__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__UTC_HOUR__">__UTC_HOUR__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__UTC_MINUTE__">__UTC_MINUTE__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#__UTC_SECOND__">__UTC_SECOND__</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#_NARG">_NARG</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#_PI">_PI</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#_RS">_RS</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ACOS">ACOS</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ASIN">ASIN</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ATAN">ATAN</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ATAN2">ATAN2</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#BANK">BANK</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#CHARMAP">CHARMAP</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#COS">COS</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#DB">DB</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#DEF">DEF</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#DIV">DIV</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#DL">DL</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#DS">DS</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#DW">DW</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ELIF">ELIF</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ELSE">ELSE</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ENDC">ENDC</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ENDM">ENDM</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ENDR">ENDR</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#EQU">EQU</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#EQUS">EQUS</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#EXPORT">EXPORT</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#FAIL">FAIL</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#GLOBAL">GLOBAL</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#HIGH">HIGH</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#HRAM">HRAM</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#IF">IF</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#INCBIN">INCBIN</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#INCLUDE">INCLUDE</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#LOW">LOW</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#MACRO">MACRO</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#MUL">MUL</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#OPT">OPT</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#POPO">POPO</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#POPS">POPS</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTF">PRINTF</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTI">PRINTI</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTT">PRINTT</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTV">PRINTV</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PURGE">PURGE</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PUSHO">PUSHO</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PUSHS">PUSHS</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#REPT">REPT</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#RB">RB</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#RL">RL</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ROM0">ROM0</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#ROMX">ROMX</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#RSRESET">RSRESET</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#RSSET">RSSET</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#RW">RW</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#SECTION">SECTION</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#SET">SET</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#SHIFT">SHIFT</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#SIN">SIN</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#SRAM">SRAM</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#STRCAT">STRCAT</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#STRCMP">STRCMP</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#STRIN">STRIN</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#STRLEN">STRLEN</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#STRLWR">STRLWR</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#STRSUB">STRSUB</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#STRUPR">STRUPR</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#TAN">TAN</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#VRAM">VRAM</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#WRAM0">WRAM0</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#WRAMX">WRAMX</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#WARN">WARN</a></dt>
|
|
||||||
<dd class="It-inset"></dd>
|
|
||||||
</dl>
|
|
||||||
<h1 class="Sh" title="Sh" id="SEE_ALSO"><a class="selflink" href="#SEE_ALSO">SEE
|
<h1 class="Sh" title="Sh" id="SEE_ALSO"><a class="selflink" href="#SEE_ALSO">SEE
|
||||||
ALSO</a></h1>
|
ALSO</a></h1>
|
||||||
<a class="Xr" title="Xr">rgbasm(1)</a>, <a class="Xr" title="Xr">rgblink(1)</a>,
|
<a class="Xr" title="Xr">rgbasm(1)</a>, <a class="Xr" title="Xr">rgblink(1)</a>,
|
||||||
|
|||||||
33
include/asm/constexpr.h
Normal file
33
include/asm/constexpr.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of RGBDS.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RGBDS_ASM_CONSTEXPR_H
|
||||||
|
#define RGBDS_ASM_CONSTEXPR_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct ConstExpression {
|
||||||
|
union {
|
||||||
|
int32_t nVal;
|
||||||
|
struct sSymbol *pSym;
|
||||||
|
} u;
|
||||||
|
uint32_t isSym;
|
||||||
|
};
|
||||||
|
|
||||||
|
void constexpr_Symbol(struct ConstExpression *expr, char *tzSym);
|
||||||
|
void constexpr_Number(struct ConstExpression *expr, int32_t i);
|
||||||
|
void constexpr_UnaryOp(struct ConstExpression *expr,
|
||||||
|
int32_t op,
|
||||||
|
const struct ConstExpression *src);
|
||||||
|
void constexpr_BinaryOp(struct ConstExpression *expr,
|
||||||
|
int32_t op,
|
||||||
|
const struct ConstExpression *src1,
|
||||||
|
const struct ConstExpression *src2);
|
||||||
|
int32_t constexpr_GetConstantValue(struct ConstExpression *expr);
|
||||||
|
|
||||||
|
#endif /* RGBDS_ASM_CONSTEXPR_H */
|
||||||
@@ -42,7 +42,7 @@ void fstk_Dump(void);
|
|||||||
void fstk_AddIncludePath(char *s);
|
void fstk_AddIncludePath(char *s);
|
||||||
uint32_t fstk_RunMacro(char *s);
|
uint32_t fstk_RunMacro(char *s);
|
||||||
void fstk_RunRept(uint32_t count);
|
void fstk_RunRept(uint32_t count);
|
||||||
FILE *fstk_FindFile(char *fname);
|
FILE *fstk_FindFile(char *fname, char **incPathUsed);
|
||||||
int32_t fstk_GetLine(void);
|
int32_t fstk_GetLine(void);
|
||||||
|
|
||||||
#endif /* RGBDS_ASM_FSTACK_H */
|
#endif /* RGBDS_ASM_FSTACK_H */
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ void CreateSymbolTable(void);
|
|||||||
struct sSection *GetSectionByName(const char *name);
|
struct sSection *GetSectionByName(const char *name);
|
||||||
int32_t IsSectionNameInUse(const char *name);
|
int32_t IsSectionNameInUse(const char *name);
|
||||||
void SetLinkerscriptName(char *tzLinkerscriptFile);
|
void SetLinkerscriptName(char *tzLinkerscriptFile);
|
||||||
int32_t IsSectionSameTypeBankAndFloating(const char *name,
|
int32_t IsSectionSameTypeBankAndAttrs(const char *name,
|
||||||
enum eSectionType type, int32_t bank);
|
enum eSectionType type, int32_t bank,
|
||||||
|
int32_t org, int32_t align);
|
||||||
uint32_t AssignSectionAddressAndBankByName(const char *name, uint32_t address,
|
uint32_t AssignSectionAddressAndBankByName(const char *name, uint32_t address,
|
||||||
int32_t bank);
|
int32_t bank);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#define PACKAGE_VERSION_MAJOR (0)
|
#define PACKAGE_VERSION_MAJOR (0)
|
||||||
#define PACKAGE_VERSION_MINOR (3)
|
#define PACKAGE_VERSION_MINOR (3)
|
||||||
#define PACKAGE_VERSION_PATCH (7)
|
#define PACKAGE_VERSION_PATCH (8)
|
||||||
|
|
||||||
const char *get_package_version_string(void);
|
const char *get_package_version_string(void);
|
||||||
|
|
||||||
|
|||||||
303
src/asm/asmy.y
303
src/asm/asmy.y
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "asm/asm.h"
|
#include "asm/asm.h"
|
||||||
#include "asm/charmap.h"
|
#include "asm/charmap.h"
|
||||||
|
#include "asm/constexpr.h"
|
||||||
#include "asm/fstack.h"
|
#include "asm/fstack.h"
|
||||||
#include "asm/lexer.h"
|
#include "asm/lexer.h"
|
||||||
#include "asm/main.h"
|
#include "asm/main.h"
|
||||||
@@ -106,18 +107,6 @@ size_t symvaluetostring(char *dest, size_t maxLength, char *sym)
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t str2int(char *s)
|
|
||||||
{
|
|
||||||
uint32_t r = 0;
|
|
||||||
|
|
||||||
while (*s) {
|
|
||||||
r <<= 8;
|
|
||||||
r |= (uint8_t)(*s++);
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t str2int2(char *s, int32_t length)
|
static uint32_t str2int2(char *s, int32_t length)
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
@@ -450,10 +439,11 @@ static void updateUnion(void)
|
|||||||
char tzString[MAXSTRLEN + 1];
|
char tzString[MAXSTRLEN + 1];
|
||||||
struct Expression sVal;
|
struct Expression sVal;
|
||||||
int32_t nConstValue;
|
int32_t nConstValue;
|
||||||
|
struct ConstExpression sConstExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
%type <sVal> relocconst
|
%type <sVal> relocconst
|
||||||
%type <nConstValue> const
|
%type <sConstExpr> const
|
||||||
%type <nConstValue> uconst
|
%type <nConstValue> uconst
|
||||||
%type <nConstValue> const_3bit
|
%type <nConstValue> const_3bit
|
||||||
%type <sVal> const_8bit
|
%type <sVal> const_8bit
|
||||||
@@ -465,38 +455,38 @@ static void updateUnion(void)
|
|||||||
%token <nConstValue> T_NUMBER
|
%token <nConstValue> T_NUMBER
|
||||||
%token <tzString> T_STRING
|
%token <tzString> T_STRING
|
||||||
|
|
||||||
%left T_OP_LOGICNOT
|
%left <nConstValue> T_OP_LOGICNOT
|
||||||
%left T_OP_LOGICOR T_OP_LOGICAND T_OP_LOGICEQU
|
%left <nConstValue> T_OP_LOGICOR T_OP_LOGICAND T_OP_LOGICEQU
|
||||||
%left T_OP_LOGICGT T_OP_LOGICLT T_OP_LOGICGE T_OP_LOGICLE T_OP_LOGICNE
|
%left <nConstValue> T_OP_LOGICGT T_OP_LOGICLT T_OP_LOGICGE T_OP_LOGICLE T_OP_LOGICNE
|
||||||
%left T_OP_ADD T_OP_SUB
|
%left <nConstValue> T_OP_ADD T_OP_SUB
|
||||||
%left T_OP_OR T_OP_XOR T_OP_AND
|
%left <nConstValue> T_OP_OR T_OP_XOR T_OP_AND
|
||||||
%left T_OP_SHL T_OP_SHR
|
%left <nConstValue> T_OP_SHL T_OP_SHR
|
||||||
%left T_OP_MUL T_OP_DIV T_OP_MOD
|
%left <nConstValue> T_OP_MUL T_OP_DIV T_OP_MOD
|
||||||
%left T_OP_NOT
|
%left <nConstValue> T_OP_NOT
|
||||||
%left T_OP_DEF
|
%left <nConstValue> T_OP_DEF
|
||||||
%left T_OP_BANK T_OP_ALIGN
|
%left <nConstValue> T_OP_BANK T_OP_ALIGN
|
||||||
%left T_OP_SIN
|
%left <nConstValue> T_OP_SIN
|
||||||
%left T_OP_COS
|
%left <nConstValue> T_OP_COS
|
||||||
%left T_OP_TAN
|
%left <nConstValue> T_OP_TAN
|
||||||
%left T_OP_ASIN
|
%left <nConstValue> T_OP_ASIN
|
||||||
%left T_OP_ACOS
|
%left <nConstValue> T_OP_ACOS
|
||||||
%left T_OP_ATAN
|
%left <nConstValue> T_OP_ATAN
|
||||||
%left T_OP_ATAN2
|
%left <nConstValue> T_OP_ATAN2
|
||||||
%left T_OP_FDIV
|
%left <nConstValue> T_OP_FDIV
|
||||||
%left T_OP_FMUL
|
%left <nConstValue> T_OP_FMUL
|
||||||
%left T_OP_ROUND
|
%left <nConstValue> T_OP_ROUND
|
||||||
%left T_OP_CEIL
|
%left <nConstValue> T_OP_CEIL
|
||||||
%left T_OP_FLOOR
|
%left <nConstValue> T_OP_FLOOR
|
||||||
|
|
||||||
%token T_OP_HIGH T_OP_LOW
|
%token <nConstValue> T_OP_HIGH T_OP_LOW
|
||||||
|
|
||||||
%left T_OP_STRCMP
|
%left <nConstValue> T_OP_STRCMP
|
||||||
%left T_OP_STRIN
|
%left <nConstValue> T_OP_STRIN
|
||||||
%left T_OP_STRSUB
|
%left <nConstValue> T_OP_STRSUB
|
||||||
%left T_OP_STRLEN
|
%left <nConstValue> T_OP_STRLEN
|
||||||
%left T_OP_STRCAT
|
%left <nConstValue> T_OP_STRCAT
|
||||||
%left T_OP_STRUPR
|
%left <nConstValue> T_OP_STRUPR
|
||||||
%left T_OP_STRLWR
|
%left <nConstValue> T_OP_STRLWR
|
||||||
|
|
||||||
%left NEG /* negation -- unary minus */
|
%left NEG /* negation -- unary minus */
|
||||||
|
|
||||||
@@ -895,13 +885,13 @@ global_list_entry : T_ID
|
|||||||
|
|
||||||
equ : T_LABEL T_POP_EQU const
|
equ : T_LABEL T_POP_EQU const
|
||||||
{
|
{
|
||||||
sym_AddEqu($1, $3);
|
sym_AddEqu($1, constexpr_GetConstantValue(&$3));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
set : T_LABEL T_POP_SET const
|
set : T_LABEL T_POP_SET const
|
||||||
{
|
{
|
||||||
sym_AddSet($1, $3);
|
sym_AddSet($1, constexpr_GetConstantValue(&$3));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -930,7 +920,7 @@ charmap : T_POP_CHARMAP string comma string
|
|||||||
}
|
}
|
||||||
| T_POP_CHARMAP string comma const
|
| T_POP_CHARMAP string comma const
|
||||||
{
|
{
|
||||||
if (charmap_Add($2, $4 & 0xFF) == -1) {
|
if (charmap_Add($2, constexpr_GetConstantValue(&$4) & 0xFF) == -1) {
|
||||||
fprintf(stderr, "Error parsing charmap. Either you've added too many (%i), or the input character length is too long (%i)' : %s\n", MAXCHARMAPS, CHARMAPLENGTH, strerror(errno));
|
fprintf(stderr, "Error parsing charmap. Either you've added too many (%i), or the input character length is too long (%i)' : %s\n", MAXCHARMAPS, CHARMAPLENGTH, strerror(errno));
|
||||||
yyerror("Error parsing charmap.");
|
yyerror("Error parsing charmap.");
|
||||||
}
|
}
|
||||||
@@ -947,28 +937,28 @@ printt : T_POP_PRINTT string
|
|||||||
printv : T_POP_PRINTV const
|
printv : T_POP_PRINTV const
|
||||||
{
|
{
|
||||||
if (nPass == 1)
|
if (nPass == 1)
|
||||||
printf("$%X", $2);
|
printf("$%X", constexpr_GetConstantValue(&$2));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
printi : T_POP_PRINTI const
|
printi : T_POP_PRINTI const
|
||||||
{
|
{
|
||||||
if (nPass == 1)
|
if (nPass == 1)
|
||||||
printf("%d", $2);
|
printf("%d", constexpr_GetConstantValue(&$2));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
printf : T_POP_PRINTF const
|
printf : T_POP_PRINTF const
|
||||||
{
|
{
|
||||||
if (nPass == 1)
|
if (nPass == 1)
|
||||||
math_Print($2);
|
math_Print(constexpr_GetConstantValue(&$2));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
if : T_POP_IF const
|
if : T_POP_IF const
|
||||||
{
|
{
|
||||||
nIFDepth++;
|
nIFDepth++;
|
||||||
if (!$2) {
|
if (!constexpr_GetConstantValue(&$2)) {
|
||||||
/*
|
/*
|
||||||
* Continue parsing after ELSE, or at ELIF or
|
* Continue parsing after ELSE, or at ELIF or
|
||||||
* ENDC keyword.
|
* ENDC keyword.
|
||||||
@@ -1000,7 +990,7 @@ elif : T_POP_ELIF const
|
|||||||
*/
|
*/
|
||||||
skipElif = true;
|
skipElif = true;
|
||||||
|
|
||||||
if (!$2) {
|
if (!constexpr_GetConstantValue(&$2)) {
|
||||||
/*
|
/*
|
||||||
* Continue parsing after ELSE, or at
|
* Continue parsing after ELSE, or at
|
||||||
* ELIF or ENDC keyword.
|
* ELIF or ENDC keyword.
|
||||||
@@ -1032,10 +1022,11 @@ endc : T_POP_ENDC
|
|||||||
|
|
||||||
const_3bit : const
|
const_3bit : const
|
||||||
{
|
{
|
||||||
if (($1 < 0) || ($1 > 7))
|
int32_t value = constexpr_GetConstantValue(&$1);
|
||||||
|
if ((value < 0) || (value > 7))
|
||||||
yyerror("Immediate value must be 3-bit");
|
yyerror("Immediate value must be 3-bit");
|
||||||
else
|
else
|
||||||
$$ = $1 & 0x7;
|
$$ = value & 0x7;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -1202,18 +1193,60 @@ relocconst : T_ID
|
|||||||
rpn_Number(&$$, sym_isConstDefined($4));
|
rpn_Number(&$$, sym_isConstDefined($4));
|
||||||
oDontExpandStrings = false;
|
oDontExpandStrings = false;
|
||||||
}
|
}
|
||||||
| T_OP_ROUND '(' const ')' { rpn_Number(&$$, math_Round($3)); }
|
| T_OP_ROUND '(' const ')'
|
||||||
| T_OP_CEIL '(' const ')' { rpn_Number(&$$, math_Ceil($3)); }
|
{
|
||||||
| T_OP_FLOOR '(' const ')' { rpn_Number(&$$, math_Floor($3)); }
|
rpn_Number(&$$, math_Round(constexpr_GetConstantValue(&$3)));
|
||||||
| T_OP_FDIV '(' const comma const ')' { rpn_Number(&$$, math_Div($3, $5)); }
|
}
|
||||||
| T_OP_FMUL '(' const comma const ')' { rpn_Number(&$$, math_Mul($3, $5)); }
|
| T_OP_CEIL '(' const ')'
|
||||||
| T_OP_SIN '(' const ')' { rpn_Number(&$$, math_Sin($3)); }
|
{
|
||||||
| T_OP_COS '(' const ')' { rpn_Number(&$$, math_Cos($3)); }
|
rpn_Number(&$$, math_Ceil(constexpr_GetConstantValue(&$3)));
|
||||||
| T_OP_TAN '(' const ')' { rpn_Number(&$$, math_Tan($3)); }
|
}
|
||||||
| T_OP_ASIN '(' const ')' { rpn_Number(&$$, math_ASin($3)); }
|
| T_OP_FLOOR '(' const ')'
|
||||||
| T_OP_ACOS '(' const ')' { rpn_Number(&$$, math_ACos($3)); }
|
{
|
||||||
| T_OP_ATAN '(' const ')' { rpn_Number(&$$, math_ATan($3)); }
|
rpn_Number(&$$, math_Floor(constexpr_GetConstantValue(&$3)));
|
||||||
| T_OP_ATAN2 '(' const comma const ')' { rpn_Number(&$$, math_ATan2($3, $5)); }
|
}
|
||||||
|
| T_OP_FDIV '(' const comma const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$,
|
||||||
|
math_Div(constexpr_GetConstantValue(&$3),
|
||||||
|
constexpr_GetConstantValue(&$5)));
|
||||||
|
}
|
||||||
|
| T_OP_FMUL '(' const comma const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$,
|
||||||
|
math_Mul(constexpr_GetConstantValue(&$3),
|
||||||
|
constexpr_GetConstantValue(&$5)));
|
||||||
|
}
|
||||||
|
| T_OP_SIN '(' const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$, math_Sin(constexpr_GetConstantValue(&$3)));
|
||||||
|
}
|
||||||
|
| T_OP_COS '(' const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$, math_Cos(constexpr_GetConstantValue(&$3)));
|
||||||
|
}
|
||||||
|
| T_OP_TAN '(' const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$, math_Tan(constexpr_GetConstantValue(&$3)));
|
||||||
|
}
|
||||||
|
| T_OP_ASIN '(' const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$, math_ASin(constexpr_GetConstantValue(&$3)));
|
||||||
|
}
|
||||||
|
| T_OP_ACOS '(' const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$, math_ACos(constexpr_GetConstantValue(&$3)));
|
||||||
|
}
|
||||||
|
| T_OP_ATAN '(' const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$, math_ATan(constexpr_GetConstantValue(&$3)));
|
||||||
|
}
|
||||||
|
| T_OP_ATAN2 '(' const comma const ')'
|
||||||
|
{
|
||||||
|
rpn_Number(&$$,
|
||||||
|
math_ATan2(constexpr_GetConstantValue(&$3),
|
||||||
|
constexpr_GetConstantValue(&$5)));
|
||||||
|
}
|
||||||
| T_OP_STRCMP '(' string comma string ')'
|
| T_OP_STRCMP '(' string comma string ')'
|
||||||
{
|
{
|
||||||
rpn_Number(&$$, strcmp($3, $5));
|
rpn_Number(&$$, strcmp($3, $5));
|
||||||
@@ -1233,107 +1266,79 @@ relocconst : T_ID
|
|||||||
|
|
||||||
uconst : const
|
uconst : const
|
||||||
{
|
{
|
||||||
if ($1 < 0)
|
int32_t value = constexpr_GetConstantValue(&$1);
|
||||||
fatalerror("Constant mustn't be negative: %d", $1);
|
if (value < 0)
|
||||||
$$ = $1;
|
fatalerror("Constant mustn't be negative: %d", value);
|
||||||
|
$$ = value;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
const : T_ID { $$ = sym_GetConstantValue($1); }
|
const : T_ID { constexpr_Symbol(&$$, $1); }
|
||||||
| T_NUMBER { $$ = $1; }
|
| T_NUMBER { constexpr_Number(&$$, $1); }
|
||||||
| T_OP_HIGH '(' const ')' { $$ = ($3 >> 8) & 0xFF; }
|
| T_OP_HIGH '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_LOW '(' const ')' { $$ = $3 & 0xFF; }
|
| T_OP_LOW '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| string { $$ = str2int($1); }
|
| string
|
||||||
| T_OP_LOGICNOT const %prec NEG { $$ = !$2; }
|
|
||||||
| const T_OP_LOGICOR const { $$ = $1 || $3; }
|
|
||||||
| const T_OP_LOGICAND const { $$ = $1 && $3; }
|
|
||||||
| const T_OP_LOGICEQU const { $$ = $1 == $3; }
|
|
||||||
| const T_OP_LOGICGT const { $$ = $1 > $3; }
|
|
||||||
| const T_OP_LOGICLT const { $$ = $1 < $3; }
|
|
||||||
| const T_OP_LOGICGE const { $$ = $1 >= $3; }
|
|
||||||
| const T_OP_LOGICLE const { $$ = $1 <= $3; }
|
|
||||||
| const T_OP_LOGICNE const { $$ = $1 != $3; }
|
|
||||||
| const T_OP_ADD const { $$ = $1 + $3; }
|
|
||||||
| const T_OP_SUB const { $$ = $1 - $3; }
|
|
||||||
| T_ID T_OP_SUB T_ID
|
|
||||||
{
|
{
|
||||||
if (sym_IsRelocDiffDefined($1, $3) == 0)
|
char *s = $1;
|
||||||
fatalerror("'%s - %s' not defined.", $1, $3);
|
int32_t length = charmap_Convert(&s);
|
||||||
$$ = sym_GetDefinedValue($1) - sym_GetDefinedValue($3);
|
constexpr_Number(&$$, str2int2(s, length));
|
||||||
|
free(s);
|
||||||
}
|
}
|
||||||
| const T_OP_XOR const { $$ = $1 ^ $3; }
|
| T_OP_LOGICNOT const %prec NEG { constexpr_UnaryOp(&$$, $1, &$2); }
|
||||||
| const T_OP_OR const { $$ = $1 | $3; }
|
| const T_OP_LOGICOR const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| const T_OP_AND const { $$ = $1 & $3; }
|
| const T_OP_LOGICAND const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| const T_OP_SHL const
|
| const T_OP_LOGICEQU const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
{
|
| const T_OP_LOGICGT const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
if ($1 < 0)
|
| const T_OP_LOGICLT const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
warning("Left shift of negative value: %d", $1);
|
| const T_OP_LOGICGE const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
|
| const T_OP_LOGICLE const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
if ($3 < 0)
|
| const T_OP_LOGICNE const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
fatalerror("Shift by negative value: %d", $3);
|
| const T_OP_ADD const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
else if ($3 >= 32)
|
| const T_OP_SUB const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
fatalerror("Shift by too big value: %d", $3);
|
| const T_OP_XOR const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
|
| const T_OP_OR const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
$$ = $1 << $3;
|
| const T_OP_AND const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
}
|
| const T_OP_SHL const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| const T_OP_SHR const
|
| const T_OP_SHR const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
{
|
| const T_OP_MUL const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
if ($3 < 0)
|
| const T_OP_DIV const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
fatalerror("Shift by negative value: %d", $3);
|
| const T_OP_MOD const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
else if ($3 >= 32)
|
| T_OP_ADD const %prec NEG { constexpr_UnaryOp(&$$, $1, &$2); }
|
||||||
fatalerror("Shift by too big value: %d", $3);
|
| T_OP_SUB const %prec NEG { constexpr_UnaryOp(&$$, $1, &$2); }
|
||||||
|
| T_OP_NOT const %prec NEG { constexpr_UnaryOp(&$$, $1, &$2); }
|
||||||
$$ = $1 >> $3;
|
| T_OP_ROUND '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
}
|
| T_OP_CEIL '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| const T_OP_MUL const { $$ = $1 * $3; }
|
| T_OP_FLOOR '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| const T_OP_DIV const
|
| T_OP_FDIV '(' const comma const ')' { constexpr_BinaryOp(&$$, $1, &$3, &$5); }
|
||||||
{
|
| T_OP_FMUL '(' const comma const ')' { constexpr_BinaryOp(&$$, $1, &$3, &$5); }
|
||||||
if ($3 == 0)
|
| T_OP_SIN '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
fatalerror("Division by zero");
|
| T_OP_COS '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
$$ = $1 / $3;
|
| T_OP_TAN '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
}
|
| T_OP_ASIN '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| const T_OP_MOD const
|
| T_OP_ACOS '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
{
|
| T_OP_ATAN '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
if ($3 == 0)
|
| T_OP_ATAN2 '(' const comma const ')' { constexpr_BinaryOp(&$$, $1, &$3, &$5); }
|
||||||
fatalerror("Division by zero");
|
|
||||||
$$ = $1 % $3;
|
|
||||||
}
|
|
||||||
| T_OP_ADD const %prec NEG { $$ = +$2; }
|
|
||||||
| T_OP_SUB const %prec NEG { $$ = -$2; }
|
|
||||||
| T_OP_NOT const %prec NEG { $$ = ~$2; }
|
|
||||||
| T_OP_ROUND '(' const ')' { $$ = math_Round($3); }
|
|
||||||
| T_OP_CEIL '(' const ')' { $$ = math_Ceil($3); }
|
|
||||||
| T_OP_FLOOR '(' const ')' { $$ = math_Floor($3); }
|
|
||||||
| T_OP_FDIV '(' const comma const ')' { $$ = math_Div($3,$5); }
|
|
||||||
| T_OP_FMUL '(' const comma const ')' { $$ = math_Mul($3,$5); }
|
|
||||||
| T_OP_SIN '(' const ')' { $$ = math_Sin($3); }
|
|
||||||
| T_OP_COS '(' const ')' { $$ = math_Cos($3); }
|
|
||||||
| T_OP_TAN '(' const ')' { $$ = math_Tan($3); }
|
|
||||||
| T_OP_ASIN '(' const ')' { $$ = math_ASin($3); }
|
|
||||||
| T_OP_ACOS '(' const ')' { $$ = math_ACos($3); }
|
|
||||||
| T_OP_ATAN '(' const ')' { $$ = math_ATan($3); }
|
|
||||||
| T_OP_ATAN2 '(' const comma const ')' { $$ = math_ATan2($3,$5); }
|
|
||||||
| T_OP_DEF {
|
| T_OP_DEF {
|
||||||
oDontExpandStrings = true;
|
oDontExpandStrings = true;
|
||||||
} '(' T_ID ')'
|
} '(' T_ID ')'
|
||||||
{
|
{
|
||||||
$$ = sym_isConstDefined($4);
|
constexpr_Number(&$$, sym_isConstDefined($4));
|
||||||
oDontExpandStrings = false;
|
oDontExpandStrings = false;
|
||||||
}
|
}
|
||||||
| T_OP_STRCMP '(' string comma string ')'
|
| T_OP_STRCMP '(' string comma string ')'
|
||||||
{
|
{
|
||||||
$$ = strcmp($3, $5);
|
constexpr_Number(&$$, strcmp($3, $5));
|
||||||
}
|
}
|
||||||
| T_OP_STRIN '(' string comma string ')'
|
| T_OP_STRIN '(' string comma string ')'
|
||||||
{
|
{
|
||||||
char *p = strstr($3, $5);
|
char *p = strstr($3, $5);
|
||||||
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
$$ = p - $3 + 1;
|
constexpr_Number(&$$, p - $3 + 1);
|
||||||
else
|
else
|
||||||
$$ = 0;
|
constexpr_Number(&$$, 0);
|
||||||
}
|
}
|
||||||
| T_OP_STRLEN '(' string ')' { $$ = strlen($3); }
|
| T_OP_STRLEN '(' string ')' { constexpr_Number(&$$, strlen($3)); }
|
||||||
| '(' const ')' { $$ = $2; }
|
| '(' const ')' { $$ = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -1707,6 +1712,14 @@ z80_ldio : T_Z80_LDIO T_MODE_A comma op_mem_ind
|
|||||||
$2.nVal &= 0xFF;
|
$2.nVal &= 0xFF;
|
||||||
out_RelByte(&$2);
|
out_RelByte(&$2);
|
||||||
}
|
}
|
||||||
|
| T_Z80_LDIO T_MODE_A comma T_MODE_C_IND
|
||||||
|
{
|
||||||
|
out_AbsByte(0xF2);
|
||||||
|
}
|
||||||
|
| T_Z80_LDIO T_MODE_C_IND comma T_MODE_A
|
||||||
|
{
|
||||||
|
out_AbsByte(0xE2);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
z80_ld : z80_ld_mem
|
z80_ld : z80_ld_mem
|
||||||
|
|||||||
@@ -32,12 +32,10 @@ int32_t readUTF8Char(char *dest, char *src)
|
|||||||
|
|
||||||
dest[i] = src[i];
|
dest[i] = src[i];
|
||||||
|
|
||||||
i++;
|
|
||||||
if (state == 0) {
|
if (state == 0) {
|
||||||
dest[i] = '\0';
|
dest[++i] = '\0';
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
dest[i] = src[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
231
src/asm/constexpr.c
Normal file
231
src/asm/constexpr.c
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of RGBDS.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "asm/asm.h"
|
||||||
|
#include "asm/constexpr.h"
|
||||||
|
#include "asm/lexer.h"
|
||||||
|
#include "asm/main.h"
|
||||||
|
#include "asm/mymath.h"
|
||||||
|
#include "asm/rpn.h"
|
||||||
|
#include "asm/symbol.h"
|
||||||
|
|
||||||
|
#include "asmy.h"
|
||||||
|
|
||||||
|
void constexpr_Symbol(struct ConstExpression *expr, char *tzSym)
|
||||||
|
{
|
||||||
|
if (!sym_isConstant(tzSym)) {
|
||||||
|
struct sSymbol *pSym = sym_FindSymbol(tzSym);
|
||||||
|
|
||||||
|
if (pSym != NULL) {
|
||||||
|
expr->u.pSym = pSym;
|
||||||
|
expr->isSym = 1;
|
||||||
|
} else {
|
||||||
|
fatalerror("'%s' not defined", tzSym);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
constexpr_Number(expr, sym_GetConstantValue(tzSym));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void constexpr_Number(struct ConstExpression *expr, int32_t i)
|
||||||
|
{
|
||||||
|
expr->u.nVal = i;
|
||||||
|
expr->isSym = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void constexpr_UnaryOp(struct ConstExpression *expr,
|
||||||
|
int32_t op,
|
||||||
|
const struct ConstExpression *src)
|
||||||
|
{
|
||||||
|
if (src->isSym)
|
||||||
|
fatalerror("Non-constant operand in constant expression");
|
||||||
|
|
||||||
|
int32_t value = src->u.nVal;
|
||||||
|
int32_t result = 0;
|
||||||
|
|
||||||
|
switch (op) {
|
||||||
|
case T_OP_HIGH:
|
||||||
|
result = (value >> 8) & 0xFF;
|
||||||
|
break;
|
||||||
|
case T_OP_LOW:
|
||||||
|
result = value & 0xFF;
|
||||||
|
break;
|
||||||
|
case T_OP_LOGICNOT:
|
||||||
|
result = !value;
|
||||||
|
break;
|
||||||
|
case T_OP_ADD:
|
||||||
|
result = value;
|
||||||
|
break;
|
||||||
|
case T_OP_SUB:
|
||||||
|
result = -value;
|
||||||
|
break;
|
||||||
|
case T_OP_NOT:
|
||||||
|
result = ~value;
|
||||||
|
break;
|
||||||
|
case T_OP_ROUND:
|
||||||
|
result = math_Round(value);
|
||||||
|
break;
|
||||||
|
case T_OP_CEIL:
|
||||||
|
result = math_Ceil(value);
|
||||||
|
break;
|
||||||
|
case T_OP_FLOOR:
|
||||||
|
result = math_Floor(value);
|
||||||
|
break;
|
||||||
|
case T_OP_SIN:
|
||||||
|
result = math_Sin(value);
|
||||||
|
break;
|
||||||
|
case T_OP_COS:
|
||||||
|
result = math_Cos(value);
|
||||||
|
break;
|
||||||
|
case T_OP_TAN:
|
||||||
|
result = math_Tan(value);
|
||||||
|
break;
|
||||||
|
case T_OP_ASIN:
|
||||||
|
result = math_ASin(value);
|
||||||
|
break;
|
||||||
|
case T_OP_ACOS:
|
||||||
|
result = math_ACos(value);
|
||||||
|
break;
|
||||||
|
case T_OP_ATAN:
|
||||||
|
result = math_ATan(value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatalerror("Unknown unary op");
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr_Number(expr, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void constexpr_BinaryOp(struct ConstExpression *expr,
|
||||||
|
int32_t op,
|
||||||
|
const struct ConstExpression *src1,
|
||||||
|
const struct ConstExpression *src2)
|
||||||
|
{
|
||||||
|
int32_t value1;
|
||||||
|
int32_t value2;
|
||||||
|
int32_t result = 0;
|
||||||
|
|
||||||
|
if (op == T_OP_SUB && src1->isSym && src2->isSym) {
|
||||||
|
char *symName1 = src1->u.pSym->tzName;
|
||||||
|
char *symName2 = src2->u.pSym->tzName;
|
||||||
|
|
||||||
|
if (!sym_IsRelocDiffDefined(symName1, symName2))
|
||||||
|
fatalerror("'%s - %s' not defined", symName1, symName2);
|
||||||
|
value1 = sym_GetDefinedValue(symName1);
|
||||||
|
value2 = sym_GetDefinedValue(symName2);
|
||||||
|
result = value1 - value2;
|
||||||
|
} else if (src1->isSym || src2->isSym) {
|
||||||
|
fatalerror("Non-constant operand in constant expression");
|
||||||
|
} else {
|
||||||
|
value1 = src1->u.nVal;
|
||||||
|
value2 = src2->u.nVal;
|
||||||
|
|
||||||
|
switch (op) {
|
||||||
|
case T_OP_LOGICOR:
|
||||||
|
result = value1 || value2;
|
||||||
|
break;
|
||||||
|
case T_OP_LOGICAND:
|
||||||
|
result = value1 && value2;
|
||||||
|
break;
|
||||||
|
case T_OP_LOGICEQU:
|
||||||
|
result = value1 == value2;
|
||||||
|
break;
|
||||||
|
case T_OP_LOGICGT:
|
||||||
|
result = value1 > value2;
|
||||||
|
break;
|
||||||
|
case T_OP_LOGICLT:
|
||||||
|
result = value1 < value2;
|
||||||
|
break;
|
||||||
|
case T_OP_LOGICGE:
|
||||||
|
result = value1 >= value2;
|
||||||
|
break;
|
||||||
|
case T_OP_LOGICLE:
|
||||||
|
result = value1 <= value2;
|
||||||
|
break;
|
||||||
|
case T_OP_LOGICNE:
|
||||||
|
result = value1 != value2;
|
||||||
|
break;
|
||||||
|
case T_OP_ADD:
|
||||||
|
result = value1 + value2;
|
||||||
|
break;
|
||||||
|
case T_OP_SUB:
|
||||||
|
result = value1 - value2;
|
||||||
|
break;
|
||||||
|
case T_OP_XOR:
|
||||||
|
result = value1 ^ value2;
|
||||||
|
break;
|
||||||
|
case T_OP_OR:
|
||||||
|
result = value1 | value2;
|
||||||
|
break;
|
||||||
|
case T_OP_AND:
|
||||||
|
result = value1 & value2;
|
||||||
|
break;
|
||||||
|
case T_OP_SHL:
|
||||||
|
if (value1 < 0)
|
||||||
|
warning("Left shift of negative value: %d",
|
||||||
|
value1);
|
||||||
|
|
||||||
|
if (value2 < 0)
|
||||||
|
fatalerror("Shift by negative value: %d",
|
||||||
|
value2);
|
||||||
|
else if (value2 >= 32)
|
||||||
|
fatalerror("Shift by too big value: %d",
|
||||||
|
value2);
|
||||||
|
|
||||||
|
result = value1 << value2;
|
||||||
|
break;
|
||||||
|
case T_OP_SHR:
|
||||||
|
if (value2 < 0)
|
||||||
|
fatalerror("Shift by negative value: %d",
|
||||||
|
value2);
|
||||||
|
else if (value2 >= 32)
|
||||||
|
fatalerror("Shift by too big value: %d",
|
||||||
|
value2);
|
||||||
|
|
||||||
|
result = value1 >> value2;
|
||||||
|
break;
|
||||||
|
case T_OP_MUL:
|
||||||
|
result = value1 * value2;
|
||||||
|
break;
|
||||||
|
case T_OP_DIV:
|
||||||
|
if (value2 == 0)
|
||||||
|
fatalerror("Division by zero");
|
||||||
|
result = value1 / value2;
|
||||||
|
break;
|
||||||
|
case T_OP_MOD:
|
||||||
|
if (value2 == 0)
|
||||||
|
fatalerror("Division by zero");
|
||||||
|
result = value1 % value2;
|
||||||
|
break;
|
||||||
|
case T_OP_FDIV:
|
||||||
|
result = math_Div(value1, value2);
|
||||||
|
break;
|
||||||
|
case T_OP_FMUL:
|
||||||
|
result = math_Mul(value1, value2);
|
||||||
|
break;
|
||||||
|
case T_OP_ATAN2:
|
||||||
|
result = math_ATan2(value1, value2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatalerror("Unknown binary op");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr_Number(expr, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t constexpr_GetConstantValue(struct ConstExpression *expr)
|
||||||
|
{
|
||||||
|
if (expr->isSym)
|
||||||
|
fatalerror("Non-constant expression");
|
||||||
|
return expr->u.nVal;
|
||||||
|
}
|
||||||
@@ -185,7 +185,6 @@ int32_t fstk_GetLine(void)
|
|||||||
pLastFile = pFileStack;
|
pLastFile = pFileStack;
|
||||||
|
|
||||||
if (pLastFile != NULL) {
|
if (pLastFile != NULL) {
|
||||||
ppLastFile = &pFileStack;
|
|
||||||
while (pLastFile->pNext) {
|
while (pLastFile->pNext) {
|
||||||
ppLastFile = &(pLastFile->pNext);
|
ppLastFile = &(pLastFile->pNext);
|
||||||
pLastFile = *ppLastFile;
|
pLastFile = *ppLastFile;
|
||||||
@@ -235,7 +234,7 @@ void fstk_AddIncludePath(char *s)
|
|||||||
fatalerror("Include path too long '%s'", s);
|
fatalerror("Include path too long '%s'", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fstk_FindFile(char *fname)
|
FILE *fstk_FindFile(char *fname, char **incPathUsed)
|
||||||
{
|
{
|
||||||
char path[_MAX_PATH];
|
char path[_MAX_PATH];
|
||||||
int32_t i;
|
int32_t i;
|
||||||
@@ -276,6 +275,8 @@ FILE *fstk_FindFile(char *fname)
|
|||||||
fprintf(dependfile, "%s: %s\n", tzObjectname,
|
fprintf(dependfile, "%s: %s\n", tzObjectname,
|
||||||
path);
|
path);
|
||||||
}
|
}
|
||||||
|
if (incPathUsed)
|
||||||
|
*incPathUsed = IncludePaths[i];
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,7 +290,8 @@ FILE *fstk_FindFile(char *fname)
|
|||||||
*/
|
*/
|
||||||
void fstk_RunInclude(char *tzFileName)
|
void fstk_RunInclude(char *tzFileName)
|
||||||
{
|
{
|
||||||
FILE *f = fstk_FindFile(tzFileName);
|
char *incPathUsed = "";
|
||||||
|
FILE *f = fstk_FindFile(tzFileName, &incPathUsed);
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
err(1, "Unable to open included file '%s'", tzFileName);
|
err(1, "Unable to open included file '%s'", tzFileName);
|
||||||
@@ -297,7 +299,8 @@ void fstk_RunInclude(char *tzFileName)
|
|||||||
pushcontext();
|
pushcontext();
|
||||||
nLineNo = 1;
|
nLineNo = 1;
|
||||||
nCurrentStatus = STAT_isInclude;
|
nCurrentStatus = STAT_isInclude;
|
||||||
strcpy(tzCurrentFileName, tzFileName);
|
snprintf(tzCurrentFileName, sizeof(tzCurrentFileName), "%s%s",
|
||||||
|
incPathUsed, tzFileName);
|
||||||
pCurrentFile = f;
|
pCurrentFile = f;
|
||||||
CurrentFlexHandle = yy_create_buffer(pCurrentFile);
|
CurrentFlexHandle = yy_create_buffer(pCurrentFile);
|
||||||
yy_switch_to_buffer(CurrentFlexHandle);
|
yy_switch_to_buffer(CurrentFlexHandle);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "asm/asm.h"
|
#include "asm/asm.h"
|
||||||
|
#include "asm/constexpr.h"
|
||||||
#include "asm/lexer.h"
|
#include "asm/lexer.h"
|
||||||
#include "asm/main.h"
|
#include "asm/main.h"
|
||||||
#include "asm/rpn.h"
|
#include "asm/rpn.h"
|
||||||
@@ -100,7 +101,13 @@ static int32_t ascii2bin(char *s)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radix == 4) {
|
if (*s == '\0') {
|
||||||
|
/*
|
||||||
|
* There are no digits after the radix prefix
|
||||||
|
* (or the string is empty, which shouldn't happen).
|
||||||
|
*/
|
||||||
|
yyerror("Invalid integer constant");
|
||||||
|
} else if (radix == 4) {
|
||||||
int32_t c;
|
int32_t c;
|
||||||
|
|
||||||
while (*s != '\0') {
|
while (*s != '\0') {
|
||||||
@@ -312,6 +319,7 @@ const struct sLexInitString lexer_strings[] = {
|
|||||||
{"sp", T_MODE_SP},
|
{"sp", T_MODE_SP},
|
||||||
{"[c]", T_MODE_C_IND},
|
{"[c]", T_MODE_C_IND},
|
||||||
{"[$ff00+c]", T_MODE_C_IND},
|
{"[$ff00+c]", T_MODE_C_IND},
|
||||||
|
{"[$ff00 + c]", T_MODE_C_IND},
|
||||||
|
|
||||||
{"a", T_TOKEN_A},
|
{"a", T_TOKEN_A},
|
||||||
{"b", T_TOKEN_B},
|
{"b", T_TOKEN_B},
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -14,6 +15,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "asm/asm.h"
|
#include "asm/asm.h"
|
||||||
|
#include "asm/constexpr.h"
|
||||||
#include "asm/fstack.h"
|
#include "asm/fstack.h"
|
||||||
#include "asm/lexer.h"
|
#include "asm/lexer.h"
|
||||||
#include "asm/main.h"
|
#include "asm/main.h"
|
||||||
@@ -110,6 +112,21 @@ void yy_delete_buffer(YY_BUFFER_STATE buf)
|
|||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Maintains the following invariants:
|
||||||
|
* 1. nBufferSize < capacity
|
||||||
|
* 2. The buffer is terminated with 0
|
||||||
|
* 3. nBufferSize is the size without the terminator
|
||||||
|
*/
|
||||||
|
static void yy_buffer_append(YY_BUFFER_STATE buf, uint32_t capacity, char c)
|
||||||
|
{
|
||||||
|
assert(buf->pBuffer[buf->nBufferSize] == 0);
|
||||||
|
assert(buf->nBufferSize + 1 < capacity);
|
||||||
|
|
||||||
|
buf->pBuffer[buf->nBufferSize++] = c;
|
||||||
|
buf->pBuffer[buf->nBufferSize] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
YY_BUFFER_STATE yy_scan_bytes(char *mem, uint32_t size)
|
YY_BUFFER_STATE yy_scan_bytes(char *mem, uint32_t size)
|
||||||
{
|
{
|
||||||
YY_BUFFER_STATE pBuffer = malloc(sizeof(struct yy_buffer_state));
|
YY_BUFFER_STATE pBuffer = malloc(sizeof(struct yy_buffer_state));
|
||||||
@@ -145,7 +162,10 @@ YY_BUFFER_STATE yy_create_buffer(FILE *f)
|
|||||||
size = ftell(f);
|
size = ftell(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
pBuffer->pBufferRealStart = malloc(size + 2 + SAFETYMARGIN);
|
/* Give extra room for 2 newlines and terminator */
|
||||||
|
uint32_t capacity = size + 3;
|
||||||
|
|
||||||
|
pBuffer->pBufferRealStart = malloc(capacity + SAFETYMARGIN);
|
||||||
|
|
||||||
if (pBuffer->pBufferRealStart == NULL)
|
if (pBuffer->pBufferRealStart == NULL)
|
||||||
fatalerror("%s: Out of memory for buffer!", __func__);
|
fatalerror("%s: Out of memory for buffer!", __func__);
|
||||||
@@ -155,9 +175,8 @@ YY_BUFFER_STATE yy_create_buffer(FILE *f)
|
|||||||
|
|
||||||
size = fread(pBuffer->pBuffer, sizeof(uint8_t), size, f);
|
size = fread(pBuffer->pBuffer, sizeof(uint8_t), size, f);
|
||||||
|
|
||||||
pBuffer->pBuffer[size] = '\n';
|
pBuffer->pBuffer[size] = 0;
|
||||||
pBuffer->pBuffer[size + 1] = 0;
|
pBuffer->nBufferSize = size;
|
||||||
pBuffer->nBufferSize = size + 1;
|
|
||||||
|
|
||||||
/* Convert all line endings to LF and spaces */
|
/* Convert all line endings to LF and spaces */
|
||||||
|
|
||||||
@@ -218,6 +237,22 @@ YY_BUFFER_STATE yy_create_buffer(FILE *f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add newline if file doesn't end with one */
|
||||||
|
if (size == 0 || pBuffer->pBuffer[size - 1] != '\n')
|
||||||
|
yy_buffer_append(pBuffer, capacity, '\n');
|
||||||
|
|
||||||
|
/* Add newline if \ will eat the last newline */
|
||||||
|
if (pBuffer->nBufferSize >= 2) {
|
||||||
|
size_t pos = pBuffer->nBufferSize - 2;
|
||||||
|
|
||||||
|
/* Skip spaces */
|
||||||
|
while (pos > 0 && pBuffer->pBuffer[pos] == ' ')
|
||||||
|
pos--;
|
||||||
|
|
||||||
|
if (pBuffer->pBuffer[pos] == '\\')
|
||||||
|
yy_buffer_append(pBuffer, capacity, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
pBuffer->oAtLineStart = 1;
|
pBuffer->oAtLineStart = 1;
|
||||||
return pBuffer;
|
return pBuffer;
|
||||||
}
|
}
|
||||||
@@ -735,6 +770,7 @@ scanagain:
|
|||||||
|
|
||||||
/* Longest match was a keyword or operator. */
|
/* Longest match was a keyword or operator. */
|
||||||
pLexBuffer += pLongestFixed->nNameLength;
|
pLexBuffer += pLongestFixed->nNameLength;
|
||||||
|
yylval.nConstValue = pLongestFixed->nToken;
|
||||||
return pLongestFixed->nToken;
|
return pLongestFixed->nToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -902,7 +902,7 @@ void out_BinaryFile(char *s)
|
|||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fstk_FindFile(s);
|
f = fstk_FindFile(s, NULL);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
err(1, "Unable to open incbin file '%s'", s);
|
err(1, "Unable to open incbin file '%s'", s);
|
||||||
|
|
||||||
@@ -938,7 +938,7 @@ void out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length)
|
|||||||
if (length < 0)
|
if (length < 0)
|
||||||
fatalerror("Number of bytes to read must be greater than zero");
|
fatalerror("Number of bytes to read must be greater than zero");
|
||||||
|
|
||||||
f = fstk_FindFile(s);
|
f = fstk_FindFile(s, NULL);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
err(1, "Unable to open included file '%s'", s);
|
err(1, "Unable to open included file '%s'", s);
|
||||||
|
|
||||||
|
|||||||
624
src/asm/rgbasm.5
624
src/asm/rgbasm.5
@@ -33,24 +33,28 @@ John: ld a,87 ;Weee
|
|||||||
All pseudo‐ops, mnemonics and registers (reserved keywords) are case‐insensitive
|
All pseudo‐ops, mnemonics and registers (reserved keywords) are case‐insensitive
|
||||||
and all labels are case‐sensitive.
|
and all labels are case‐sensitive.
|
||||||
.Pp
|
.Pp
|
||||||
There are two syntaxes for comments. In both cases, a comment ends at the end of
|
There are two syntaxes for comments.
|
||||||
the line. The most common one is: anything that follows a semicolon
|
In both cases, a comment ends at the end of the line.
|
||||||
\[dq]\&;\[dq] (that isn't inside a string) is a comment. There is another
|
The most common one is: anything that follows a semicolon
|
||||||
format: anything that follows a \[dq]*\[dq] that is placed right at the start of
|
.Ql \&;
|
||||||
a line is a comment. The assembler removes all comments from the code before
|
(that isn't inside a string) is a comment.
|
||||||
doing anything else.
|
There is another format: anything that follows a
|
||||||
|
.Ql *
|
||||||
|
that is placed right at the start of
|
||||||
|
a line is a comment.
|
||||||
|
The assembler removes all comments from the code before doing anything else.
|
||||||
.Pp
|
.Pp
|
||||||
Sometimes lines can be too long and it may be necessary to split them. The
|
Sometimes lines can be too long and it may be necessary to split them.
|
||||||
syntax to do so is the following one:
|
The syntax to do so is the following one:
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
DB 1, 2, 3, 4 \[rs]
|
DB 1, 2, 3, 4 \[rs]
|
||||||
5, 6, 7, 8
|
5, 6, 7, 8
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
This works anywhere in the code except inside of strings. To split strings it is
|
This works anywhere in the code except inside of strings.
|
||||||
needed to use
|
To split strings it is needed to use
|
||||||
.Sy STRCAT
|
.Fn STRCAT
|
||||||
like this:
|
like this:
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
@@ -59,162 +63,145 @@ like this:
|
|||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
.Ss Sections
|
.Ss Sections
|
||||||
|
.Ic SECTION Ar name , type
|
||||||
|
.Pp
|
||||||
|
.Ic SECTION Ar name , type , options
|
||||||
|
.Pp
|
||||||
|
.Ic SECTION Ar name , type Ns Bo Ar addr Bc
|
||||||
|
.Pp
|
||||||
|
.Ic SECTION Ar name , type Ns Bo Ar addr Bc , Ar options
|
||||||
|
.Pp
|
||||||
Before you can start writing code, you must define a section.
|
Before you can start writing code, you must define a section.
|
||||||
This tells the assembler what kind of information follows and, if it is code,
|
This tells the assembler what kind of information follows and, if it is code,
|
||||||
where to put it.
|
where to put it.
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Ar name
|
||||||
SECTION \[dq]CoolStuff\[dq],ROMX
|
is a string enclosed in double quotes and can be a new name or the name of an
|
||||||
.Ed
|
existing section.
|
||||||
.Pp
|
All sections assembled at the same time that have the same name and type are
|
||||||
This switches to the section called "CoolStuff" (or creates it if it doesn't
|
considered to be the same section, and their code is put together in the object
|
||||||
already exist) and it defines it as a code section.
|
file generated by the assembler.
|
||||||
All sections assembled at the same time that have the same name, type, etc, are
|
|
||||||
considered to be the same one, and their code is put together in the object file
|
|
||||||
generated by the assembler.
|
|
||||||
All other sections must have a unique name, even in different source files, or
|
All other sections must have a unique name, even in different source files, or
|
||||||
the linker will treat it as an error.
|
the linker will treat it as an error.
|
||||||
.Pp
|
.Pp
|
||||||
Possible section types are as follows:
|
Possible section
|
||||||
|
.Ar type Ns s
|
||||||
|
are as follows:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag
|
.Bl -tag
|
||||||
.It Sy ROM0
|
.It Cm ROM0
|
||||||
A ROM section.
|
A ROM section.
|
||||||
Mapped to memory at $0000–$3FFF (or $0000-$7FFF if tiny ROM mode is enabled in
|
.Ar addr
|
||||||
|
can range from $0000–$3FFF (or $0000–$7FFF if tiny ROM mode is enabled in
|
||||||
.Xr rgblink 1 ) .
|
.Xr rgblink 1 ) .
|
||||||
.It Sy ROMX
|
.It Cm ROMX
|
||||||
A banked ROM section.
|
A banked ROM section.
|
||||||
Mapped to memory at $4000–$7FFF.
|
.Ar addr
|
||||||
Valid banks range from 1 to 511.
|
can range from $4000–$7FFF.
|
||||||
|
.Ar bank
|
||||||
|
can range from 1 to 511.
|
||||||
Not available if tiny ROM mode is enabled in
|
Not available if tiny ROM mode is enabled in
|
||||||
.Xr rgblink 1 .
|
.Xr rgblink 1 .
|
||||||
.It Sy VRAM
|
.It Cm VRAM
|
||||||
A banked video RAM section.
|
A banked video RAM section.
|
||||||
Mapped to memory at $8000–$9FFF.
|
.Ar addr
|
||||||
Can only allocate memory, not fill it.
|
can range from $8000–$9FFF.
|
||||||
Valid banks are 0 and 1 but bank 1 isn't available if DMG mode is enabled in
|
.Ar bank
|
||||||
|
can be 0 or 1 but bank 1 is unavailable if DMG mode is enabled in
|
||||||
.Xr rgblink 1 .
|
.Xr rgblink 1 .
|
||||||
.It Sy SRAM
|
Memory in this section can only be allocated with
|
||||||
|
.Sy DS ,
|
||||||
|
not filled with data.
|
||||||
|
.It Cm SRAM
|
||||||
A banked external (save) RAM section.
|
A banked external (save) RAM section.
|
||||||
Mapped to memory at $A000–$BFFF.
|
.Ar addr
|
||||||
Can only allocate memory, not fill it.
|
can range from $A000–$BFFF.
|
||||||
Valid banks range from 0 to 15.
|
.Ar bank
|
||||||
.It Sy WRAM0
|
can range from 0 to 15.
|
||||||
|
Memory in this section can only be allocated with
|
||||||
|
.Sy DS ,
|
||||||
|
not filled with data.
|
||||||
|
.It Cm WRAM0
|
||||||
A general-purpose RAM section.
|
A general-purpose RAM section.
|
||||||
Mapped to memory at $C000–$CFFF, or $C000-$DFFF if DMG mode is enabled in
|
.Ar addr
|
||||||
|
can range from $C000–$CFFF, or $C000–$DFFF if DMG mode is enabled in
|
||||||
.Xr rgblink 1 .
|
.Xr rgblink 1 .
|
||||||
Can only allocate memory, not fill it.
|
Memory in this section can only be allocated with
|
||||||
.It Sy WRAMX
|
.Sy DS ,
|
||||||
|
not filled with data.
|
||||||
|
.It Cm WRAMX
|
||||||
A banked general-purpose RAM section.
|
A banked general-purpose RAM section.
|
||||||
Mapped to memory at $D000–$DFFF.
|
.Ar addr
|
||||||
Can only allocate memory, not fill it.
|
can range from $D000–$DFFF.
|
||||||
Valid banks range from 1 to 7.
|
.Ar bank
|
||||||
|
can range from 1 to 7.
|
||||||
|
Memory in this section can only be allocated with
|
||||||
|
.Sy DS ,
|
||||||
|
not filled with data.
|
||||||
Not available if DMG mode is enabled in
|
Not available if DMG mode is enabled in
|
||||||
.Xr rgblink 1 .
|
.Xr rgblink 1 .
|
||||||
.It Sy OAM
|
.It Cm OAM
|
||||||
An object attributes RAM section.
|
An object attributes RAM section.
|
||||||
Mapped to memory at $FE00-$FE9F.
|
.Ar addr
|
||||||
Can only allocate memory, not fill it.
|
can range from $FE00-$FE9F.
|
||||||
.It Sy HRAM
|
Memory in this section can only be allocated with
|
||||||
|
.Sy DS ,
|
||||||
|
not filled with data.
|
||||||
|
.It Cm HRAM
|
||||||
A high RAM section.
|
A high RAM section.
|
||||||
Mapped to memory at $FF80–$FFFE.
|
.Ar addr
|
||||||
Can only allocate memory, not fill it.
|
can range from $FF80–$FFFE.
|
||||||
|
Memory in this section can only be allocated with
|
||||||
|
.Sy DS ,
|
||||||
|
not filled with data.
|
||||||
.Pp
|
.Pp
|
||||||
NOTE: If you use this method of allocating HRAM the assembler will NOT choose
|
.Sy Note :
|
||||||
the short addressing mode in the LD instructions
|
If you use this method of allocating HRAM the assembler will
|
||||||
|
.Em not
|
||||||
|
choose the short addressing mode in the LD instructions
|
||||||
.Sy LD [$FF00+n8],A
|
.Sy LD [$FF00+n8],A
|
||||||
and
|
and
|
||||||
.Sy LD A,[$FF00+n8]
|
.Sy LD A,[$FF00+n8]
|
||||||
because the actual address calculation is done by the linker.
|
because the actual address calculation is done by the linker.
|
||||||
If you find this undesirable you can use
|
If you find this undesirable you can use
|
||||||
.Ic RSSET No / Ic RB No / Ic RW
|
.Ic RSSET , RB ,
|
||||||
|
or
|
||||||
|
.Ic RW
|
||||||
instead or use the
|
instead or use the
|
||||||
.Sy LDH [$FF00+n8],A
|
.Sy LDH [$FF00+n8],A
|
||||||
and
|
and
|
||||||
.Sy LDH A,[$FF00+n8]
|
.Sy LDH A,[$FF00+n8]
|
||||||
syntax instead.
|
syntax instead.
|
||||||
This forces the assembler to emit the correct instruction and the linker to
|
This forces the assembler to emit the correct instruction and the linker to
|
||||||
check if the value is in the correct range. This optimization can be disabled
|
check if the value is in the correct range.
|
||||||
by passing the
|
This optimization can be disabled by passing the
|
||||||
.Fl L
|
.Fl L
|
||||||
flag to
|
flag to
|
||||||
.Sy rgbasm
|
|
||||||
as explained in
|
|
||||||
.Xr rgbasm 1 .
|
.Xr rgbasm 1 .
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
A section is usually defined as a floating one, but the code can restrict where
|
.Ar option Ns s are comma separated and may include:
|
||||||
the linker can place it.
|
.Bl -tag
|
||||||
|
.It Cm BANK Ns Bq Ar bank
|
||||||
|
Specify which
|
||||||
|
.Ar bank
|
||||||
|
for the linker to place the section.
|
||||||
|
.It Cm ALIGN Ns Bq Ar align
|
||||||
|
Place the section at an address whose
|
||||||
|
.Ar align
|
||||||
|
least‐significant bits are zero.
|
||||||
|
It is a syntax error to use this option with
|
||||||
|
.Ar addr .
|
||||||
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
If a section is defined with no indications, it is a floating section.
|
If
|
||||||
The linker will decide where to place it in the final binary and it has no
|
.Bq Ar addr
|
||||||
obligation to follow any specific rules.
|
is not specified, the section is considered
|
||||||
The following example defines a section that can be placed anywhere in any ROMX
|
.Dq floating ;
|
||||||
bank:
|
the linker will automatically calculate an appropriate address for the section.
|
||||||
.Pp
|
Similarly, if
|
||||||
.Bd -literal -offset indent
|
.Cm BANK Ns Bq Ar bank
|
||||||
SECTION \[dq]CoolStuff\[dq],ROMX
|
is not specified, the linker will automatically find a bank with enough space.
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
If it is needed, the following syntax can be used to fix the base address of the
|
|
||||||
section:
|
|
||||||
.Pp
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
SECTION \[dq]CoolStuff\[dq],ROMX[$4567]
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
It won't, however, fix the bank number, which is left to the linker.
|
|
||||||
If you also want to specify the bank you can do:
|
|
||||||
.Pp
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
SECTION \[dq]CoolStuff\[dq],ROMX[$4567],BANK[3]
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
And if you only want to force the section into a certain bank, and not it's
|
|
||||||
position within the bank, that's also possible:
|
|
||||||
.Pp
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
SECTION \[dq]CoolStuff\[dq],ROMX,BANK[7]
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
In addition, you can specify byte alignment for a section.
|
|
||||||
This ensures that the section starts at a memory address where the given number
|
|
||||||
of least-significant bits are 0.
|
|
||||||
This can be used along with
|
|
||||||
.Ic BANK ,
|
|
||||||
if desired.
|
|
||||||
However, if an alignment is specified, the base address must be left unassigned.
|
|
||||||
This can be useful when using DMA to copy data or when it is needed to align the
|
|
||||||
start of an array to 256 bytes to optimize the code that accesses it.
|
|
||||||
.Pp
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
SECTION \[dq]OAM Data\[dq],WRAM0,ALIGN[8] ; align to 256 bytes
|
|
||||||
|
|
||||||
SECTION \[dq]VRAM Data\[dq],ROMX,BANK[2],ALIGN[4] ; align to 16 bytes
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
HINT: If you think this is a lot of typing for doing a simple
|
|
||||||
.Ic ORG
|
|
||||||
type thing you can quite easily write an intelligent macro (called
|
|
||||||
.Ic ORG
|
|
||||||
for example) that uses
|
|
||||||
.Ic \@
|
|
||||||
for the section name and determines
|
|
||||||
correct section type etc as arguments for
|
|
||||||
.Ic SECTION .
|
|
||||||
.Pp
|
|
||||||
.Ic POPS
|
|
||||||
and
|
|
||||||
.Ic PUSHS
|
|
||||||
provide the interface to the section stack.
|
|
||||||
.Ic PUSHS
|
|
||||||
will push the current section context on the section stack.
|
|
||||||
.Ic POPS
|
|
||||||
can then later be used to restore it.
|
|
||||||
Useful for defining sections in included files when you don't want to destroy
|
|
||||||
the section context for the program that included your file.
|
|
||||||
The number of entries in the stack is limited only by the amount of memory in
|
|
||||||
your machine.
|
|
||||||
.Pp
|
.Pp
|
||||||
Sections can also be placed by using a linkerscript file.
|
Sections can also be placed by using a linkerscript file.
|
||||||
The format is described in
|
The format is described in
|
||||||
@@ -224,6 +211,75 @@ specified in the script.
|
|||||||
This is useful if the sections can't be placed at an address manually because
|
This is useful if the sections can't be placed at an address manually because
|
||||||
the size may change, but they have to be together.
|
the size may change, but they have to be together.
|
||||||
.Pp
|
.Pp
|
||||||
|
Section examples:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
SECTION "CoolStuff",ROMX
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
This switches to the section called
|
||||||
|
.Dq CoolStuff
|
||||||
|
(or creates it if it doesn't already exist) and defines it as a code section.
|
||||||
|
.Pp
|
||||||
|
The following example defines a section that can be placed anywhere in any ROMX
|
||||||
|
bank:
|
||||||
|
.Pp
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
SECTION "CoolStuff",ROMX
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
If it is needed, the the base address of the section can be specified:
|
||||||
|
.Pp
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
SECTION "CoolStuff",ROMX[$4567]
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
An example with a fixed bank:
|
||||||
|
.Pp
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
SECTION "CoolStuff",ROMX[$4567],BANK[3]
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
And if you only want to force the section into a certain bank, and not it's
|
||||||
|
position within the bank, that's also possible:
|
||||||
|
.Pp
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
SECTION "CoolStuff",ROMX,BANK[7]
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
Alignment examples:
|
||||||
|
one use could be when using DMA to copy data or when it is needed to align the
|
||||||
|
start of an array to 256 bytes to optimize the code that accesses it.
|
||||||
|
.Pp
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
SECTION "OAM Data",WRAM0,ALIGN[8] ; align to 256 bytes
|
||||||
|
|
||||||
|
SECTION "VRAM Data",ROMX,BANK[2],ALIGN[4] ; align to 16 bytes
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
.Sy Hint :
|
||||||
|
If you think this is a lot of typing for doing a simple
|
||||||
|
.Dq org
|
||||||
|
type thing you can quite easily write an intelligent macro (called
|
||||||
|
.Ic ORG
|
||||||
|
for example) that uses
|
||||||
|
.Ic @
|
||||||
|
for the section name and determines
|
||||||
|
correct section type etc as arguments for
|
||||||
|
.Ic SECTION .
|
||||||
|
.Ss Section Stack
|
||||||
|
.Ic POPS
|
||||||
|
and
|
||||||
|
.Ic PUSHS
|
||||||
|
provide the interface to the section stack.
|
||||||
|
.Pp
|
||||||
|
.Ic PUSHS
|
||||||
|
will push the current section context on the section stack.
|
||||||
|
.Ic POPS
|
||||||
|
can then later be used to restore it.
|
||||||
|
Useful for defining sections in included files when you don't want to destroy
|
||||||
|
the section context for the program that included your file.
|
||||||
|
The number of entries in the stack is limited only by the amount of memory in
|
||||||
|
your machine.
|
||||||
.Sh SYMBOLS
|
.Sh SYMBOLS
|
||||||
.Pp
|
.Pp
|
||||||
.Ss Symbols
|
.Ss Symbols
|
||||||
@@ -241,7 +297,9 @@ assembling.
|
|||||||
Define a structure easily.
|
Define a structure easily.
|
||||||
.It Sy String equate Pq Sy EQUS
|
.It Sy String equate Pq Sy EQUS
|
||||||
Give a frequently used string a name.
|
Give a frequently used string a name.
|
||||||
Can also be used as a mini-macro, like #define in C.
|
Can also be used as a mini-macro, like
|
||||||
|
.Fd #define
|
||||||
|
in C.
|
||||||
.It Sy MACRO
|
.It Sy MACRO
|
||||||
A block of code or pseudo instructions that you invoke like any other mnemonic.
|
A block of code or pseudo instructions that you invoke like any other mnemonic.
|
||||||
You can give them arguments too.
|
You can give them arguments too.
|
||||||
@@ -341,9 +399,9 @@ str_SIZEOF = 259
|
|||||||
.Pp
|
.Pp
|
||||||
There are four commands in the RS group of commands:
|
There are four commands in the RS group of commands:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -column ".Sy String" ".Sy String"
|
.Bl -column "RSSET constexpr"
|
||||||
.It Sy Command Ta Ta Ta Sy Meaning
|
.It Sy Command Ta Sy Meaning
|
||||||
.It Ic RSRESET Ta Ta Resets the _RS counter to zero.
|
.It Ic RSRESET Ta Resets the _RS counter to zero.
|
||||||
.It Ic RSSET Ar constexpr Ta Sets the
|
.It Ic RSSET Ar constexpr Ta Sets the
|
||||||
.Ic _RS No counter to Ar constexpr .
|
.Ic _RS No counter to Ar constexpr .
|
||||||
.It Ic RB Ar constexpr Ta Sets the preceding symbol to
|
.It Ic RB Ar constexpr Ta Sets the preceding symbol to
|
||||||
@@ -364,13 +422,14 @@ They don't change their value during the link process.
|
|||||||
EQUS is used to define string-symbols.
|
EQUS is used to define string-symbols.
|
||||||
Wherever the assembler meets a string symbol its name is replaced with its
|
Wherever the assembler meets a string symbol its name is replaced with its
|
||||||
value.
|
value.
|
||||||
If you are familiar with C you can think of it as the same as #define.
|
If you are familiar with C you can think of it as the same as
|
||||||
|
.Fd #define .
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
COUNTREG EQUS "[hl+]"
|
COUNTREG EQUS "[hl+]"
|
||||||
ld a,COUNTREG
|
ld a,COUNTREG
|
||||||
|
|
||||||
PLAYER_NAME EQUS \[dq]\[rs]\[dq]John\[rs]\[dq]\[dq]
|
PLAYER_NAME EQUS "\[rs]"John\[rs]""
|
||||||
db PLAYER_NAME
|
db PLAYER_NAME
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
@@ -381,13 +440,13 @@ This will be interpreted as:
|
|||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
ld a,[hl+]
|
ld a,[hl+]
|
||||||
db \[dq]John\[dq]
|
db "John"
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
String-symbols can also be used to define small one-line macros:
|
String-symbols can also be used to define small one-line macros:
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
PUSHA EQUS \[dq]push af\[rs]npush bc\[rs]npush de\[rs]npush hl\[rs]n\[dq]
|
PUSHA EQUS "push af\[rs]npush bc\[rs]npush de\[rs]npush hl\[rs]n"
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Note that a colon (:) following the label-name is not allowed.
|
Note that a colon (:) following the label-name is not allowed.
|
||||||
@@ -448,17 +507,17 @@ LoopyMacro: MACRO
|
|||||||
This is fine.
|
This is fine.
|
||||||
That is, if you only use the macro once per scope.
|
That is, if you only use the macro once per scope.
|
||||||
To get around this problem there is a special label string equate called
|
To get around this problem there is a special label string equate called
|
||||||
.Ic \[rs]\@
|
.Ic \[rs]@
|
||||||
that you can append to your labels and it will then expand to a unique string.
|
that you can append to your labels and it will then expand to a unique string.
|
||||||
.Pp
|
.Pp
|
||||||
.Ic \[rs]\@
|
.Ic \[rs]@
|
||||||
also works in REPT-blocks should you have any loops there.
|
also works in REPT-blocks should you have any loops there.
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
LoopyMacro: MACRO
|
LoopyMacro: MACRO
|
||||||
xor a,a
|
xor a,a
|
||||||
\&.loop\[rs]\@ ld [hl+],a
|
\&.loop\[rs]@ ld [hl+],a
|
||||||
dec c
|
dec c
|
||||||
jr nz,.loop\[rs]\@
|
jr nz,.loop\[rs]@
|
||||||
ENDM
|
ENDM
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
@@ -491,9 +550,9 @@ LoopyMacro: MACRO
|
|||||||
ld hl,\[rs]1
|
ld hl,\[rs]1
|
||||||
ld c,\[rs]2
|
ld c,\[rs]2
|
||||||
xor a,a
|
xor a,a
|
||||||
\&.loop\[rs]\@ ld [hl+],a
|
\&.loop\[rs]@ ld [hl+],a
|
||||||
dec c
|
dec c
|
||||||
jr nz,.loop\[rs]\@
|
jr nz,.loop\[rs]@
|
||||||
ENDM
|
ENDM
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
@@ -520,26 +579,27 @@ For instance, if you pass 1 + 2 as the first argument and then do
|
|||||||
you will get the value 5 on screen and not 6 as you might have expected.
|
you will get the value 5 on screen and not 6 as you might have expected.
|
||||||
.Pp
|
.Pp
|
||||||
In reality, up to 256 arguments can be passed to a macro, but you can only use
|
In reality, up to 256 arguments can be passed to a macro, but you can only use
|
||||||
the first 9 like this. If you want to use the rest, you need to use the keyword
|
the first 9 like this.
|
||||||
|
If you want to use the rest, you need to use the keyword
|
||||||
.Ic SHIFT .
|
.Ic SHIFT .
|
||||||
.Pp
|
.Pp
|
||||||
Line continuations work as usual inside macros or lists of arguments of macros.
|
Line continuations work as usual inside macros or lists of arguments of macros.
|
||||||
Strings, however, are a bit trickier. The following example shows how to use
|
Strings, however, are a bit trickier.
|
||||||
strings as arguments for a macro:
|
The following example shows how to use strings as arguments for a macro:
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
PrintMacro : MACRO
|
PrintMacro : MACRO
|
||||||
PRINTT \[rs]1
|
PRINTT \[rs]1
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
PrintMacro STRCAT(\[rs]\[dq]Hello\[rs]\[dq]\[rs], \[rs]
|
PrintMacro STRCAT(\[rs]"Hello\[rs]"\[rs], \[rs]
|
||||||
\[rs]\[dq] world\[rs]\[rs]n\[rs]\[dq])
|
\[rs]" world\[rs]\[rs]n\[rs]")
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
.Ic SHIFT
|
.Ic SHIFT
|
||||||
is a special command only available in macros.
|
is a special command only available in macros.
|
||||||
Very useful in REPT-blocks.
|
Very useful in REPT-blocks.
|
||||||
It will "shift" the arguments by one "to the left".
|
It will shift the arguments by one to the left.
|
||||||
.Ic \[rs]1
|
.Ic \[rs]1
|
||||||
will get the value of
|
will get the value of
|
||||||
.Ic \[rs]2 ,
|
.Ic \[rs]2 ,
|
||||||
@@ -582,8 +642,8 @@ In fact, it's probably not even safe to purge anything other than string symbols
|
|||||||
and macros.
|
and macros.
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
Kamikaze EQUS \[dq]I don't want to live anymore\[dq]
|
Kamikaze EQUS "I don't want to live anymore"
|
||||||
AOLer EQUS \[dq]Me too\[dq]
|
AOLer EQUS "Me too"
|
||||||
PURGE Kamikaze, AOLer
|
PURGE Kamikaze, AOLer
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
@@ -593,27 +653,27 @@ command WILL NOT BE EXPANDED as the ONLY exception to this rule.
|
|||||||
.Ss Predeclared Symbols
|
.Ss Predeclared Symbols
|
||||||
The following symbols are defined by the assembler:
|
The following symbols are defined by the assembler:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -column -offset indent ".Sy String" ".Sy String" ".Sy String"
|
.Bl -column -offset indent "EQUS" "__ISO_8601_LOCAL__"
|
||||||
.It Sy Type Ta Sy Name Ta Ta Sy Contents
|
.It Sy Type Ta Sy Name Ta Sy Contents
|
||||||
.It Ic EQU Ta Ic \@ Ta Ta PC value
|
.It Ic EQU Ta Ic @ Ta PC value
|
||||||
.It Ic EQU Ta Ic _PI Ta Ta Fixed point \[*p]
|
.It Ic EQU Ta Ic _PI Ta Fixed point \[*p]
|
||||||
.It Ic SET Ta Ic _RS Ta Ta _RS Counter
|
.It Ic SET Ta Ic _RS Ta _RS Counter
|
||||||
.It Ic EQU Ta Ic _NARG Ta Ta Number of arguments passed to macro
|
.It Ic EQU Ta Ic _NARG Ta Number of arguments passed to macro
|
||||||
.It Ic EQU Ta Ic __LINE__ Ta Ta The current line number
|
.It Ic EQU Ta Ic __LINE__ Ta The current line number
|
||||||
.It Ic EQUS Ta Ic __FILE__ Ta Ta The current filename
|
.It Ic EQUS Ta Ic __FILE__ Ta The current filename
|
||||||
.It Ic EQUS Ta Ic __DATE__ Ta Ta Today's date
|
.It Ic EQUS Ta Ic __DATE__ Ta Today's date
|
||||||
.It Ic EQUS Ta Ic __TIME__ Ta Ta The current time
|
.It Ic EQUS Ta Ic __TIME__ Ta The current time
|
||||||
.It Ic EQUS Ta Ic __ISO_8601_LOCAL__ Ta ISO 8601 timestamp (local)
|
.It Ic EQUS Ta Ic __ISO_8601_LOCAL__ Ta ISO 8601 timestamp (local)
|
||||||
.It Ic EQUS Ta Ic __ISO_8601_UTC__ Ta ISO 8601 timestamp (UTC)
|
.It Ic EQUS Ta Ic __ISO_8601_UTC__ Ta ISO 8601 timestamp (UTC)
|
||||||
.It Ic EQU Ta Ic __UTC_YEAR__ Ta Ta Today's year
|
.It Ic EQU Ta Ic __UTC_YEAR__ Ta Today's year
|
||||||
.It Ic EQU Ta Ic __UTC_MONTH__ Ta Ta Today's month number, 1-12
|
.It Ic EQU Ta Ic __UTC_MONTH__ Ta Today's month number, 1-12
|
||||||
.It Ic EQU Ta Ic __UTC_DAY__ Ta Ta Today's day of the month, 1-31
|
.It Ic EQU Ta Ic __UTC_DAY__ Ta Today's day of the month, 1-31
|
||||||
.It Ic EQU Ta Ic __UTC_HOUR__ Ta Ta Current hour, 0-23
|
.It Ic EQU Ta Ic __UTC_HOUR__ Ta Current hour, 0-23
|
||||||
.It Ic EQU Ta Ic __UTC_MINUTE__ Ta Ta Current minute, 0-59
|
.It Ic EQU Ta Ic __UTC_MINUTE__ Ta Current minute, 0-59
|
||||||
.It Ic EQU Ta Ic __UTC_SECOND__ Ta Ta Current second, 0-59
|
.It Ic EQU Ta Ic __UTC_SECOND__ Ta Current second, 0-59
|
||||||
.It Ic EQU Ta Ic __RGBDS_MAJOR__ Ta Ta Major version number of RGBDS.
|
.It Ic EQU Ta Ic __RGBDS_MAJOR__ Ta Major version number of RGBDS.
|
||||||
.It Ic EQU Ta Ic __RGBDS_MINOR__ Ta Ta Minor version number of RGBDS.
|
.It Ic EQU Ta Ic __RGBDS_MINOR__ Ta Minor version number of RGBDS.
|
||||||
.It Ic EQU Ta Ic __RGBDS_PATCH__ Ta Ta Patch version number of RGBDS.
|
.It Ic EQU Ta Ic __RGBDS_PATCH__ Ta Patch version number of RGBDS.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
.Sh DEFINING DATA
|
.Sh DEFINING DATA
|
||||||
@@ -623,7 +683,7 @@ defines a list of bytes that will be stored in the final image.
|
|||||||
Ideal for tables and text (which is not zero-terminated).
|
Ideal for tables and text (which is not zero-terminated).
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
DB 1,2,3,4,\[dq]This is a string\[dq]
|
DB 1,2,3,4,"This is a string"
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Alternatively, you can use
|
Alternatively, you can use
|
||||||
@@ -681,9 +741,9 @@ If the file isn't found in the current directory, the include-path list passed
|
|||||||
to the linker on the command line will be searched.
|
to the linker on the command line will be searched.
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
INCBIN \[dq]titlepic.bin\[dq]
|
INCBIN "titlepic.bin"
|
||||||
INCBIN \[dq]sprites/hero.bin\[dq]\ ; UNIX
|
INCBIN "sprites/hero.bin"\ ; UNIX
|
||||||
INCBIN \[dq]sprites\[rs]\[rs]hero.bin\[dq]\ ; Windows
|
INCBIN "sprites\[rs]\[rs]hero.bin"\ ; Windows
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
You can also include only part of a file with
|
You can also include only part of a file with
|
||||||
@@ -691,7 +751,7 @@ You can also include only part of a file with
|
|||||||
The example below includes 256 bytes from data.bin starting from byte 78.
|
The example below includes 256 bytes from data.bin starting from byte 78.
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
INCBIN \[dq]data.bin\[dq],78,256
|
INCBIN "data.bin",78,256
|
||||||
.Ed
|
.Ed
|
||||||
.Ss Unions
|
.Ss Unions
|
||||||
Unions allow multiple memory allocations to share the same space in memory,
|
Unions allow multiple memory allocations to share the same space in memory,
|
||||||
@@ -736,7 +796,7 @@ Useful for debugging macros or wherever you may feel the need to tell yourself
|
|||||||
some important information.
|
some important information.
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
PRINTT \[dq]I'm the greatest programmer in the whole wide world\[rs]n\[dq]
|
PRINTT "I'm the greatest programmer in the whole wide world\[rs]n"
|
||||||
PRINTI (2 + 3) / 5
|
PRINTI (2 + 3) / 5
|
||||||
PRINTV $FF00 + $F0
|
PRINTV $FF00 + $F0
|
||||||
PRINTF MUL(3.14, 3987.0)
|
PRINTF MUL(3.14, 3987.0)
|
||||||
@@ -747,7 +807,8 @@ PRINTF MUL(3.14, 3987.0)
|
|||||||
prints out a string.
|
prints out a string.
|
||||||
.It Ic PRINTV
|
.It Ic PRINTV
|
||||||
prints out an integer value in hexadecimal or, as in the example, the result of
|
prints out an integer value in hexadecimal or, as in the example, the result of
|
||||||
a calculation. Unsurprisingly, you can also print out a constant symbols value.
|
a calculation.
|
||||||
|
Unsurprisingly, you can also print out a constant symbols value.
|
||||||
.It Ic PRINTI
|
.It Ic PRINTI
|
||||||
prints out a signed integer value.
|
prints out a signed integer value.
|
||||||
.It Ic PRINTF
|
.It Ic PRINTF
|
||||||
@@ -791,7 +852,7 @@ ANGLE SET ANGLE+256.0
|
|||||||
.Ic REPT
|
.Ic REPT
|
||||||
is also very useful in recursive macros and, as in macros, you can also use the
|
is also very useful in recursive macros and, as in macros, you can also use the
|
||||||
special label operator
|
special label operator
|
||||||
.Ic \[rs]\@ .
|
.Ic \[rs]@ .
|
||||||
REPT-blocks can be nested.
|
REPT-blocks can be nested.
|
||||||
.Ss Aborting the assembly process
|
.Ss Aborting the assembly process
|
||||||
.Ic FAIL
|
.Ic FAIL
|
||||||
@@ -821,7 +882,7 @@ You may nest
|
|||||||
calls infinitely (or until you run out of memory, whichever comes first).
|
calls infinitely (or until you run out of memory, whichever comes first).
|
||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
INCLUDE \[dq]irq.inc\[dq]
|
INCLUDE "irq.inc"
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
.Ss Conditional assembling
|
.Ss Conditional assembling
|
||||||
@@ -836,11 +897,11 @@ This is a powerful feature commonly used in macros.
|
|||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
IF NUM < 0
|
IF NUM < 0
|
||||||
PRINTT \[dq]NUM < 0\[rs]n\[dq]
|
PRINTT "NUM < 0\[rs]n"
|
||||||
ELIF NUM == 0
|
ELIF NUM == 0
|
||||||
PRINTT \[dq]NUM == 0\[rs]n\[dq]
|
PRINTT "NUM == 0\[rs]n"
|
||||||
ELSE
|
ELSE
|
||||||
PRINTT \[dq]NUM > 0\[rs]n\[dq]
|
PRINTT "NUM > 0\[rs]n"
|
||||||
ENDC
|
ENDC
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
@@ -879,17 +940,18 @@ There are a number of numeric formats.
|
|||||||
.Pp
|
.Pp
|
||||||
.Bl -dash -compact
|
.Bl -dash -compact
|
||||||
.It
|
.It
|
||||||
Hexadecimal: \(Do0123456789ABCDEF. Case-insensitive
|
Hexadecimal: $0123456789ABCDEF.
|
||||||
|
Case-insensitive
|
||||||
.It
|
.It
|
||||||
Decimal: 0123456789
|
Decimal: 0123456789
|
||||||
.It
|
.It
|
||||||
Octal: \*(Am01234567
|
Octal: &01234567
|
||||||
.It
|
.It
|
||||||
Binary: %01
|
Binary: %01
|
||||||
.It
|
.It
|
||||||
Fixedpoint (16.16): 01234.56789
|
Fixedpoint (16.16): 01234.56789
|
||||||
.It
|
.It
|
||||||
Character constant: \[dq]ABYZ\[dq]
|
Character constant: "ABYZ"
|
||||||
.It
|
.It
|
||||||
Gameboy graphics: \`0123
|
Gameboy graphics: \`0123
|
||||||
.El
|
.El
|
||||||
@@ -911,19 +973,19 @@ calculations between numbers.
|
|||||||
A great number of operators you can use in expressions are available (listed in
|
A great number of operators you can use in expressions are available (listed in
|
||||||
order of precedence):
|
order of precedence):
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -column -offset indent ".Sy String" ".Sy String"
|
.Bl -column -offset indent "Operator"
|
||||||
.It Sy Operator Ta Sy Meaning
|
.It Sy Operator Ta Sy Meaning
|
||||||
.It Li ( ) Ta Precedence override
|
.It Li \&( \&) Ta Precedence override
|
||||||
.It Li FUNC() Ta Function call
|
.It Li FUNC() Ta Function call
|
||||||
.It Li ~ + - Ta Unary not/plus/minus
|
.It Li ~ + - Ta Unary not/plus/minus
|
||||||
.It Li * / % Ta Multiply/divide/modulo
|
.It Li * / % Ta Multiply/divide/modulo
|
||||||
.It Li << >> Ta Shift left/right
|
.It Li << >> Ta Shift left/right
|
||||||
.It Li & | ^ Ta Binary and/or/xor
|
.It Li & \&| ^ Ta Binary and/or/xor
|
||||||
.It Li + - Ta Add/subtract
|
.It Li + - Ta Add/subtract
|
||||||
.It Li != == <= Ta Boolean comparison
|
.It Li != == <= Ta Boolean comparison
|
||||||
.It Li >= < > Ta Boolean comparison (Same precedence as the others)
|
.It Li >= < > Ta Boolean comparison (Same precedence as the others)
|
||||||
.It Li && || Ta Boolean and/or
|
.It Li && || Ta Boolean and/or
|
||||||
.It Li ! Ta Unary Boolean not
|
.It Li \&! Ta Unary Boolean not
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The result of the boolean operators is zero if when FALSE and non-zero when
|
The result of the boolean operators is zero if when FALSE and non-zero when
|
||||||
@@ -956,19 +1018,25 @@ it left.
|
|||||||
.Pp
|
.Pp
|
||||||
Some things are different for fixed-point math, though, which is why you have
|
Some things are different for fixed-point math, though, which is why you have
|
||||||
the following functions to use:
|
the following functions to use:
|
||||||
|
.EQ
|
||||||
|
delim $$
|
||||||
|
.EN
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -column -offset indent ".Sy String" ".Sy String"
|
.Bl -column -offset indent "ATAN2(x, y)"
|
||||||
.It Sy Name Ta Ta Sy Operation
|
.It Sy Name Ta Sy Operation
|
||||||
.It Li DIV(x,y) Ta Ta x/y
|
.It Fn DIV x y Ta $x \[di] y$
|
||||||
.It Li MUL(x,y) Ta Ta x*y
|
.It Fn MUL x y Ta $x \[mu] y$
|
||||||
.It Li SIN(x) Ta Ta sin(x)
|
.It Fn SIN x Ta $sin ( x )$
|
||||||
.It Li COS(x) Ta Ta cos(x)
|
.It Fn COS x Ta $cos ( x )$
|
||||||
.It Li TAN(x) Ta Ta tan(x)
|
.It Fn TAN x Ta $tan ( x )$
|
||||||
.It Li ASIN(x) Ta Ta arcsin(x)
|
.It Fn ASIN x Ta $asin ( x )$
|
||||||
.It Li ACOS(x) Ta Ta arccos(x)
|
.It Fn ACOS x Ta $acos ( x )$
|
||||||
.It Li ATAN(x) Ta Ta arctan(x)
|
.It Fn ATAN x Ta $atan ( x )$
|
||||||
.It Li ATAN2(x,y) Ta Angle between (x,y) and (1,0)
|
.It Fn ATAN2 x y Ta Angle between $( x , y )$ and $( 1 , 0 )$
|
||||||
.El
|
.El
|
||||||
|
.EQ
|
||||||
|
delim off
|
||||||
|
.EN
|
||||||
.Pp
|
.Pp
|
||||||
These functions are extremely useful for automatic generation of various tables.
|
These functions are extremely useful for automatic generation of various tables.
|
||||||
A circle has 65536.0 degrees.
|
A circle has 65536.0 degrees.
|
||||||
@@ -988,36 +1056,37 @@ ANGLE SET ANGLE+256.0
|
|||||||
.Pp
|
.Pp
|
||||||
.Ss String Expressions
|
.Ss String Expressions
|
||||||
The most basic string expression is any number of characters contained in double
|
The most basic string expression is any number of characters contained in double
|
||||||
quotes (\[dq]for instance\[dq]).
|
quotes ("for instance").
|
||||||
Like in C, the escape character is \[rs], and there are a number of commands you
|
Like in C, the escape character is \[rs], and there are a number of commands you
|
||||||
can use within a string:
|
can use within a string:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -column -offset indent ".Sy String" ".Sy String"
|
.Bl -column -offset indent "String"
|
||||||
.It Sy String Ta Sy Meaning
|
.It Sy String Ta Sy Meaning
|
||||||
.It Li \[rs]\[rs] Ta Backslash
|
.It Li \[rs]\[rs] Ta Backslash
|
||||||
.It Li \[rs]\[dq] Ta Double quote
|
.It Li \[rs]" Ta Double quote
|
||||||
.It Li \[rs], Ta Comma
|
.It Li \[rs], Ta Comma
|
||||||
.It Li \[rs]\[lC] Ta Curly bracket left
|
.It Li \[rs]{ Ta Curly bracket left
|
||||||
.It Li \[rs]\[rC] Ta Curly bracket right
|
.It Li \[rs]} Ta Curly bracket right
|
||||||
.It Li \[rs]n Ta Newline ($0A)
|
.It Li \[rs]n Ta Newline ($0A)
|
||||||
.It Li \[rs]t Ta Tab ($09)
|
.It Li \[rs]t Ta Tab ($09)
|
||||||
.It Li \[rs]1 - \[rs]9 Ta Macro argument (Only the body of a macros)
|
.It Li \[rs]1 - \[rs]9 Ta Macro argument (Only the body of a macros)
|
||||||
.It Li \[rs]\@ Ta Label name suffix (Only in the body of macros and repts)
|
.It Li \[rs]@ Ta Label name suffix (Only in the body of macros and repts)
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
A funky feature is
|
A funky feature is
|
||||||
.Sy \[lC]symbol\[rC]
|
.Sy {symbol}
|
||||||
withing a string.
|
within a string.
|
||||||
This will examine the type of the symbol and insert its value accordingly.
|
This will examine the type of the symbol and insert its value accordingly.
|
||||||
If symbol is a string symbol, the symbols value is simply copied.
|
If symbol is a string symbol, the symbols value is simply copied.
|
||||||
If it's a numeric symbol, the value is converted to hexadecimal notation and
|
If it's a numeric symbol, the value is converted to hexadecimal notation and
|
||||||
inserted as a string.
|
inserted as a string.
|
||||||
.Pp
|
.Pp
|
||||||
HINT: The
|
HINT: The
|
||||||
.Sy \[lC]symbol\[rC]
|
.Sy {symbol}
|
||||||
construct can also be used outside strings.
|
construct can also be used outside strings.
|
||||||
The symbol's value is again inserted as a string.
|
The symbol's value is again inserted as a string.
|
||||||
This is just a short way of doing \[dq]\[lC]symbol\[rC]\[dq].
|
This is just a short way of doing
|
||||||
|
.Dq {symbol} .
|
||||||
.Pp
|
.Pp
|
||||||
Whenever the macro-language expects a string you can actually use a string
|
Whenever the macro-language expects a string you can actually use a string
|
||||||
expression.
|
expression.
|
||||||
@@ -1025,19 +1094,19 @@ This consists of one or more of these function (yes, you can nest them).
|
|||||||
Note that some of these functions actually return an integer and can be used as
|
Note that some of these functions actually return an integer and can be used as
|
||||||
part of an integer expression!
|
part of an integer expression!
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -column ".Sy String" ".Sy String"
|
.Bl -column "STRSUB_str,_pos,_len"
|
||||||
.It Sy Name Ta Ta Ta Sy Operation
|
.It Sy Name Ta Sy Operation
|
||||||
.It Li STRLEN(string) Ta Returns the number of characters in string
|
.It Fn STRLEN string Ta Returns the number of characters in string
|
||||||
.It Li STRCAT(str1,str2) Ta Appends str2 to str1.
|
.It Fn STRCAT str1 str2 Ta Appends str2 to str1.
|
||||||
.It Li STRCMP(str1,str2) Ta Returns negative if str1 is alphabetically lower
|
.It Fn STRCMP str1 str2 Ta Returns negative if str1 is alphabetically lower
|
||||||
than str2, zero if they match, positive if str1 is greater than str2.
|
than str2, zero if they match, positive if str1 is greater than str2.
|
||||||
.It Li STRIN(str1,str2) Ta Returns the position of str2 in str1 or zero if it's
|
.It Fn STRIN str1 str2 Ta Returns the position of str2 in str1 or zero if it's
|
||||||
not present (first character is position 1).
|
not present (first character is position 1).
|
||||||
.It Li STRSUB(str,pos,len) Ta Returns a substring from str starting at pos
|
.It Fn STRSUB str pos len Ta Returns a substring from str starting at pos
|
||||||
(first character is position 1) and with len characters.
|
(first character is position 1) and with len characters.
|
||||||
.It Li STRUPR(str) Ta Converts all characters in str to capitals and returns the
|
.It Fn STRUPR str Ta Converts all characters in str to capitals and returns the
|
||||||
new string.
|
new string.
|
||||||
.It Li STRLWR(str) Ta Converts all characters in str to lower case and returns
|
.It Fn STRLWR str Ta Converts all characters in str to lower case and returns
|
||||||
the new string.
|
the new string.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
@@ -1072,23 +1141,32 @@ rest of it will be trimmed.
|
|||||||
.Ss Other functions
|
.Ss Other functions
|
||||||
There are a few other functions that do various useful things:
|
There are a few other functions that do various useful things:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -column ".Sy String" ".Sy String"
|
.Bl -column "BANK(arg)"
|
||||||
.It Sy Name Ta Ta Ta Sy Operation
|
.It Sy Name Ta Sy Operation
|
||||||
.It Li BANK(\@/str/lbl) Ta Returns a bank number.
|
.It Fn BANK arg Ta Returns a bank number.
|
||||||
If the argument is the symbol
|
If
|
||||||
.Ic \@,
|
.Ar arg
|
||||||
|
is the symbol
|
||||||
|
.Ic @ ,
|
||||||
this function returns the bank of the current section.
|
this function returns the bank of the current section.
|
||||||
If the argument is a string, it returns the bank of the section that has that
|
If
|
||||||
name.
|
.Ar arg
|
||||||
If the argument is a label, it returns the bank number the label is in.
|
is a string, it returns the bank of the section that has that name.
|
||||||
|
If
|
||||||
|
.Ar arg
|
||||||
|
is a label, it returns the bank number the label is in.
|
||||||
For labels, as the linker has to resolve this, it can't be used when the
|
For labels, as the linker has to resolve this, it can't be used when the
|
||||||
expression has to be constant.
|
expression has to be constant.
|
||||||
.It Li DEF(label) Ta Returns TRUE if label has been defined.
|
.It Fn DEF label Ta Returns TRUE if
|
||||||
.It Li HIGH(r16/cnst/lbl) Ta Returns the top 8 bits of the operand if it is a
|
.Ar label
|
||||||
label or constant, or the top 8-bit register if it is a 16-bit register.
|
has been defined.
|
||||||
.It Li LOW(r16/cnst/lbl) Ta Returns the bottom 8 bits of the operand if it is a
|
.It Fn HIGH arg Ta Returns the top 8 bits of the operand if
|
||||||
label or constant, or the bottom 8-bit register if it is a 16-bit register (AF
|
.Ar arg
|
||||||
isn't a valid register for this function).
|
is a label or constant, or the top 8-bit register if it is a 16-bit register.
|
||||||
|
.It Fn LOW arg Ta Returns the bottom 8 bits of the operand if
|
||||||
|
.Ar arg
|
||||||
|
is a label or constant, or the bottom 8-bit register if it is a 16-bit register
|
||||||
|
(AF isn't a valid register for this function).
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
.Sh MISCELLANEOUS
|
.Sh MISCELLANEOUS
|
||||||
@@ -1125,94 +1203,6 @@ Useful if you want to change some options in an include file and you don't want
|
|||||||
to destroy the options set by the program that included your file.
|
to destroy the options set by the program that included your file.
|
||||||
The stacks number of entries is limited only by the amount of memory in your
|
The stacks number of entries is limited only by the amount of memory in your
|
||||||
machine.
|
machine.
|
||||||
.Sh ALPHABETICAL LIST OF KEYWORDS
|
|
||||||
.Bl -inset -compact
|
|
||||||
.It Sx @
|
|
||||||
.It Sx __DATE__
|
|
||||||
.It Sx __FILE__
|
|
||||||
.It Sx __ISO_8601_LOCAL__
|
|
||||||
.It Sx __ISO_8601_UTC__
|
|
||||||
.It Sx __LINE__
|
|
||||||
.It Sx __TIME__
|
|
||||||
.It Sx __RGBDS_MAJOR__
|
|
||||||
.It Sx __RGBDS_MINOR__
|
|
||||||
.It Sx __RGBDS_PATCH__
|
|
||||||
.It Sx __UTC_YEAR__
|
|
||||||
.It Sx __UTC_MONTH__
|
|
||||||
.It Sx __UTC_DAY__
|
|
||||||
.It Sx __UTC_HOUR__
|
|
||||||
.It Sx __UTC_MINUTE__
|
|
||||||
.It Sx __UTC_SECOND__
|
|
||||||
.It Sx _NARG
|
|
||||||
.It Sx _PI
|
|
||||||
.It Sx _RS
|
|
||||||
.It Sx ACOS
|
|
||||||
.It Sx ASIN
|
|
||||||
.It Sx ATAN
|
|
||||||
.It Sx ATAN2
|
|
||||||
.It Sx BANK
|
|
||||||
.It Sx CHARMAP
|
|
||||||
.It Sx COS
|
|
||||||
.It Sx DB
|
|
||||||
.It Sx DEF
|
|
||||||
.It Sx DIV
|
|
||||||
.It Sx DL
|
|
||||||
.It Sx DS
|
|
||||||
.It Sx DW
|
|
||||||
.It Sx ELIF
|
|
||||||
.It Sx ELSE
|
|
||||||
.It Sx ENDC
|
|
||||||
.It Sx ENDM
|
|
||||||
.It Sx ENDR
|
|
||||||
.It Sx EQU
|
|
||||||
.It Sx EQUS
|
|
||||||
.It Sx EXPORT
|
|
||||||
.It Sx FAIL
|
|
||||||
.It Sx GLOBAL
|
|
||||||
.It Sx HIGH
|
|
||||||
.It Sx HRAM
|
|
||||||
.It Sx IF
|
|
||||||
.It Sx INCBIN
|
|
||||||
.It Sx INCLUDE
|
|
||||||
.It Sx LOW
|
|
||||||
.It Sx MACRO
|
|
||||||
.It Sx MUL
|
|
||||||
.It Sx OPT
|
|
||||||
.It Sx POPO
|
|
||||||
.It Sx POPS
|
|
||||||
.It Sx PRINTF
|
|
||||||
.It Sx PRINTI
|
|
||||||
.It Sx PRINTT
|
|
||||||
.It Sx PRINTV
|
|
||||||
.It Sx PURGE
|
|
||||||
.It Sx PUSHO
|
|
||||||
.It Sx PUSHS
|
|
||||||
.It Sx REPT
|
|
||||||
.It Sx RB
|
|
||||||
.It Sx RL
|
|
||||||
.It Sx ROM0
|
|
||||||
.It Sx ROMX
|
|
||||||
.It Sx RSRESET
|
|
||||||
.It Sx RSSET
|
|
||||||
.It Sx RW
|
|
||||||
.It Sx SECTION
|
|
||||||
.It Sx SET
|
|
||||||
.It Sx SHIFT
|
|
||||||
.It Sx SIN
|
|
||||||
.It Sx SRAM
|
|
||||||
.It Sx STRCAT
|
|
||||||
.It Sx STRCMP
|
|
||||||
.It Sx STRIN
|
|
||||||
.It Sx STRLEN
|
|
||||||
.It Sx STRLWR
|
|
||||||
.It Sx STRSUB
|
|
||||||
.It Sx STRUPR
|
|
||||||
.It Sx TAN
|
|
||||||
.It Sx VRAM
|
|
||||||
.It Sx WRAM0
|
|
||||||
.It Sx WRAMX
|
|
||||||
.It Sx WARN
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr rgbasm 1 ,
|
.Xr rgbasm 1 ,
|
||||||
.Xr rgblink 1 ,
|
.Xr rgblink 1 ,
|
||||||
|
|||||||
@@ -102,6 +102,19 @@ uint32_t calchash(char *s)
|
|||||||
return hash % HASHSIZE;
|
return hash % HASHSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update a symbol's definition filename and line
|
||||||
|
*/
|
||||||
|
void updateSymbolFilename(struct sSymbol *nsym)
|
||||||
|
{
|
||||||
|
if (snprintf(nsym->tzFileName, _MAX_PATH + 1, "%s",
|
||||||
|
tzCurrentFileName) > _MAX_PATH) {
|
||||||
|
fatalerror("%s: File name is too long: '%s'", __func__,
|
||||||
|
tzCurrentFileName);
|
||||||
|
}
|
||||||
|
nsym->nFileLine = fstk_GetLine();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new symbol by name
|
* Create a new symbol by name
|
||||||
*/
|
*/
|
||||||
@@ -133,14 +146,7 @@ struct sSymbol *createsymbol(char *s)
|
|||||||
(*ppsym)->pMacro = NULL;
|
(*ppsym)->pMacro = NULL;
|
||||||
(*ppsym)->pSection = NULL;
|
(*ppsym)->pSection = NULL;
|
||||||
(*ppsym)->Callback = NULL;
|
(*ppsym)->Callback = NULL;
|
||||||
|
updateSymbolFilename(*ppsym);
|
||||||
if (snprintf((*ppsym)->tzFileName, _MAX_PATH + 1, "%s",
|
|
||||||
tzCurrentFileName) > _MAX_PATH) {
|
|
||||||
fatalerror("%s: File name is too long: '%s'", __func__,
|
|
||||||
tzCurrentFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
(*ppsym)->nFileLine = fstk_GetLine();
|
|
||||||
return *ppsym;
|
return *ppsym;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,6 +566,7 @@ void sym_AddEqu(char *tzSym, int32_t value)
|
|||||||
nsym->nValue = value;
|
nsym->nValue = value;
|
||||||
nsym->nType |= SYMF_EQU | SYMF_DEFINED | SYMF_CONST;
|
nsym->nType |= SYMF_EQU | SYMF_DEFINED | SYMF_CONST;
|
||||||
nsym->pScope = NULL;
|
nsym->pScope = NULL;
|
||||||
|
updateSymbolFilename(nsym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -633,6 +640,7 @@ void sym_AddSet(char *tzSym, int32_t value)
|
|||||||
nsym->nValue = value;
|
nsym->nValue = value;
|
||||||
nsym->nType |= SYMF_SET | SYMF_DEFINED | SYMF_CONST;
|
nsym->nType |= SYMF_SET | SYMF_DEFINED | SYMF_CONST;
|
||||||
nsym->pScope = NULL;
|
nsym->pScope = NULL;
|
||||||
|
updateSymbolFilename(nsym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,6 +718,8 @@ void sym_AddReloc(char *tzSym)
|
|||||||
|
|
||||||
nsym->pScope = scope;
|
nsym->pScope = scope;
|
||||||
nsym->pSection = pCurrentSection;
|
nsym->pSection = pCurrentSection;
|
||||||
|
|
||||||
|
updateSymbolFilename(nsym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pScope = findsymbol(tzSym, scope);
|
pScope = findsymbol(tzSym, scope);
|
||||||
@@ -840,6 +850,7 @@ void sym_AddMacro(char *tzSym)
|
|||||||
nsym->pScope = NULL;
|
nsym->pScope = NULL;
|
||||||
nsym->ulMacroSize = ulNewMacroSize;
|
nsym->ulMacroSize = ulNewMacroSize;
|
||||||
nsym->pMacro = tzNewMacro;
|
nsym->pMacro = tzNewMacro;
|
||||||
|
updateSymbolFilename(nsym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
src/extern/utf8decoder.c
vendored
9
src/extern/utf8decoder.c
vendored
@@ -25,12 +25,9 @@ static const uint8_t utf8d[] = {
|
|||||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* b0..bf */
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* b0..bf */
|
||||||
8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* c0..cf */
|
8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* c0..cf */
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* d0..df */
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* d0..df */
|
||||||
0xa, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, /* e0..e7 */
|
10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, /* e0..ef */
|
||||||
0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, /* e8..ef */
|
11, 6, 6, 6, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* f0..ff */
|
||||||
0xb, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, /* f0..f7 */
|
0, 1, 2, 3, 5, 8, 7, 1, 1, 1, 4, 6, 1, 1, 1, 1, /* s0 */
|
||||||
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, /* f8..ff */
|
|
||||||
0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, /* s0.. */
|
|
||||||
0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, /* ..s0 */
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* s1 */
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* s1 */
|
||||||
1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, /* s1 */
|
1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, /* s1 */
|
||||||
1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, /* s3 */
|
1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, /* s3 */
|
||||||
|
|||||||
@@ -478,9 +478,9 @@ int main(int argc, char *argv[])
|
|||||||
int byte;
|
int byte;
|
||||||
|
|
||||||
while ((byte = fgetc(rom)) != EOF) {
|
while ((byte = fgetc(rom)) != EOF) {
|
||||||
i++;
|
if (i != 0x14E && i != 0x14F)
|
||||||
if (i != 0x150)
|
|
||||||
globalcksum += byte;
|
globalcksum += byte;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ferror(rom))
|
if (ferror(rom))
|
||||||
|
|||||||
26
src/gbz80.7
26
src/gbz80.7
@@ -1105,7 +1105,21 @@ Cycles: 3
|
|||||||
.Pp
|
.Pp
|
||||||
Bytes: 1
|
Bytes: 1
|
||||||
.Pp
|
.Pp
|
||||||
Flags: None affected.
|
Flags:
|
||||||
|
.Bl -bullet -compact
|
||||||
|
.It
|
||||||
|
.Sy Z :
|
||||||
|
Set from bit 7 of the popped low byte.
|
||||||
|
.It
|
||||||
|
.Sy N :
|
||||||
|
Set from bit 6 of the popped low byte.
|
||||||
|
.It
|
||||||
|
.Sy H :
|
||||||
|
Set from bit 5 of the popped low byte.
|
||||||
|
.It
|
||||||
|
.Sy C :
|
||||||
|
Set from bit 4 of the popped low byte.
|
||||||
|
.El
|
||||||
.Ss POP r16
|
.Ss POP r16
|
||||||
Pop register
|
Pop register
|
||||||
.Ar r16
|
.Ar r16
|
||||||
@@ -1119,7 +1133,15 @@ Flags: None affected.
|
|||||||
.Ss PUSH AF
|
.Ss PUSH AF
|
||||||
Push register
|
Push register
|
||||||
.Sy AF
|
.Sy AF
|
||||||
into the stack.
|
into the stack. The low byte's bit 7 corresponds to the
|
||||||
|
.Sy Z
|
||||||
|
flag, its bit 6 to the
|
||||||
|
.Sy N
|
||||||
|
flag, bit 5 to the
|
||||||
|
.Sy H
|
||||||
|
flag, and bit 4 to the
|
||||||
|
.Sy C
|
||||||
|
flag. Bits 3 to 0 are reset.
|
||||||
.Pp
|
.Pp
|
||||||
Cycles: 4
|
Cycles: 4
|
||||||
.Pp
|
.Pp
|
||||||
|
|||||||
@@ -321,8 +321,9 @@ struct sSection *GetSectionByName(const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IsSectionSameTypeBankAndFloating(const char *name,
|
int32_t IsSectionSameTypeBankAndAttrs(const char *name,
|
||||||
enum eSectionType type, int32_t bank)
|
enum eSectionType type, int32_t bank,
|
||||||
|
int32_t org, int32_t align)
|
||||||
{
|
{
|
||||||
const struct sSection *pSection;
|
const struct sSection *pSection;
|
||||||
|
|
||||||
@@ -340,8 +341,9 @@ int32_t IsSectionSameTypeBankAndFloating(const char *name,
|
|||||||
* mismatch or not.
|
* mismatch or not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Section must be floating in source */
|
/* Section must have the same attributes or float */
|
||||||
if (pSection->nOrg != -1 || pSection->nAlign != 1)
|
if ((pSection->nOrg != -1 && pSection->nOrg != org) ||
|
||||||
|
(pSection->nAlign != 1 && pSection->nAlign != align))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* It must have the same type in source and linkerscript */
|
/* It must have the same type in source and linkerscript */
|
||||||
@@ -374,15 +376,6 @@ uint32_t AssignSectionAddressAndBankByName(const char *name, uint32_t address,
|
|||||||
|
|
||||||
/* Section has been found. */
|
/* Section has been found. */
|
||||||
|
|
||||||
/*
|
|
||||||
* A section can be left as floating in the code if the location
|
|
||||||
* is assigned in the linkerscript.
|
|
||||||
*/
|
|
||||||
if (pSection->nOrg != -1 || pSection->nAlign != 1) {
|
|
||||||
errx(1, "Section \"%s\" from linkerscript isn't floating.\n",
|
|
||||||
name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The bank can be left as unassigned or be the same */
|
/* The bank can be left as unassigned or be the same */
|
||||||
if (pSection->nBank != -1 && pSection->nBank != bank) {
|
if (pSection->nBank != -1 && pSection->nBank != bank) {
|
||||||
errx(1, "Section \"%s\" from linkerscript has different bank number than in the source.\n",
|
errx(1, "Section \"%s\" from linkerscript has different bank number than in the source.\n",
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
struct sSymbol **tSymbols;
|
struct sSymbol **tSymbols;
|
||||||
struct sSection *pSections;
|
struct sSection *pSections;
|
||||||
struct sSection *pLibSections;
|
struct sSection *pLibSections;
|
||||||
uint8_t dummymem;
|
|
||||||
uint8_t oReadLib;
|
uint8_t oReadLib;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -209,7 +208,7 @@ struct sSection *obj_ReadRGBSection(FILE *f)
|
|||||||
if (pSection->nByteSize == 0) {
|
if (pSection->nByteSize == 0) {
|
||||||
/* Skip number of patches */
|
/* Skip number of patches */
|
||||||
readlong(f);
|
readlong(f);
|
||||||
pSection->pData = &dummymem;
|
pSection->pData = NULL;
|
||||||
return pSection;
|
return pSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +282,7 @@ void obj_ReadRGB(FILE *pObjfile, char *tzObjectfile)
|
|||||||
for (i = 0; i < nNumberOfSymbols; i += 1)
|
for (i = 0; i < nNumberOfSymbols; i += 1)
|
||||||
tSymbols[i] = obj_ReadSymbol(pObjfile, tzObjectfile);
|
tSymbols[i] = obj_ReadSymbol(pObjfile, tzObjectfile);
|
||||||
} else {
|
} else {
|
||||||
tSymbols = (struct sSymbol **)&dummymem;
|
tSymbols = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next we have the sections */
|
/* Next we have the sections */
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ static struct {
|
|||||||
static int32_t current_bank = -1; /* Bank as seen by the bank array */
|
static int32_t current_bank = -1; /* Bank as seen by the bank array */
|
||||||
static int32_t current_real_bank = -1; /* bank as seen by the GB */
|
static int32_t current_real_bank = -1; /* bank as seen by the GB */
|
||||||
|
|
||||||
|
/* Current section attributes */
|
||||||
|
static int32_t fix_org = -1;
|
||||||
|
static int32_t fix_align = 1;
|
||||||
|
|
||||||
void script_InitSections(void)
|
void script_InitSections(void)
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
@@ -176,6 +180,8 @@ void script_SetAddress(uint32_t addr)
|
|||||||
bank[current_bank].address,
|
bank[current_bank].address,
|
||||||
bank[current_bank].top_address);
|
bank[current_bank].top_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fix_org = addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void script_SetAlignment(uint32_t alignment)
|
void script_SetAlignment(uint32_t alignment)
|
||||||
@@ -200,6 +206,8 @@ void script_SetAlignment(uint32_t alignment)
|
|||||||
bank[current_bank].address,
|
bank[current_bank].address,
|
||||||
bank[current_bank].top_address);
|
bank[current_bank].top_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fix_align = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void script_OutputSection(const char *section_name)
|
void script_OutputSection(const char *section_name)
|
||||||
@@ -209,9 +217,11 @@ void script_OutputSection(const char *section_name)
|
|||||||
section_name);
|
section_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsSectionSameTypeBankAndFloating(section_name,
|
if (!IsSectionSameTypeBankAndAttrs(section_name,
|
||||||
bank[current_bank].type,
|
bank[current_bank].type,
|
||||||
current_real_bank)) {
|
current_real_bank,
|
||||||
|
fix_org,
|
||||||
|
fix_align)) {
|
||||||
errx(1, "Different attributes for \"%s\" in source and linkerscript\n",
|
errx(1, "Different attributes for \"%s\" in source and linkerscript\n",
|
||||||
section_name);
|
section_name);
|
||||||
}
|
}
|
||||||
@@ -221,5 +231,7 @@ void script_OutputSection(const char *section_name)
|
|||||||
AssignSectionAddressAndBankByName(section_name,
|
AssignSectionAddressAndBankByName(section_name,
|
||||||
bank[current_bank].address,
|
bank[current_bank].address,
|
||||||
current_real_bank);
|
current_real_bank);
|
||||||
}
|
|
||||||
|
|
||||||
|
fix_org = -1;
|
||||||
|
fix_align = 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
|
ERROR: divzero-section-bank.asm(1):
|
||||||
|
Invalid integer constant
|
||||||
ERROR: divzero-section-bank.asm(1):
|
ERROR: divzero-section-bank.asm(1):
|
||||||
Division by zero
|
Division by zero
|
||||||
|
|||||||
4
test/asm/equ-charmap.asm
Normal file
4
test/asm/equ-charmap.asm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
charmap "A", 1
|
||||||
|
_A_ EQU "A"
|
||||||
|
db _A_
|
||||||
0
test/asm/equ-charmap.out
Normal file
0
test/asm/equ-charmap.out
Normal file
1
test/asm/equ-charmap.out.bin
Normal file
1
test/asm/equ-charmap.out.bin
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
7
test/asm/label-redefinition.asm
Normal file
7
test/asm/label-redefinition.asm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
dw Sym
|
||||||
|
m: MACRO
|
||||||
|
Sym::
|
||||||
|
ENDM
|
||||||
|
m
|
||||||
|
Sym::
|
||||||
3
test/asm/label-redefinition.out
Normal file
3
test/asm/label-redefinition.out
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ERROR: label-redefinition.asm(7):
|
||||||
|
'Sym' already defined in m(6)
|
||||||
|
error: Assembly aborted in pass 1 (1 errors)!
|
||||||
1
test/asm/line-continuation.asm
Normal file
1
test/asm/line-continuation.asm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
foo @bar\
|
||||||
2
test/asm/line-continuation.out
Normal file
2
test/asm/line-continuation.out
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ERROR: line-continuation.asm(2) -> @(-1):
|
||||||
|
Macro '@' not defined
|
||||||
@@ -1,11 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
fname=$(mktemp)
|
o=$(mktemp)
|
||||||
|
gb=$(mktemp)
|
||||||
|
before=$(mktemp)
|
||||||
|
after=$(mktemp)
|
||||||
rc=0
|
rc=0
|
||||||
|
|
||||||
for i in *.asm; do
|
for i in *.asm; do
|
||||||
../../rgbasm $i >$fname 2>&1
|
../../rgbasm -o $o $i > $after 2>&1
|
||||||
diff -u $fname ${i%.asm}.out
|
diff -u ${i%.asm}.out $after
|
||||||
rc=$(($? || $rc))
|
rc=$(($? || $rc))
|
||||||
|
bin=${i%.asm}.out.bin
|
||||||
|
if [ -f $bin ]; then
|
||||||
|
../../rgblink -o $gb $o > $after 2>&1
|
||||||
|
head -c $(wc -c < $bin) $gb > $after 2>&1
|
||||||
|
hexdump -C $after > $before && mv $before $after
|
||||||
|
hexdump -C $bin > $before
|
||||||
|
diff -u $before $after
|
||||||
|
rc=$(($? || $rc))
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
rm -f $o $gb $before $after
|
||||||
exit $rc
|
exit $rc
|
||||||
|
|||||||
@@ -6,4 +6,5 @@ for i in *.asm; do
|
|||||||
mv -f $fname ${i%.asm}.out
|
mv -f $fname ${i%.asm}.out
|
||||||
done
|
done
|
||||||
|
|
||||||
|
rm -f $fname
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
2
test/asm/utf-8.asm
Normal file
2
test/asm/utf-8.asm
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
db "é"
|
||||||
0
test/asm/utf-8.out
Normal file
0
test/asm/utf-8.out
Normal file
1
test/asm/utf-8.out.bin
Normal file
1
test/asm/utf-8.out.bin
Normal file
@@ -0,0 +1 @@
|
|||||||
|
é
|
||||||
5
test/link/section-attributes-mismatch.link
Normal file
5
test/link/section-attributes-mismatch.link
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
ROM0
|
||||||
|
org $10
|
||||||
|
"sec"
|
||||||
|
org $20
|
||||||
|
"secfix"
|
||||||
2
test/link/section-attributes-mismatch.out
Normal file
2
test/link/section-attributes-mismatch.out
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
error: Different attributes for "sec" in source and linkerscript
|
||||||
|
|
||||||
2
test/link/section-attributes.asm
Normal file
2
test/link/section-attributes.asm
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
SECTION "sec",ROM0,ALIGN[4]
|
||||||
|
SECTION "secfix",ROM0[$20]
|
||||||
5
test/link/section-attributes.link
Normal file
5
test/link/section-attributes.link
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
ROM0
|
||||||
|
align 4
|
||||||
|
"sec"
|
||||||
|
org $20
|
||||||
|
"secfix"
|
||||||
0
test/link/section-attributes.out
Normal file
0
test/link/section-attributes.out
Normal file
@@ -16,6 +16,14 @@ head -c 20 $gbtemp > $otemp 2>&1
|
|||||||
diff bank-numbers.out.bin $otemp
|
diff bank-numbers.out.bin $otemp
|
||||||
rc=$(($? || $rc))
|
rc=$(($? || $rc))
|
||||||
|
|
||||||
|
$RGBASM -o $otemp section-attributes.asm
|
||||||
|
$RGBLINK -l section-attributes.link -o $gbtemp $otemp > $outtemp 2>&1
|
||||||
|
diff section-attributes.out $outtemp
|
||||||
|
rc=$(($? || $rc))
|
||||||
|
$RGBLINK -l section-attributes-mismatch.link -o $gbtemp $otemp > $outtemp 2>&1
|
||||||
|
diff section-attributes-mismatch.out $outtemp
|
||||||
|
rc=$(($? || $rc))
|
||||||
|
|
||||||
$RGBASM -o $otemp wramx-dmg-mode.asm
|
$RGBASM -o $otemp wramx-dmg-mode.asm
|
||||||
$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1
|
$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1
|
||||||
diff wramx-dmg-mode-no-d.out $outtemp
|
diff wramx-dmg-mode-no-d.out $outtemp
|
||||||
@@ -60,4 +68,5 @@ $RGBLINK -o $gbtemp $otemp
|
|||||||
diff all-instructions.out.bin $gbtemp
|
diff all-instructions.out.bin $gbtemp
|
||||||
rc=$(($? || $rc))
|
rc=$(($? || $rc))
|
||||||
|
|
||||||
|
rm -f $otemp $gbtemp $gbtemp2 $outtemp
|
||||||
exit $rc
|
exit $rc
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ $RGBASM -o $otemp bank-numbers.asm
|
|||||||
$RGBLINK -o $gbtemp $otemp > bank-numbers.out 2>&1
|
$RGBLINK -o $gbtemp $otemp > bank-numbers.out 2>&1
|
||||||
head -c 20 $gbtemp > bank-numbers.out.bin 2>&1
|
head -c 20 $gbtemp > bank-numbers.out.bin 2>&1
|
||||||
|
|
||||||
|
$RGBASM -o $otemp section-attributes.asm
|
||||||
|
$RGBLINK -l section-attributes.link \
|
||||||
|
-o $gbtemp $otemp > section-attributes.out 2>&1
|
||||||
|
$RGBLINK -l section-attributes-mismatch.link \
|
||||||
|
-o $gbtemp $otemp > section-attributes-mismatch.out 2>&1
|
||||||
|
|
||||||
$RGBASM -o $otemp wramx-dmg-mode.asm
|
$RGBASM -o $otemp wramx-dmg-mode.asm
|
||||||
$RGBLINK -o $gbtemp $otemp > wramx-dmg-mode-no-d.out 2>&1
|
$RGBLINK -o $gbtemp $otemp > wramx-dmg-mode-no-d.out 2>&1
|
||||||
$RGBLINK -d -o $gbtemp $otemp > wramx-dmg-mode-d.out 2>&1
|
$RGBLINK -d -o $gbtemp $otemp > wramx-dmg-mode-d.out 2>&1
|
||||||
@@ -28,4 +34,5 @@ $RGBLINK -t -o $gbtemp $otemp > romx-tiny-t.out 2>&1
|
|||||||
$RGBASM -o $otemp all-instructions.asm
|
$RGBASM -o $otemp all-instructions.asm
|
||||||
$RGBLINK -o all-instructions.out.bin $otemp 2>&1
|
$RGBLINK -o all-instructions.out.bin $otemp 2>&1
|
||||||
|
|
||||||
|
rm -f $otemp $gbtemp
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -15,20 +15,33 @@ pushd link
|
|||||||
popd
|
popd
|
||||||
|
|
||||||
# Test some significant external projects that use RGBDS
|
# Test some significant external projects that use RGBDS
|
||||||
|
# When adding new ones, don't forget to add them to the .gitignore!
|
||||||
|
|
||||||
git clone https://github.com/pret/pokecrystal.git --depth=1
|
if [ ! -d pokecrystal ]; then
|
||||||
|
git clone https://github.com/pret/pokecrystal.git --shallow-since=2018-06-04 --single-branch
|
||||||
|
fi
|
||||||
pushd pokecrystal
|
pushd pokecrystal
|
||||||
|
git fetch
|
||||||
|
git checkout 06e169d
|
||||||
make -j
|
make -j
|
||||||
make compare
|
make compare
|
||||||
popd
|
popd
|
||||||
|
|
||||||
git clone --recursive https://github.com/pret/pokered.git --depth=1
|
if [ ! -d pokered ]; then
|
||||||
|
git clone --recursive https://github.com/pret/pokered.git --shallow-since=2018-03-23 --single-branch
|
||||||
|
fi
|
||||||
pushd pokered
|
pushd pokered
|
||||||
|
git fetch
|
||||||
|
git checkout 98f09b6
|
||||||
make -j
|
make -j
|
||||||
make compare
|
make compare
|
||||||
popd
|
popd
|
||||||
|
|
||||||
git clone https://github.com/AntonioND/ucity.git --depth=1
|
if [ ! -d ucity ]; then
|
||||||
|
git clone https://github.com/AntonioND/ucity.git --shallow-since=2017-07-13 --single-branch
|
||||||
|
fi
|
||||||
pushd ucity
|
pushd ucity
|
||||||
|
git fetch
|
||||||
|
git checkout 3315601
|
||||||
make -j
|
make -j
|
||||||
popd
|
popd
|
||||||
|
|||||||
Reference in New Issue
Block a user