mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Compare commits
84 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 | ||
|
|
748943f6fc | ||
|
|
d945c5811c | ||
|
|
6fe2741f2d | ||
|
|
24d7cfe0f9 | ||
|
|
630933b148 | ||
|
|
e8a16c6f53 | ||
|
|
2cb50730a1 | ||
|
|
efae6c7fd2 | ||
|
|
8a559beeb8 | ||
|
|
7149fc1e39 | ||
|
|
2e695334c1 | ||
|
|
e2b4554a5c | ||
|
|
ef87dd5a6e | ||
|
|
4f126b37d0 | ||
|
|
1b4187e51f | ||
|
|
0daec91683 | ||
|
|
cbaaec98ca | ||
|
|
895d1d5813 | ||
|
|
e99a651165 | ||
|
|
0ae69b3114 | ||
|
|
95ccc48d0c | ||
|
|
29253046d5 | ||
|
|
340362d984 | ||
|
|
85ece88268 | ||
|
|
516e4578ea | ||
|
|
9829be1045 | ||
|
|
b28a16c0da | ||
|
|
4d13d57491 | ||
|
|
be6bc7460b | ||
|
|
efdd42c6a8 | ||
|
|
c1a97f6541 |
@@ -16,6 +16,12 @@
|
|||||||
# Show file line, not input line
|
# Show file line, not input line
|
||||||
--showfile
|
--showfile
|
||||||
|
|
||||||
|
# Don't expect SPDX tag in the first line of a file
|
||||||
|
--ignore SPDX_LICENSE_TAG
|
||||||
|
|
||||||
|
# Don't expect Signed-off-by lines in commit messages
|
||||||
|
--no-signoff
|
||||||
|
|
||||||
# List of ignored rules
|
# List of ignored rules
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
||||||
@@ -53,6 +59,9 @@
|
|||||||
# Prefer stdint.h types over kernel types
|
# Prefer stdint.h types over kernel types
|
||||||
--ignore PREFER_KERNEL_TYPES
|
--ignore PREFER_KERNEL_TYPES
|
||||||
|
|
||||||
|
# Don't ask to replace sscanf by kstrto
|
||||||
|
--ignore SSCANF_TO_KSTRTO
|
||||||
|
|
||||||
# Parentheses can make the code clearer
|
# Parentheses can make the code clearer
|
||||||
--ignore UNNECESSARY_PARENTHESES
|
--ignore UNNECESSARY_PARENTHESES
|
||||||
|
|
||||||
|
|||||||
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/*
|
||||||
|
|||||||
48
.travis-checkpatch.sh
Executable file
48
.travis-checkpatch.sh
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Checking code style..."
|
||||||
|
|
||||||
|
# Return failure as soon as a command fails to execute
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Download checkpatch.pl and related files
|
||||||
|
|
||||||
|
echo "Getting checkpatch.pl..."
|
||||||
|
|
||||||
|
mkdir checkpatchdir
|
||||||
|
|
||||||
|
wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl
|
||||||
|
mv checkpatch.pl checkpatchdir/checkpatch.pl
|
||||||
|
chmod +x checkpatchdir/checkpatch.pl
|
||||||
|
|
||||||
|
touch checkpatchdir/const_structs.checkpatch
|
||||||
|
touch checkpatchdir/spelling.txt
|
||||||
|
|
||||||
|
# Run checkpatch.pl on the new commits
|
||||||
|
|
||||||
|
echo "Running checkpatch.pl..."
|
||||||
|
|
||||||
|
fname=$(mktemp)
|
||||||
|
rc=0
|
||||||
|
|
||||||
|
git remote set-branches --add origin develop
|
||||||
|
git fetch
|
||||||
|
|
||||||
|
make CHECKPATCH=checkpatchdir/checkpatch.pl checkpatch > $fname
|
||||||
|
|
||||||
|
cat $fname
|
||||||
|
|
||||||
|
if grep "ERROR" $fname; then
|
||||||
|
# At least one error found
|
||||||
|
echo "Code style errors have been found!"
|
||||||
|
rc=1
|
||||||
|
else
|
||||||
|
echo "No code style errors found, your patches are ready!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
|
||||||
|
rm -rf checkpatchdir
|
||||||
|
|
||||||
|
exit $rc
|
||||||
@@ -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,9 +6,14 @@ install:
|
|||||||
- sudo make install
|
- sudo make install
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
|
- osx
|
||||||
compiler:
|
compiler:
|
||||||
- clang
|
- clang
|
||||||
- gcc
|
- gcc
|
||||||
script:
|
script:
|
||||||
- cd test
|
- cd test && ./run-tests.sh
|
||||||
- ./run-tests.sh
|
matrix:
|
||||||
|
include:
|
||||||
|
- env: _="checkpatch"
|
||||||
|
script:
|
||||||
|
- ./.travis-checkpatch.sh
|
||||||
|
|||||||
@@ -70,11 +70,14 @@ copyright and the reference to the MIT License.
|
|||||||
3. Create a new branch to work on. You could still work on ``develop``, but it's
|
3. Create a new branch to work on. You could still work on ``develop``, but it's
|
||||||
easier that way.
|
easier that way.
|
||||||
|
|
||||||
4. Sign off your commits: ``git commit -s``
|
4. Compile your changes with ``make develop`` instead of just ``make``. This
|
||||||
|
target checks for additional warnings. Your patches shouldn't introduce any
|
||||||
|
new warning (but it may be possible to remove some warning checks if it makes
|
||||||
|
the code much easier).
|
||||||
|
|
||||||
5. Follow the Linux kernel coding style, which can be found in the file
|
5. 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.
|
||||||
|
|
||||||
6. Download the files ``checkpatch.pl``, ``const_structs.checkpatch`` and
|
6. Download the files ``checkpatch.pl``, ``const_structs.checkpatch`` and
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
30
Makefile
30
Makefile
@@ -26,7 +26,7 @@ PNGLDLIBS := `${PKG_CONFIG} --static --libs-only-l libpng`
|
|||||||
|
|
||||||
VERSION_STRING := `git describe --tags --dirty --always 2>/dev/null`
|
VERSION_STRING := `git describe --tags --dirty --always 2>/dev/null`
|
||||||
|
|
||||||
WARNFLAGS := -Wall -Werror
|
WARNFLAGS := -Wall
|
||||||
|
|
||||||
# Overridable CFLAGS
|
# Overridable CFLAGS
|
||||||
CFLAGS := -g
|
CFLAGS := -g
|
||||||
@@ -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 \
|
||||||
@@ -160,6 +161,7 @@ install: all
|
|||||||
|
|
||||||
# Target used to check the coding style of the whole codebase. '.y' and '.l'
|
# Target used to check the coding style of the whole codebase. '.y' and '.l'
|
||||||
# files aren't checked, unfortunately...
|
# files aren't checked, unfortunately...
|
||||||
|
|
||||||
checkcodebase:
|
checkcodebase:
|
||||||
$Qfor file in `git ls-files | grep -E '\.c|\.h' | grep -v '\.html'`; do \
|
$Qfor file in `git ls-files | grep -E '\.c|\.h' | grep -v '\.html'`; do \
|
||||||
${CHECKPATCH} -f "$$file"; \
|
${CHECKPATCH} -f "$$file"; \
|
||||||
@@ -169,6 +171,7 @@ checkcodebase:
|
|||||||
# to the HEAD. Runs checkpatch once for each commit between the current HEAD and
|
# to the HEAD. Runs checkpatch once for each commit between the current HEAD and
|
||||||
# the first common commit between the HEAD and origin/develop. '.y' and '.l'
|
# the first common commit between the HEAD and origin/develop. '.y' and '.l'
|
||||||
# files aren't checked, unfortunately...
|
# files aren't checked, unfortunately...
|
||||||
|
|
||||||
checkpatch:
|
checkpatch:
|
||||||
$Qeval COMMON_COMMIT=$$(git merge-base HEAD origin/develop); \
|
$Qeval COMMON_COMMIT=$$(git merge-base HEAD origin/develop); \
|
||||||
for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \
|
for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \
|
||||||
@@ -193,6 +196,25 @@ wwwman:
|
|||||||
$Qmandoc ${MANDOC} src/link/rgblink.5 > docs/rgblink.5.html
|
$Qmandoc ${MANDOC} src/link/rgblink.5 > docs/rgblink.5.html
|
||||||
$Qmandoc ${MANDOC} src/gfx/rgbgfx.1 > docs/rgbgfx.1.html
|
$Qmandoc ${MANDOC} src/gfx/rgbgfx.1 > docs/rgbgfx.1.html
|
||||||
|
|
||||||
|
# This target is used during development in order to prevent adding new issues
|
||||||
|
# to the source code. All warnings are treated as errors in order to block the
|
||||||
|
# compilation and make the continous integration infrastructure return failure.
|
||||||
|
|
||||||
|
develop:
|
||||||
|
$Qenv make -j WARNFLAGS="-Werror -Wall -Wextra -Wpedantic \
|
||||||
|
-Wno-sign-compare -Wchkp -Wformat=2 -Wformat-overflow=2 \
|
||||||
|
-Wformat-truncation=1 -Wformat-y2k -Wswitch-enum -Wunused \
|
||||||
|
-Wuninitialized -Wunknown-pragmas -Wstrict-overflow=5 \
|
||||||
|
-Wstringop-overflow=4 -Walloc-zero -Wduplicated-cond \
|
||||||
|
-Wfloat-equal -Wshadow -Wcast-qual -Wcast-align -Wlogical-op \
|
||||||
|
-Wnested-externs -Wno-aggressive-loop-optimizations -Winline \
|
||||||
|
-Wundef -Wstrict-prototypes -Wold-style-definition \
|
||||||
|
-fsanitize=shift -fsanitize=integer-divide-by-zero \
|
||||||
|
-fsanitize=unreachable -fsanitize=vla-bound \
|
||||||
|
-fsanitize=signed-integer-overflow -fsanitize=bounds \
|
||||||
|
-fsanitize=object-size -fsanitize=bool -fsanitize=enum \
|
||||||
|
-fsanitize=alignment -fsanitize=null"
|
||||||
|
|
||||||
# Targets for the project maintainer to easily create Windows exes.
|
# Targets for the project maintainer to easily create Windows exes.
|
||||||
# This is not for Windows users!
|
# This is not for Windows users!
|
||||||
# If you're building on Windows with Cygwin or Mingw, just follow the Unix
|
# If you're building on Windows with Cygwin or Mingw, just follow the Unix
|
||||||
@@ -200,7 +222,7 @@ wwwman:
|
|||||||
|
|
||||||
mingw32:
|
mingw32:
|
||||||
$Qenv PKG_CONFIG_PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/ \
|
$Qenv PKG_CONFIG_PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/ \
|
||||||
make CC=i686-w64-mingw32-gcc YACC=bison WARNFLAGS= -j
|
make CC=i686-w64-mingw32-gcc YACC=bison -j
|
||||||
$Qmv rgbasm rgbasm.exe
|
$Qmv rgbasm rgbasm.exe
|
||||||
$Qmv rgblink rgblink.exe
|
$Qmv rgblink rgblink.exe
|
||||||
$Qmv rgbfix rgbfix.exe
|
$Qmv rgbfix rgbfix.exe
|
||||||
@@ -208,7 +230,7 @@ mingw32:
|
|||||||
|
|
||||||
mingw64:
|
mingw64:
|
||||||
$Qenv PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/ \
|
$Qenv PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/ \
|
||||||
make CC=x86_64-w64-mingw32-gcc YACC=bison WARNFLAGS= -j
|
make CC=x86_64-w64-mingw32-gcc YACC=bison -j
|
||||||
$Qmv rgbasm rgbasm.exe
|
$Qmv rgbasm rgbasm.exe
|
||||||
$Qmv rgblink rgblink.exe
|
$Qmv rgblink rgblink.exe
|
||||||
$Qmv rgbfix rgbfix.exe
|
$Qmv rgbfix rgbfix.exe
|
||||||
|
|||||||
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>,
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ REPT NumberOfSymbols ; Number of symbols defined in this object file.
|
|||||||
LONG LineNum ; Line number in the file where the symbol is defined.
|
LONG LineNum ; Line number in the file where the symbol is defined.
|
||||||
|
|
||||||
LONG SectionID ; The section number (of this object file) in which
|
LONG SectionID ; The section number (of this object file) in which
|
||||||
; this symbol is defined.
|
; this symbol is defined. If it doesn't belong to any
|
||||||
|
; specific section (like a constant), this field has
|
||||||
|
; the value -1.
|
||||||
|
|
||||||
LONG Value ; The symbols value. It's the offset into that
|
LONG Value ; The symbols value. It's the offset into that
|
||||||
; symbol's section.
|
; symbol's section.
|
||||||
|
|||||||
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 */
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "extern/stdnoreturn.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
struct sOptions {
|
struct sOptions {
|
||||||
char binary[2];
|
char binary[2];
|
||||||
@@ -46,7 +46,7 @@ void opt_Parse(char *s);
|
|||||||
* It is also used when the assembler goes into an invalid state (for example,
|
* It is also used when the assembler goes into an invalid state (for example,
|
||||||
* when it fails to allocate memory).
|
* when it fails to allocate memory).
|
||||||
*/
|
*/
|
||||||
noreturn void fatalerror(const char *fmt, ...);
|
noreturn_ void fatalerror(const char *fmt, ...);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used for errors that make it impossible to assemble correctly, but don't
|
* Used for errors that make it impossible to assemble correctly, but don't
|
||||||
|
|||||||
10
include/extern/err.h
vendored
10
include/extern/err.h
vendored
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "extern/stdnoreturn.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
#define warn rgbds_warn
|
#define warn rgbds_warn
|
||||||
#define vwarn rgbds_vwarn
|
#define vwarn rgbds_vwarn
|
||||||
@@ -34,10 +34,10 @@ void vwarn(const char *fmt, va_list ap);
|
|||||||
void warnx(const char *fmt, ...);
|
void warnx(const char *fmt, ...);
|
||||||
void vwarnx(const char *fmt, va_list ap);
|
void vwarnx(const char *fmt, va_list ap);
|
||||||
|
|
||||||
noreturn void err(int status, const char *fmt, ...);
|
noreturn_ void err(int status, const char *fmt, ...);
|
||||||
noreturn void verr(int status, const char *fmt, va_list ap);
|
noreturn_ void verr(int status, const char *fmt, va_list ap);
|
||||||
noreturn void errx(int status, const char *fmt, ...);
|
noreturn_ void errx(int status, const char *fmt, ...);
|
||||||
noreturn void verrx(int status, const char *fmt, va_list ap);
|
noreturn_ void verrx(int status, const char *fmt, va_list ap);
|
||||||
|
|
||||||
#endif /* ERR_IN_LIBC */
|
#endif /* ERR_IN_LIBC */
|
||||||
|
|
||||||
|
|||||||
29
include/extern/stdnoreturn.h
vendored
29
include/extern/stdnoreturn.h
vendored
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of RGBDS.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2014-2018, RGBDS contributors.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef EXTERN_STDNORETURN_H
|
|
||||||
#define EXTERN_STDNORETURN_H
|
|
||||||
|
|
||||||
#if __STDC_VERSION__ >= 201112L
|
|
||||||
/* C11 or newer */
|
|
||||||
#define noreturn _Noreturn
|
|
||||||
#elif __cplusplus >= 201103L
|
|
||||||
/* C++11 or newer */
|
|
||||||
#define noreturn [[noreturn]]
|
|
||||||
#elif __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ >= 5))
|
|
||||||
/* GCC 2.5 or newer */
|
|
||||||
#define noreturn __attribute__ ((noreturn))
|
|
||||||
#elif _MSC_VER >= 1310
|
|
||||||
/* MS Visual Studio 2003/.NET Framework 1.1 or newer */
|
|
||||||
#define noreturn _declspec(noreturn)
|
|
||||||
#else
|
|
||||||
/* Unsupported, but no need to throw a fit */
|
|
||||||
#define noreturn
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* EXTERN_STDNORETURN_H */
|
|
||||||
22
include/helpers.h
Normal file
22
include/helpers.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of RGBDS.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2018, RGBDS contributors.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HELPERS_H
|
||||||
|
#define HELPERS_H
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
/* GCC or compatible */
|
||||||
|
#define noreturn_ __attribute__ ((noreturn))
|
||||||
|
#define unused_ __attribute__ ((unused))
|
||||||
|
#else
|
||||||
|
/* Unsupported, but no need to throw a fit */
|
||||||
|
#define noreturn_
|
||||||
|
#define unused_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* HELPERS_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,9 +11,9 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "extern/stdnoreturn.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
noreturn void script_fatalerror(const char *fmt, ...);
|
noreturn_ void script_fatalerror(const char *fmt, ...);
|
||||||
|
|
||||||
void script_Parse(const char *path);
|
void script_Parse(const char *path);
|
||||||
|
|
||||||
|
|||||||
@@ -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 (6)
|
#define PACKAGE_VERSION_PATCH (8)
|
||||||
|
|
||||||
const char *get_package_version_string(void);
|
const char *get_package_version_string(void);
|
||||||
|
|
||||||
|
|||||||
402
src/asm/asmy.y
402
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"
|
||||||
@@ -28,8 +29,10 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "linkdefs.h"
|
#include "linkdefs.h"
|
||||||
|
|
||||||
|
uint32_t nListCountEmpty;
|
||||||
char *tzNewMacro;
|
char *tzNewMacro;
|
||||||
uint32_t ulNewMacroSize;
|
uint32_t ulNewMacroSize;
|
||||||
|
int32_t nPCOffset;
|
||||||
|
|
||||||
static void bankrangecheck(char *name, uint32_t secttype, int32_t org,
|
static void bankrangecheck(char *name, uint32_t secttype, int32_t org,
|
||||||
int32_t bank)
|
int32_t bank)
|
||||||
@@ -104,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;
|
||||||
@@ -339,8 +330,9 @@ static void if_skip_to_else(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '\"':
|
case '\"':
|
||||||
src++;
|
src += 2;
|
||||||
inString = false;
|
inString = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
src++;
|
src++;
|
||||||
@@ -447,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
|
||||||
@@ -462,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 */
|
||||||
|
|
||||||
@@ -579,7 +572,10 @@ asmfile : lines;
|
|||||||
|
|
||||||
/* Note: The lexer adds '\n' at the end of the input */
|
/* Note: The lexer adds '\n' at the end of the input */
|
||||||
lines : /* empty */
|
lines : /* empty */
|
||||||
| lines line '\n' {
|
| lines {
|
||||||
|
nListCountEmpty = 0;
|
||||||
|
nPCOffset = 1;
|
||||||
|
} line '\n' {
|
||||||
nLineNo += 1;
|
nLineNo += 1;
|
||||||
nTotalLines += 1;
|
nTotalLines += 1;
|
||||||
}
|
}
|
||||||
@@ -655,9 +651,9 @@ simple_pseudoop : include
|
|||||||
| import
|
| import
|
||||||
| export
|
| export
|
||||||
| global
|
| global
|
||||||
| db
|
| { nPCOffset = 0; } db
|
||||||
| dw
|
| { nPCOffset = 0; } dw
|
||||||
| dl
|
| { nPCOffset = 0; } dl
|
||||||
| ds
|
| ds
|
||||||
| section
|
| section
|
||||||
| rsreset
|
| rsreset
|
||||||
@@ -802,16 +798,28 @@ ds : T_POP_DS uconst
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
db : T_POP_DB constlist_8bit_entry comma constlist_8bit
|
db : T_POP_DB constlist_8bit_entry comma constlist_8bit {
|
||||||
| T_POP_DB constlist_8bit_entry_single
|
if ((nPass == 1) && (nListCountEmpty > 0)) {
|
||||||
|
warning("Empty entry in list of 8-bit elements (treated as 0).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| T_POP_DB constlist_8bit_entry
|
||||||
;
|
;
|
||||||
|
|
||||||
dw : T_POP_DW constlist_16bit_entry comma constlist_16bit
|
dw : T_POP_DW constlist_16bit_entry comma constlist_16bit {
|
||||||
| T_POP_DW constlist_16bit_entry_single
|
if ((nPass == 1) && (nListCountEmpty > 0)) {
|
||||||
|
warning("Empty entry in list of 16-bit elements (treated as 0).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| T_POP_DW constlist_16bit_entry
|
||||||
;
|
;
|
||||||
|
|
||||||
dl : T_POP_DL constlist_32bit_entry comma constlist_32bit
|
dl : T_POP_DL constlist_32bit_entry comma constlist_32bit {
|
||||||
| T_POP_DL constlist_32bit_entry_single
|
if ((nPass == 1) && (nListCountEmpty > 0)) {
|
||||||
|
warning("Empty entry in list of 32-bit elements (treated as 0).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| T_POP_DL constlist_32bit_entry
|
||||||
;
|
;
|
||||||
|
|
||||||
purge : T_POP_PURGE {
|
purge : T_POP_PURGE {
|
||||||
@@ -877,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));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -912,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.");
|
||||||
}
|
}
|
||||||
@@ -929,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.
|
||||||
@@ -982,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.
|
||||||
@@ -1014,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;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -1028,26 +1037,7 @@ constlist_8bit : constlist_8bit_entry
|
|||||||
constlist_8bit_entry : /* empty */
|
constlist_8bit_entry : /* empty */
|
||||||
{
|
{
|
||||||
out_Skip(1);
|
out_Skip(1);
|
||||||
if (nPass == 1)
|
nListCountEmpty++;
|
||||||
warning("Empty entry in list of 8-bit elements (treated as 0).");
|
|
||||||
}
|
|
||||||
| const_8bit
|
|
||||||
{
|
|
||||||
out_RelByte(&$1);
|
|
||||||
}
|
|
||||||
| string
|
|
||||||
{
|
|
||||||
char *s = $1;
|
|
||||||
int32_t length = charmap_Convert(&s);
|
|
||||||
|
|
||||||
out_AbsByteGroup(s, length);
|
|
||||||
free(s);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
constlist_8bit_entry_single : /* empty */
|
|
||||||
{
|
|
||||||
out_Skip(1);
|
|
||||||
}
|
}
|
||||||
| const_8bit
|
| const_8bit
|
||||||
{
|
{
|
||||||
@@ -1070,18 +1060,7 @@ constlist_16bit : constlist_16bit_entry
|
|||||||
constlist_16bit_entry : /* empty */
|
constlist_16bit_entry : /* empty */
|
||||||
{
|
{
|
||||||
out_Skip(2);
|
out_Skip(2);
|
||||||
if (nPass == 1)
|
nListCountEmpty++;
|
||||||
warning("Empty entry in list of 16-bit elements (treated as 0).");
|
|
||||||
}
|
|
||||||
| const_16bit
|
|
||||||
{
|
|
||||||
out_RelWord(&$1);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
constlist_16bit_entry_single : /* empty */
|
|
||||||
{
|
|
||||||
out_Skip(2);
|
|
||||||
}
|
}
|
||||||
| const_16bit
|
| const_16bit
|
||||||
{
|
{
|
||||||
@@ -1096,18 +1075,7 @@ constlist_32bit : constlist_32bit_entry
|
|||||||
constlist_32bit_entry : /* empty */
|
constlist_32bit_entry : /* empty */
|
||||||
{
|
{
|
||||||
out_Skip(4);
|
out_Skip(4);
|
||||||
if (nPass == 1)
|
nListCountEmpty++;
|
||||||
warning("Empty entry in list of 32-bit elements (treated as 0).");
|
|
||||||
}
|
|
||||||
| relocconst
|
|
||||||
{
|
|
||||||
out_RelLong(&$1);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
constlist_32bit_entry_single : /* empty */
|
|
||||||
{
|
|
||||||
out_Skip(4);
|
|
||||||
}
|
}
|
||||||
| relocconst
|
| relocconst
|
||||||
{
|
{
|
||||||
@@ -1134,9 +1102,40 @@ const_16bit : relocconst
|
|||||||
|
|
||||||
relocconst : T_ID
|
relocconst : T_ID
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* The value of @ needs to be evaluated by the linker,
|
||||||
|
* it can only be calculated by the assembler in very
|
||||||
|
* few cases (when the base address of a section is
|
||||||
|
* known).
|
||||||
|
*
|
||||||
|
* '@' is a bit special in that it means different
|
||||||
|
* things depending on when it is used:
|
||||||
|
*
|
||||||
|
* - JR/LD/ADD/etc: It refers to the first byte of the
|
||||||
|
* instruction (1 byte offset relative to the value
|
||||||
|
* stored in the ROM).
|
||||||
|
* - DB/DW/DL: It refers to the address of the value
|
||||||
|
* that is being saved (0 byte offset relative to the
|
||||||
|
* value stored in the ROM.
|
||||||
|
*
|
||||||
|
* This offset must be added whenever '@' is added to a
|
||||||
|
* RPN expression so that the linker can calculate the
|
||||||
|
* correct result of any expression that uses '@'.
|
||||||
|
*/
|
||||||
|
if ((strcmp($1, "@") == 0) && (nPCOffset != 0)) {
|
||||||
|
struct Expression sTemp, sOffset;
|
||||||
|
|
||||||
|
rpn_Symbol(&sTemp, $1);
|
||||||
|
sTemp.nVal = sym_GetValue($1);
|
||||||
|
|
||||||
|
rpn_Number(&sOffset, nPCOffset);
|
||||||
|
|
||||||
|
rpn_SUB(&$$, &sTemp, &sOffset);
|
||||||
|
} else {
|
||||||
rpn_Symbol(&$$, $1);
|
rpn_Symbol(&$$, $1);
|
||||||
$$.nVal = sym_GetValue($1);
|
$$.nVal = sym_GetValue($1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
| T_NUMBER
|
| T_NUMBER
|
||||||
{
|
{
|
||||||
rpn_Number(&$$, $1);
|
rpn_Number(&$$, $1);
|
||||||
@@ -1194,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));
|
||||||
@@ -1225,88 +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 { $$ = $1 << $3; }
|
| const T_OP_LOGICEQU const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| const T_OP_SHR const { $$ = $1 >> $3; }
|
| const T_OP_LOGICGT const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| const T_OP_MUL const { $$ = $1 * $3; }
|
| const T_OP_LOGICLT const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| const T_OP_DIV const
|
| 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("division by zero");
|
| const T_OP_ADD const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
$$ = $1 / $3;
|
| const T_OP_SUB const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
}
|
| const T_OP_XOR const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| const T_OP_MOD const
|
| const T_OP_OR const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
{
|
| const T_OP_AND const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
if ($3 == 0)
|
| const T_OP_SHL const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
fatalerror("division by zero");
|
| const T_OP_SHR const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
$$ = $1 % $3;
|
| const T_OP_MUL const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
}
|
| const T_OP_DIV const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| T_OP_ADD const %prec NEG { $$ = +$2; }
|
| const T_OP_MOD const { constexpr_BinaryOp(&$$, $2, &$1, &$3); }
|
||||||
| T_OP_SUB const %prec NEG { $$ = -$2; }
|
| T_OP_ADD const %prec NEG { constexpr_UnaryOp(&$$, $1, &$2); }
|
||||||
| T_OP_NOT const %prec NEG { $$ = ~$2; }
|
| T_OP_SUB const %prec NEG { constexpr_UnaryOp(&$$, $1, &$2); }
|
||||||
| T_OP_ROUND '(' const ')' { $$ = math_Round($3); }
|
| T_OP_NOT const %prec NEG { constexpr_UnaryOp(&$$, $1, &$2); }
|
||||||
| T_OP_CEIL '(' const ')' { $$ = math_Ceil($3); }
|
| T_OP_ROUND '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_FLOOR '(' const ')' { $$ = math_Floor($3); }
|
| T_OP_CEIL '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_FDIV '(' const comma const ')' { $$ = math_Div($3,$5); }
|
| T_OP_FLOOR '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_FMUL '(' const comma const ')' { $$ = math_Mul($3,$5); }
|
| T_OP_FDIV '(' const comma const ')' { constexpr_BinaryOp(&$$, $1, &$3, &$5); }
|
||||||
| T_OP_SIN '(' const ')' { $$ = math_Sin($3); }
|
| T_OP_FMUL '(' const comma const ')' { constexpr_BinaryOp(&$$, $1, &$3, &$5); }
|
||||||
| T_OP_COS '(' const ')' { $$ = math_Cos($3); }
|
| T_OP_SIN '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_TAN '(' const ')' { $$ = math_Tan($3); }
|
| T_OP_COS '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_ASIN '(' const ')' { $$ = math_ASin($3); }
|
| T_OP_TAN '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_ACOS '(' const ')' { $$ = math_ACos($3); }
|
| T_OP_ASIN '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_ATAN '(' const ')' { $$ = math_ATan($3); }
|
| T_OP_ACOS '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
| T_OP_ATAN2 '(' const comma const ')' { $$ = math_ATan2($3,$5); }
|
| T_OP_ATAN '(' const ')' { constexpr_UnaryOp(&$$, $1, &$3); }
|
||||||
|
| T_OP_ATAN2 '(' const comma const ')' { constexpr_BinaryOp(&$$, $1, &$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; }
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -1680,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;
|
||||||
|
}
|
||||||
@@ -87,6 +87,8 @@ static void pushcontext(void)
|
|||||||
(*ppFileStack)->nREPTBlockSize = nCurrentREPTBlockSize;
|
(*ppFileStack)->nREPTBlockSize = nCurrentREPTBlockSize;
|
||||||
(*ppFileStack)->nREPTBlockCount = nCurrentREPTBlockCount;
|
(*ppFileStack)->nREPTBlockCount = nCurrentREPTBlockCount;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
fatalerror("%s: Internal error.", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nLineNo = 0;
|
nLineNo = 0;
|
||||||
@@ -152,6 +154,8 @@ static int32_t popcontext(void)
|
|||||||
nCurrentREPTBlockSize = pLastFile->nREPTBlockSize;
|
nCurrentREPTBlockSize = pLastFile->nREPTBlockSize;
|
||||||
nCurrentREPTBlockCount = pLastFile->nREPTBlockCount;
|
nCurrentREPTBlockCount = pLastFile->nREPTBlockCount;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
fatalerror("%s: Internal error.", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(*ppLastFile);
|
free(*ppLastFile);
|
||||||
@@ -174,12 +178,13 @@ int32_t fstk_GetLine(void)
|
|||||||
return nLineNo; /* ??? */
|
return nLineNo; /* ??? */
|
||||||
case STAT_isREPTBlock:
|
case STAT_isREPTBlock:
|
||||||
break; /* Peek top file of the stack */
|
break; /* Peek top file of the stack */
|
||||||
|
default:
|
||||||
|
fatalerror("%s: Internal error.", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -229,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;
|
||||||
@@ -257,8 +262,10 @@ FILE *fstk_FindFile(char *fname)
|
|||||||
* space had been available. Thus, a return value of `size` or
|
* space had been available. Thus, a return value of `size` or
|
||||||
* more means that the output was truncated.
|
* more means that the output was truncated.
|
||||||
*/
|
*/
|
||||||
if (snprintf(path, sizeof(path), "%s%s", IncludePaths[i], fname)
|
int fullpathlen = snprintf(path, sizeof(path), "%s%s",
|
||||||
>= sizeof(path))
|
IncludePaths[i], fname);
|
||||||
|
|
||||||
|
if (fullpathlen >= (int)sizeof(path))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = fopen(path, "rb");
|
||||||
@@ -268,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,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);
|
||||||
@@ -289,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,12 +14,15 @@
|
|||||||
#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"
|
||||||
#include "asm/symbol.h"
|
#include "asm/symbol.h"
|
||||||
#include "asm/symbol.h"
|
#include "asm/symbol.h"
|
||||||
|
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
#include "asmy.h"
|
#include "asmy.h"
|
||||||
|
|
||||||
bool oDontExpandStrings;
|
bool oDontExpandStrings;
|
||||||
@@ -93,9 +96,18 @@ static int32_t ascii2bin(char *s)
|
|||||||
s += 1;
|
s += 1;
|
||||||
convertfunc = binary2bin;
|
convertfunc = binary2bin;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
/* Handle below */
|
||||||
|
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') {
|
||||||
@@ -216,7 +228,7 @@ uint32_t PutMacroArg(char *src, uint32_t size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t PutUniqueArg(char *src, uint32_t size)
|
uint32_t PutUniqueArg(unused_ char *src, uint32_t size)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
@@ -307,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},
|
||||||
@@ -579,7 +592,7 @@ void setup_lexer(void)
|
|||||||
lex_FloatAddRange(id, '@', '@');
|
lex_FloatAddRange(id, '@', '@');
|
||||||
lex_FloatAddRange(id, '#', '#');
|
lex_FloatAddRange(id, '#', '#');
|
||||||
|
|
||||||
//@ID
|
// "@"
|
||||||
|
|
||||||
id = lex_FloatAlloc(&tIDToken);
|
id = lex_FloatAlloc(&tIDToken);
|
||||||
lex_FloatAddFirstRange(id, '@', '@');
|
lex_FloatAddFirstRange(id, '@', '@');
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -414,7 +449,7 @@ void yylex_GetFloatMaskAndFloatLen(uint32_t *pnFloatMask, uint32_t *pnFloatLen)
|
|||||||
/*
|
/*
|
||||||
* Gets the longest keyword/operator from the current position in the buffer.
|
* Gets the longest keyword/operator from the current position in the buffer.
|
||||||
*/
|
*/
|
||||||
struct sLexString *yylex_GetLongestFixed()
|
struct sLexString *yylex_GetLongestFixed(void)
|
||||||
{
|
{
|
||||||
struct sLexString *pLongestFixed = NULL;
|
struct sLexString *pLongestFixed = NULL;
|
||||||
char *s = pLexBuffer;
|
char *s = pLexBuffer;
|
||||||
@@ -640,7 +675,6 @@ scanagain:
|
|||||||
|
|
||||||
/* Check for line continuation character */
|
/* Check for line continuation character */
|
||||||
if (*pLexBuffer == '\\') {
|
if (*pLexBuffer == '\\') {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look for line continuation character after a series of
|
* Look for line continuation character after a series of
|
||||||
* spaces. This is also useful for files that use Windows line
|
* spaces. This is also useful for files that use Windows line
|
||||||
@@ -736,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -851,7 +886,7 @@ uint32_t yylex(void)
|
|||||||
return yylex_NORMAL();
|
return yylex_NORMAL();
|
||||||
case LEX_STATE_MACROARGS:
|
case LEX_STATE_MACROARGS:
|
||||||
return yylex_MACROARGS();
|
return yylex_MACROARGS();
|
||||||
|
default:
|
||||||
|
fatalerror("%s: Internal error.", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
fatalerror("Internal error in %s", __func__);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
|
|
||||||
#include "extern/err.h"
|
#include "extern/err.h"
|
||||||
|
|
||||||
|
#include "helpers.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
extern int yyparse(void);
|
extern int yyparse(void);
|
||||||
@@ -147,10 +149,13 @@ void opt_Parse(char *s)
|
|||||||
case 'z':
|
case 'z':
|
||||||
if (strlen(&s[1]) <= 2) {
|
if (strlen(&s[1]) <= 2) {
|
||||||
int32_t result;
|
int32_t result;
|
||||||
|
unsigned int fillchar;
|
||||||
|
|
||||||
result = sscanf(&s[1], "%x", &newopt.fillchar);
|
result = sscanf(&s[1], "%x", &fillchar);
|
||||||
if (!((result == EOF) || (result == 1)))
|
if (!((result == EOF) || (result == 1)))
|
||||||
errx(1, "Invalid argument for option 'z'");
|
errx(1, "Invalid argument for option 'z'");
|
||||||
|
|
||||||
|
newopt.fillchar = fillchar;
|
||||||
} else {
|
} else {
|
||||||
errx(1, "Invalid argument for option 'z'");
|
errx(1, "Invalid argument for option 'z'");
|
||||||
}
|
}
|
||||||
@@ -222,7 +227,7 @@ void opt_AddDefine(char *s)
|
|||||||
|
|
||||||
static void opt_ParseDefines(void)
|
static void opt_ParseDefines(void)
|
||||||
{
|
{
|
||||||
int32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0; i < cldefines_index; i += 2)
|
for (i = 0; i < cldefines_index; i += 2)
|
||||||
sym_AddString(cldefines[i], cldefines[i + 1]);
|
sym_AddString(cldefines[i], cldefines[i + 1]);
|
||||||
@@ -235,7 +240,7 @@ void verror(const char *fmt, va_list args)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: ");
|
fprintf(stderr, "ERROR: ");
|
||||||
fstk_Dump();
|
fstk_Dump();
|
||||||
fprintf(stderr, ":\n\t");
|
fprintf(stderr, ":\n ");
|
||||||
vfprintf(stderr, fmt, args);
|
vfprintf(stderr, fmt, args);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
nErrors += 1;
|
nErrors += 1;
|
||||||
@@ -250,7 +255,7 @@ void yyerror(const char *fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fatalerror(const char *fmt, ...)
|
noreturn_ void fatalerror(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@@ -272,7 +277,7 @@ void warning(const char *fmt, ...)
|
|||||||
|
|
||||||
fprintf(stderr, "warning: ");
|
fprintf(stderr, "warning: ");
|
||||||
fstk_Dump();
|
fstk_Dump();
|
||||||
fprintf(stderr, ":\n\t");
|
fprintf(stderr, ":\n ");
|
||||||
vfprintf(stderr, fmt, args);
|
vfprintf(stderr, fmt, args);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
@@ -480,7 +485,7 @@ int main(int argc, char *argv[])
|
|||||||
if (CurrentOptions.verbose) {
|
if (CurrentOptions.verbose) {
|
||||||
printf("Success! %u lines in %d.%02d seconds ", nTotalLines,
|
printf("Success! %u lines in %d.%02d seconds ", nTotalLines,
|
||||||
(int)timespent, ((int)(timespent * 100.0)) % 100);
|
(int)timespent, ((int)(timespent * 100.0)) % 100);
|
||||||
if (timespent == 0)
|
if (timespent < FLT_MIN_EXP)
|
||||||
printf("(INFINITY lines/minute)\n");
|
printf("(INFINITY lines/minute)\n");
|
||||||
else
|
else
|
||||||
printf("(%d lines/minute)\n",
|
printf("(%d lines/minute)\n",
|
||||||
|
|||||||
@@ -882,7 +882,8 @@ void out_PCRelByte(struct Expression *expr)
|
|||||||
{
|
{
|
||||||
checkcodesection();
|
checkcodesection();
|
||||||
checksectionoverflow(1);
|
checksectionoverflow(1);
|
||||||
if (rpn_isReloc(expr)) {
|
|
||||||
|
/* Always let the linker calculate the offset. */
|
||||||
if (nPass == 2) {
|
if (nPass == 2) {
|
||||||
pCurrentSection->tData[nPC] = 0;
|
pCurrentSection->tData[nPC] = 0;
|
||||||
createpatch(PATCH_BYTE_JR, expr);
|
createpatch(PATCH_BYTE_JR, expr);
|
||||||
@@ -890,16 +891,7 @@ void out_PCRelByte(struct Expression *expr)
|
|||||||
pCurrentSection->nPC += 1;
|
pCurrentSection->nPC += 1;
|
||||||
nPC += 1;
|
nPC += 1;
|
||||||
pPCSymbol->nValue += 1;
|
pPCSymbol->nValue += 1;
|
||||||
} else {
|
|
||||||
int32_t b = expr->nVal;
|
|
||||||
|
|
||||||
b = (int16_t)((b & 0xFFFF) - (nPC + 1));
|
|
||||||
|
|
||||||
if (nPass == 2 && ((b < -128) || (b > 127)))
|
|
||||||
yyerror("PC-relative value must be 8-bit");
|
|
||||||
|
|
||||||
out_AbsByte(b & 0xFF);
|
|
||||||
}
|
|
||||||
rpn_Reset(expr);
|
rpn_Reset(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -910,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);
|
||||||
|
|
||||||
@@ -946,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 ,
|
||||||
|
|||||||
@@ -330,6 +330,15 @@ void rpn_SHL(struct Expression *expr, const struct Expression *src1,
|
|||||||
const struct Expression *src2)
|
const struct Expression *src2)
|
||||||
{
|
{
|
||||||
joinexpr();
|
joinexpr();
|
||||||
|
|
||||||
|
if (src1->nVal < 0)
|
||||||
|
warning("Left shift of negative value: %d", src1->nVal);
|
||||||
|
|
||||||
|
if (src2->nVal < 0)
|
||||||
|
fatalerror("Shift by negative value: %d", src2->nVal);
|
||||||
|
else if (src2->nVal >= 32)
|
||||||
|
fatalerror("Shift by too big value: %d", src2->nVal);
|
||||||
|
|
||||||
expr->nVal = (expr->nVal << src2->nVal);
|
expr->nVal = (expr->nVal << src2->nVal);
|
||||||
pushbyte(expr, RPN_SHL);
|
pushbyte(expr, RPN_SHL);
|
||||||
}
|
}
|
||||||
@@ -338,6 +347,11 @@ void rpn_SHR(struct Expression *expr, const struct Expression *src1,
|
|||||||
const struct Expression *src2)
|
const struct Expression *src2)
|
||||||
{
|
{
|
||||||
joinexpr();
|
joinexpr();
|
||||||
|
if (src2->nVal < 0)
|
||||||
|
fatalerror("Shift by negative value: %d", src2->nVal);
|
||||||
|
else if (src2->nVal >= 32)
|
||||||
|
fatalerror("Shift by too big value: %d", src2->nVal);
|
||||||
|
|
||||||
expr->nVal = (expr->nVal >> src2->nVal);
|
expr->nVal = (expr->nVal >> src2->nVal);
|
||||||
pushbyte(expr, RPN_SHR);
|
pushbyte(expr, RPN_SHR);
|
||||||
}
|
}
|
||||||
@@ -355,7 +369,7 @@ void rpn_DIV(struct Expression *expr, const struct Expression *src1,
|
|||||||
{
|
{
|
||||||
joinexpr();
|
joinexpr();
|
||||||
if (src2->nVal == 0)
|
if (src2->nVal == 0)
|
||||||
fatalerror("division by zero");
|
fatalerror("Division by zero");
|
||||||
|
|
||||||
expr->nVal = (expr->nVal / src2->nVal);
|
expr->nVal = (expr->nVal / src2->nVal);
|
||||||
pushbyte(expr, RPN_DIV);
|
pushbyte(expr, RPN_DIV);
|
||||||
@@ -366,7 +380,7 @@ void rpn_MOD(struct Expression *expr, const struct Expression *src1,
|
|||||||
{
|
{
|
||||||
joinexpr();
|
joinexpr();
|
||||||
if (src2->nVal == 0)
|
if (src2->nVal == 0)
|
||||||
fatalerror("division by zero");
|
fatalerror("Division by zero");
|
||||||
|
|
||||||
expr->nVal = (expr->nVal % src2->nVal);
|
expr->nVal = (expr->nVal % src2->nVal);
|
||||||
pushbyte(expr, RPN_MOD);
|
pushbyte(expr, RPN_MOD);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "extern/err.h"
|
#include "extern/err.h"
|
||||||
|
|
||||||
|
#include "helpers.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
struct sSymbol *tHashedSymbols[HASHSIZE];
|
struct sSymbol *tHashedSymbols[HASHSIZE];
|
||||||
@@ -62,7 +63,7 @@ void helper_RemoveLeadingZeros(char *string)
|
|||||||
memmove(string, new_beginning, strlen(new_beginning) + 1);
|
memmove(string, new_beginning, strlen(new_beginning) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Callback_NARG(struct sSymbol *sym)
|
int32_t Callback_NARG(unused_ struct sSymbol *sym)
|
||||||
{
|
{
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ int32_t Callback_NARG(struct sSymbol *sym)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Callback__LINE__(struct sSymbol __attribute__((unused)) *sym)
|
int32_t Callback__LINE__(unused_ struct sSymbol *sym)
|
||||||
{
|
{
|
||||||
return nLineNo;
|
return nLineNo;
|
||||||
}
|
}
|
||||||
@@ -101,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
|
||||||
*/
|
*/
|
||||||
@@ -132,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -632,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,7 +682,7 @@ void sym_AddReloc(char *tzSym)
|
|||||||
|
|
||||||
struct sSymbol *parent = pScope->pScope ?
|
struct sSymbol *parent = pScope->pScope ?
|
||||||
pScope->pScope : pScope;
|
pScope->pScope : pScope;
|
||||||
int32_t parentLen = localPtr - tzSym;
|
uint32_t parentLen = localPtr - tzSym;
|
||||||
|
|
||||||
if (strchr(localPtr + 1, '.') != NULL) {
|
if (strchr(localPtr + 1, '.') != NULL) {
|
||||||
fatalerror("'%s' is a nonsensical reference to a nested local symbol",
|
fatalerror("'%s' is a nonsensical reference to a nested local symbol",
|
||||||
@@ -709,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);
|
||||||
@@ -839,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/extern/err.c
vendored
8
src/extern/err.c
vendored
@@ -33,7 +33,7 @@ void rgbds_vwarnx(const char *fmt, va_list ap)
|
|||||||
putc('\n', stderr);
|
putc('\n', stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
noreturn void rgbds_verr(int status, const char *fmt, va_list ap)
|
noreturn_ void rgbds_verr(int status, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "error");
|
fprintf(stderr, "error");
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
@@ -44,7 +44,7 @@ noreturn void rgbds_verr(int status, const char *fmt, va_list ap)
|
|||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
noreturn void rgbds_verrx(int status, const char *fmt, va_list ap)
|
noreturn_ void rgbds_verrx(int status, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "error");
|
fprintf(stderr, "error");
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
@@ -73,7 +73,7 @@ void rgbds_warnx(const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
noreturn void rgbds_err(int status, const char *fmt, ...)
|
noreturn_ void rgbds_err(int status, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ noreturn void rgbds_err(int status, const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
noreturn void rgbds_errx(int status, const char *fmt, ...)
|
noreturn_ void rgbds_errx(int status, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
|||||||
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 */
|
||||||
|
|||||||
122
src/fix/main.c
122
src/fix/main.c
@@ -207,9 +207,19 @@ int main(int argc, char *argv[])
|
|||||||
err(1, "Error opening file %s", argv[argc - 1]);
|
err(1, "Error opening file %s", argv[argc - 1]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write changes to ROM
|
* Read ROM header
|
||||||
|
*
|
||||||
|
* Offsets in the buffer are 0x100 less than the equivalent in ROM.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
uint8_t header[0x50];
|
||||||
|
|
||||||
|
if (fseek(rom, 0x100, SEEK_SET) != 0)
|
||||||
|
err(1, "Could not locate ROM header");
|
||||||
|
if (fread(header, sizeof(uint8_t), sizeof(header), rom)
|
||||||
|
!= sizeof(header))
|
||||||
|
err(1, "Could not read ROM header");
|
||||||
|
|
||||||
if (fixlogo || trashlogo) {
|
if (fixlogo || trashlogo) {
|
||||||
/*
|
/*
|
||||||
* Offset 0x104–0x133: Nintendo Logo
|
* Offset 0x104–0x133: Nintendo Logo
|
||||||
@@ -232,12 +242,12 @@ int main(int argc, char *argv[])
|
|||||||
0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E
|
0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E
|
||||||
};
|
};
|
||||||
|
|
||||||
if (trashlogo)
|
if (trashlogo) {
|
||||||
for (int i = 0; i < sizeof(ninlogo); i++)
|
for (int i = 0; i < sizeof(ninlogo); i++)
|
||||||
ninlogo[i] = ~ninlogo[i];
|
ninlogo[i] = ~ninlogo[i];
|
||||||
|
}
|
||||||
|
|
||||||
fseek(rom, 0x104, SEEK_SET);
|
memcpy(header + 0x04, ninlogo, sizeof(ninlogo));
|
||||||
fwrite(ninlogo, 1, 48, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settitle) {
|
if (settitle) {
|
||||||
@@ -258,11 +268,10 @@ int main(int argc, char *argv[])
|
|||||||
* characters may conflict with the title.
|
* characters may conflict with the title.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x134, SEEK_SET);
|
int n = snprintf((char *)header + 0x34, 16, "%s", title);
|
||||||
fwrite(title, 1, strlen(title) + 1, rom);
|
|
||||||
|
|
||||||
while (ftell(rom) < 0x143)
|
for (int i = 16; i > n; i--)
|
||||||
fputc(0, rom);
|
header[0x34 + i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setid) {
|
if (setid) {
|
||||||
@@ -272,8 +281,7 @@ int main(int argc, char *argv[])
|
|||||||
* characters).
|
* characters).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x13F, SEEK_SET);
|
memcpy(header + 0x3F, id, 4);
|
||||||
fwrite(id, 1, 4, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colorcompatible) {
|
if (colorcompatible) {
|
||||||
@@ -291,20 +299,12 @@ int main(int argc, char *argv[])
|
|||||||
* may conflict.
|
* may conflict.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t byte;
|
header[0x43] |= 1 << 7;
|
||||||
|
|
||||||
fseek(rom, 0x143, SEEK_SET);
|
|
||||||
byte = fgetc(rom);
|
|
||||||
|
|
||||||
byte |= 1 << 7;
|
|
||||||
if (coloronly)
|
if (coloronly)
|
||||||
byte |= 1 << 6;
|
header[0x43] |= 1 << 6;
|
||||||
|
|
||||||
if (byte & 0x3F)
|
if (header[0x43] & 0x3F)
|
||||||
warnx("Color flag conflicts with game title");
|
warnx("Color flag conflicts with game title");
|
||||||
|
|
||||||
fseek(rom, 0x143, SEEK_SET);
|
|
||||||
fputc(byte, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setnewlicensee) {
|
if (setnewlicensee) {
|
||||||
@@ -320,8 +320,8 @@ int main(int argc, char *argv[])
|
|||||||
* as a Super Game Boy flag.
|
* as a Super Game Boy flag.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x144, SEEK_SET);
|
header[0x44] = newlicensee[0];
|
||||||
fwrite(newlicensee, 1, 2, rom);
|
header[0x45] = newlicensee[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (super) {
|
if (super) {
|
||||||
@@ -340,8 +340,7 @@ int main(int argc, char *argv[])
|
|||||||
if (!setlicensee)
|
if (!setlicensee)
|
||||||
warnx("You should probably set both '-s' and '-l 0x33'");
|
warnx("You should probably set both '-s' and '-l 0x33'");
|
||||||
|
|
||||||
fseek(rom, 0x146, SEEK_SET);
|
header[0x46] = 3;
|
||||||
fputc(3, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setcartridge) {
|
if (setcartridge) {
|
||||||
@@ -351,8 +350,7 @@ int main(int argc, char *argv[])
|
|||||||
* external RAM, timer, rumble, or battery.
|
* external RAM, timer, rumble, or battery.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x147, SEEK_SET);
|
header[0x47] = cartridge;
|
||||||
fputc(cartridge, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resize) {
|
if (resize) {
|
||||||
@@ -366,8 +364,13 @@ int main(int argc, char *argv[])
|
|||||||
int headbyte;
|
int headbyte;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
fseek(rom, 0, SEEK_END);
|
if (fseek(rom, 0, SEEK_END) != 0)
|
||||||
|
err(1, "Could not pad ROM file");
|
||||||
|
|
||||||
romsize = ftell(rom);
|
romsize = ftell(rom);
|
||||||
|
if (romsize == -1)
|
||||||
|
err(1, "Could not pad ROM file");
|
||||||
|
|
||||||
newsize = 0x8000;
|
newsize = 0x8000;
|
||||||
|
|
||||||
headbyte = 0;
|
headbyte = 0;
|
||||||
@@ -380,11 +383,14 @@ int main(int argc, char *argv[])
|
|||||||
warnx("ROM size is bigger than 8MiB");
|
warnx("ROM size is bigger than 8MiB");
|
||||||
|
|
||||||
buf = malloc(newsize - romsize);
|
buf = malloc(newsize - romsize);
|
||||||
memset(buf, padvalue, newsize - romsize);
|
if (buf == NULL)
|
||||||
fwrite(buf, 1, newsize - romsize, rom);
|
errx(1, "Couldn't allocate memory for padded ROM.");
|
||||||
|
|
||||||
fseek(rom, 0x148, SEEK_SET);
|
memset(buf, padvalue, newsize - romsize);
|
||||||
fputc(headbyte, rom);
|
if (fwrite(buf, 1, newsize - romsize, rom) != newsize - romsize)
|
||||||
|
err(1, "Could not pad ROM file");
|
||||||
|
|
||||||
|
header[0x48] = headbyte;
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
@@ -394,8 +400,7 @@ int main(int argc, char *argv[])
|
|||||||
* Offset 0x149: RAM Size
|
* Offset 0x149: RAM Size
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x149, SEEK_SET);
|
header[0x49] = ramsize;
|
||||||
fputc(ramsize, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonjapan) {
|
if (nonjapan) {
|
||||||
@@ -403,8 +408,7 @@ int main(int argc, char *argv[])
|
|||||||
* Offset 0x14A: Non-Japanese Region Flag
|
* Offset 0x14A: Non-Japanese Region Flag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x14A, SEEK_SET);
|
header[0x4A] = 1;
|
||||||
fputc(1, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setlicensee) {
|
if (setlicensee) {
|
||||||
@@ -420,8 +424,7 @@ int main(int argc, char *argv[])
|
|||||||
* See also: the New Licensee ID at 0x144–0x145.
|
* See also: the New Licensee ID at 0x144–0x145.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x14B, SEEK_SET);
|
header[0x4B] = licensee;
|
||||||
fputc(licensee, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setversion) {
|
if (setversion) {
|
||||||
@@ -430,8 +433,7 @@ int main(int argc, char *argv[])
|
|||||||
* Which version of the ROM this is.
|
* Which version of the ROM this is.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fseek(rom, 0x14C, SEEK_SET);
|
header[0x4C] = version;
|
||||||
fputc(version, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fixheadsum || trashheadsum) {
|
if (fixheadsum || trashheadsum) {
|
||||||
@@ -441,17 +443,27 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
uint8_t headcksum = 0;
|
uint8_t headcksum = 0;
|
||||||
|
|
||||||
fseek(rom, 0x134, SEEK_SET);
|
for (int i = 0x34; i < 0x4D; ++i)
|
||||||
for (int i = 0; i < (0x14D - 0x134); ++i)
|
headcksum = headcksum - header[i] - 1;
|
||||||
headcksum = headcksum - fgetc(rom) - 1;
|
|
||||||
|
|
||||||
if (trashheadsum)
|
if (trashheadsum)
|
||||||
headcksum = ~headcksum;
|
headcksum = ~headcksum;
|
||||||
|
|
||||||
fseek(rom, 0x14D, SEEK_SET);
|
header[0x4D] = headcksum;
|
||||||
fputc(headcksum, rom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Before calculating the global checksum, we must write the modified
|
||||||
|
* header to the ROM.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (fseek(rom, 0x100, SEEK_SET) != 0)
|
||||||
|
err(1, "Could not locate header for writing");
|
||||||
|
|
||||||
|
if (fwrite(header, sizeof(uint8_t), sizeof(header), rom)
|
||||||
|
!= sizeof(header))
|
||||||
|
err(1, "Could not write modified ROM header");
|
||||||
|
|
||||||
if (fixglobalsum || trashglobalsum) {
|
if (fixglobalsum || trashglobalsum) {
|
||||||
/*
|
/*
|
||||||
* Offset 0x14E–0x14F: Global Checksum
|
* Offset 0x14E–0x14F: Global Checksum
|
||||||
@@ -459,15 +471,20 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
uint16_t globalcksum = 0;
|
uint16_t globalcksum = 0;
|
||||||
|
|
||||||
rewind(rom);
|
if (fseek(rom, 0, SEEK_SET) != 0)
|
||||||
for (int i = 0; i < 0x14E; ++i)
|
err(1, "Could not start calculating global checksum");
|
||||||
globalcksum += fgetc(rom);
|
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
int byte;
|
int byte;
|
||||||
|
|
||||||
fseek(rom, 0x150, SEEK_SET);
|
while ((byte = fgetc(rom)) != EOF) {
|
||||||
while ((byte = fgetc(rom)) != EOF)
|
if (i != 0x14E && i != 0x14F)
|
||||||
globalcksum += byte;
|
globalcksum += byte;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ferror(rom))
|
||||||
|
err(1, "Could not calculate global checksum");
|
||||||
|
|
||||||
if (trashglobalsum)
|
if (trashglobalsum)
|
||||||
globalcksum = ~globalcksum;
|
globalcksum = ~globalcksum;
|
||||||
@@ -475,9 +492,12 @@ int main(int argc, char *argv[])
|
|||||||
fseek(rom, 0x14E, SEEK_SET);
|
fseek(rom, 0x14E, SEEK_SET);
|
||||||
fputc(globalcksum >> 8, rom);
|
fputc(globalcksum >> 8, rom);
|
||||||
fputc(globalcksum & 0xFF, rom);
|
fputc(globalcksum & 0xFF, rom);
|
||||||
|
if (ferror(rom))
|
||||||
|
err(1, "Could not write global checksum");
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(rom);
|
if (fclose(rom) != 0)
|
||||||
|
err(1, "Could not complete ROM write");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
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
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
opts.hardfix = true;
|
opts.hardfix = true;
|
||||||
|
/* fallthrough */
|
||||||
case 'f':
|
case 'f':
|
||||||
opts.fix = true;
|
opts.fix = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -317,9 +317,9 @@ static void rgba_png_palette(struct PNGImage *img,
|
|||||||
png_color **palette_ptr_ptr, int *num_colors)
|
png_color **palette_ptr_ptr, int *num_colors)
|
||||||
{
|
{
|
||||||
if (png_get_valid(img->png, img->info, PNG_INFO_PLTE))
|
if (png_get_valid(img->png, img->info, PNG_INFO_PLTE))
|
||||||
return rgba_PLTE_palette(img, palette_ptr_ptr, num_colors);
|
rgba_PLTE_palette(img, palette_ptr_ptr, num_colors);
|
||||||
else
|
else
|
||||||
return rgba_build_palette(img, palette_ptr_ptr, num_colors);
|
rgba_build_palette(img, palette_ptr_ptr, num_colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rgba_PLTE_palette(struct PNGImage *img,
|
static void rgba_PLTE_palette(struct PNGImage *img,
|
||||||
@@ -469,8 +469,10 @@ struct ColorWithLuminance {
|
|||||||
|
|
||||||
static int compare_luminance(const void *a, const void *b)
|
static int compare_luminance(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
struct ColorWithLuminance *x = (struct ColorWithLuminance *)a;
|
const struct ColorWithLuminance *x, *y;
|
||||||
struct ColorWithLuminance *y = (struct ColorWithLuminance *)b;
|
|
||||||
|
x = (const struct ColorWithLuminance *)a;
|
||||||
|
y = (const struct ColorWithLuminance *)b;
|
||||||
|
|
||||||
return y->luminance - x->luminance;
|
return y->luminance - x->luminance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ static void do_max_bank(enum eSectionType Type, int32_t nBank)
|
|||||||
if (nBank > MaxVBankUsed)
|
if (nBank > MaxVBankUsed)
|
||||||
MaxVBankUsed = nBank;
|
MaxVBankUsed = nBank;
|
||||||
break;
|
break;
|
||||||
|
case SECT_ROM0:
|
||||||
|
case SECT_WRAM0:
|
||||||
|
case SECT_OAM:
|
||||||
|
case SECT_HRAM:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -317,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;
|
||||||
|
|
||||||
@@ -336,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 */
|
||||||
@@ -370,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",
|
||||||
@@ -494,7 +491,6 @@ void SetLinkerscriptName(char *tzLinkerscriptFile)
|
|||||||
|
|
||||||
void AssignSections(void)
|
void AssignSections(void)
|
||||||
{
|
{
|
||||||
int32_t i;
|
|
||||||
struct sSection *pSection;
|
struct sSection *pSection;
|
||||||
|
|
||||||
MaxBankUsed = 0;
|
MaxBankUsed = 0;
|
||||||
@@ -503,7 +499,7 @@ void AssignSections(void)
|
|||||||
* Initialize the memory areas
|
* Initialize the memory areas
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = 0; i < BANK_INDEX_MAX; i += 1) {
|
for (int32_t i = 0; i < BANK_INDEX_MAX; i += 1) {
|
||||||
BankFree[i] = malloc(sizeof(*BankFree[i]));
|
BankFree[i] = malloc(sizeof(*BankFree[i]));
|
||||||
|
|
||||||
if (!BankFree[i]) {
|
if (!BankFree[i]) {
|
||||||
@@ -617,6 +613,9 @@ void AssignSections(void)
|
|||||||
pSection->nOrg, pSection->nBank);
|
pSection->nOrg, pSection->nBank);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
errx(1, "%s: Internal error: Type %d", __func__,
|
||||||
|
pSection->Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,6 +659,10 @@ void AssignSections(void)
|
|||||||
do_max_bank(pSection->Type, pSection->nBank);
|
do_max_bank(pSection->Type, pSection->nBank);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SECT_ROM0:
|
||||||
|
case SECT_WRAM0:
|
||||||
|
case SECT_OAM:
|
||||||
|
case SECT_HRAM:
|
||||||
default: /* Handle other sections later */
|
default: /* Handle other sections later */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
extern int yyparse();
|
extern int yyparse(void);
|
||||||
|
|
||||||
/* File include stack. */
|
/* File include stack. */
|
||||||
|
|
||||||
@@ -179,13 +179,13 @@ void script_PrintFileStack(void)
|
|||||||
fprintf(stderr, "%s(%d)", linkerscript_path, include_line[i]);
|
fprintf(stderr, "%s(%d)", linkerscript_path, include_line[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
noreturn void script_fatalerror(const char *fmt, ...)
|
noreturn_ void script_fatalerror(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
fprintf(stderr, "error: ");
|
fprintf(stderr, "error: ");
|
||||||
script_PrintFileStack();
|
script_PrintFileStack();
|
||||||
fprintf(stderr, ":\n\t");
|
fprintf(stderr, ":\n ");
|
||||||
vfprintf(stderr, fmt, args);
|
vfprintf(stderr, fmt, args);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ void MapfileWriteSection(const struct sSection *pSect)
|
|||||||
for (i = 0; i < pSect->nNumberOfSymbols; i += 1) {
|
for (i = 0; i < pSect->nNumberOfSymbols; i += 1) {
|
||||||
const struct sSymbol *pSym = pSect->tSymbols[i];
|
const struct sSymbol *pSym = pSect->tSymbols[i];
|
||||||
|
|
||||||
|
/* Don't print '@' */
|
||||||
|
if (strcmp(pSym->pzName, "@") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if ((pSym->pSection == pSect) && (pSym->Type != SYM_IMPORT)) {
|
if ((pSym->pSection == pSect) && (pSym->Type != SYM_IMPORT)) {
|
||||||
if (mf) {
|
if (mf) {
|
||||||
fprintf(mf, " $%04X = %s\n",
|
fprintf(mf, " $%04X = %s\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;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -36,14 +35,14 @@ uint8_t oReadLib;
|
|||||||
*/
|
*/
|
||||||
static int32_t readlong(FILE *f)
|
static int32_t readlong(FILE *f)
|
||||||
{
|
{
|
||||||
int32_t r;
|
uint32_t r;
|
||||||
|
|
||||||
r = fgetc(f);
|
r = ((uint32_t)(uint8_t)fgetc(f));
|
||||||
r |= fgetc(f) << 8;
|
r |= ((uint32_t)(uint8_t)fgetc(f)) << 8;
|
||||||
r |= fgetc(f) << 16;
|
r |= ((uint32_t)(uint8_t)fgetc(f)) << 16;
|
||||||
r |= fgetc(f) << 24;
|
r |= ((uint32_t)(uint8_t)fgetc(f)) << 24;
|
||||||
|
|
||||||
return r;
|
return (int32_t)r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -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 */
|
||||||
|
|||||||
@@ -110,12 +110,9 @@ void Output(void)
|
|||||||
FILE *f_overlay = NULL;
|
FILE *f_overlay = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apply overlay
|
* Load overlay
|
||||||
*/
|
*/
|
||||||
|
|
||||||
f = fopen(tzOutname, "wb");
|
|
||||||
|
|
||||||
if (f != NULL) {
|
|
||||||
if (tzOverlayname) {
|
if (tzOverlayname) {
|
||||||
f_overlay = fopen(tzOverlayname, "rb");
|
f_overlay = fopen(tzOverlayname, "rb");
|
||||||
|
|
||||||
@@ -138,18 +135,28 @@ void Output(void)
|
|||||||
MaxBankUsed = MaxOverlayBank;
|
MaxBankUsed = MaxOverlayBank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write ROM.
|
||||||
|
*/
|
||||||
|
|
||||||
|
f = fopen(tzOutname, "wb");
|
||||||
|
if (f != NULL) {
|
||||||
writehome(f, f_overlay);
|
writehome(f, f_overlay);
|
||||||
for (i = 1; i <= MaxBankUsed; i += 1)
|
for (i = 1; i <= MaxBankUsed; i += 1)
|
||||||
writebank(f, f_overlay, i);
|
writebank(f, f_overlay, i);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (tzOverlayname)
|
|
||||||
fclose(f_overlay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add regular sections
|
* Close overlay
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (tzOverlayname)
|
||||||
|
fclose(f_overlay);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add regular sections to map and sym files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = BANK_INDEX_WRAM0; i < BANK_INDEX_MAX; i++) {
|
for (i = BANK_INDEX_WRAM0; i < BANK_INDEX_MAX; i++) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "link/script.h"
|
#include "link/script.h"
|
||||||
|
|
||||||
int yylex();
|
int yylex(void);
|
||||||
void yyerror(char *);
|
void yyerror(char *);
|
||||||
|
|
||||||
extern int yylineno;
|
extern int yylineno;
|
||||||
@@ -107,8 +107,8 @@ statement:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
extern int yylex();
|
extern int yylex(void);
|
||||||
extern int yyparse();
|
extern int yyparse(void);
|
||||||
|
|
||||||
int yywrap(void)
|
int yywrap(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ void Patch(void)
|
|||||||
/* t contains the destination of the jump */
|
/* t contains the destination of the jump */
|
||||||
t = (int16_t)((t & 0xFFFF) - (nPatchOrg + 1));
|
t = (int16_t)((t & 0xFFFF) - (nPatchOrg + 1));
|
||||||
|
|
||||||
if (t >= -128 && t <= 255) {
|
if (t >= -128 && t <= 127) {
|
||||||
t &= 0xFF;
|
t &= 0xFF;
|
||||||
pSect->pData[pPatch->nOffset] =
|
pSect->pData[pPatch->nOffset] =
|
||||||
(uint8_t)t;
|
(uint8_t)t;
|
||||||
@@ -325,6 +325,8 @@ void Patch(void)
|
|||||||
pPatch->nLineNo);
|
pPatch->nLineNo);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
errx(1, "%s: Internal error.", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
pPatch = pPatch->pNext;
|
pPatch = pPatch->pNext;
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -85,59 +89,59 @@ void script_InitSections(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void script_SetCurrentSectionType(const char *type, uint32_t bank)
|
void script_SetCurrentSectionType(const char *type, uint32_t bank_num)
|
||||||
{
|
{
|
||||||
if (strcmp(type, "ROM0") == 0) {
|
if (strcmp(type, "ROM0") == 0) {
|
||||||
if (bank != 0)
|
if (bank_num != 0)
|
||||||
errx(1, "Trying to assign a bank number to ROM0.\n");
|
errx(1, "Trying to assign a bank number to ROM0.\n");
|
||||||
current_bank = BANK_INDEX_ROM0;
|
current_bank = BANK_INDEX_ROM0;
|
||||||
current_real_bank = 0;
|
current_real_bank = 0;
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(type, "ROMX") == 0) {
|
} else if (strcmp(type, "ROMX") == 0) {
|
||||||
if (bank == 0)
|
if (bank_num == 0)
|
||||||
errx(1, "ROMX index can't be 0.\n");
|
errx(1, "ROMX index can't be 0.\n");
|
||||||
if (bank > BANK_COUNT_ROMX) {
|
if (bank_num > BANK_COUNT_ROMX) {
|
||||||
errx(1, "ROMX index too big (%d > %d).\n", bank,
|
errx(1, "ROMX index too big (%d > %d).\n", bank_num,
|
||||||
BANK_COUNT_ROMX);
|
BANK_COUNT_ROMX);
|
||||||
}
|
}
|
||||||
current_bank = BANK_INDEX_ROMX + bank - 1;
|
current_bank = BANK_INDEX_ROMX + bank_num - 1;
|
||||||
current_real_bank = bank;
|
current_real_bank = bank_num;
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(type, "VRAM") == 0) {
|
} else if (strcmp(type, "VRAM") == 0) {
|
||||||
if (bank >= BANK_COUNT_VRAM) {
|
if (bank_num >= BANK_COUNT_VRAM) {
|
||||||
errx(1, "VRAM index too big (%d >= %d).\n", bank,
|
errx(1, "VRAM index too big (%d >= %d).\n", bank_num,
|
||||||
BANK_COUNT_VRAM);
|
BANK_COUNT_VRAM);
|
||||||
}
|
}
|
||||||
current_bank = BANK_INDEX_VRAM + bank;
|
current_bank = BANK_INDEX_VRAM + bank_num;
|
||||||
current_real_bank = bank;
|
current_real_bank = bank_num;
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(type, "WRAM0") == 0) {
|
} else if (strcmp(type, "WRAM0") == 0) {
|
||||||
if (bank != 0)
|
if (bank_num != 0)
|
||||||
errx(1, "Trying to assign a bank number to WRAM0.\n");
|
errx(1, "Trying to assign a bank number to WRAM0.\n");
|
||||||
|
|
||||||
current_bank = BANK_INDEX_WRAM0;
|
current_bank = BANK_INDEX_WRAM0;
|
||||||
current_real_bank = 0;
|
current_real_bank = 0;
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(type, "WRAMX") == 0) {
|
} else if (strcmp(type, "WRAMX") == 0) {
|
||||||
if (bank == 0)
|
if (bank_num == 0)
|
||||||
errx(1, "WRAMX index can't be 0.\n");
|
errx(1, "WRAMX index can't be 0.\n");
|
||||||
if (bank > BANK_COUNT_WRAMX) {
|
if (bank_num > BANK_COUNT_WRAMX) {
|
||||||
errx(1, "WRAMX index too big (%d > %d).\n", bank,
|
errx(1, "WRAMX index too big (%d > %d).\n", bank_num,
|
||||||
BANK_COUNT_WRAMX);
|
BANK_COUNT_WRAMX);
|
||||||
}
|
}
|
||||||
current_bank = BANK_INDEX_WRAMX + bank - 1;
|
current_bank = BANK_INDEX_WRAMX + bank_num - 1;
|
||||||
current_real_bank = bank;
|
current_real_bank = bank_num;
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(type, "SRAM") == 0) {
|
} else if (strcmp(type, "SRAM") == 0) {
|
||||||
if (bank >= BANK_COUNT_SRAM) {
|
if (bank_num >= BANK_COUNT_SRAM) {
|
||||||
errx(1, "SRAM index too big (%d >= %d).\n", bank,
|
errx(1, "SRAM index too big (%d >= %d).\n", bank_num,
|
||||||
BANK_COUNT_SRAM);
|
BANK_COUNT_SRAM);
|
||||||
}
|
}
|
||||||
current_bank = BANK_INDEX_SRAM + bank;
|
current_bank = BANK_INDEX_SRAM + bank_num;
|
||||||
current_real_bank = bank;
|
current_real_bank = bank_num;
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(type, "OAM") == 0) {
|
} else if (strcmp(type, "OAM") == 0) {
|
||||||
if (bank != 0) {
|
if (bank_num != 0) {
|
||||||
errx(1, "%s: Trying to assign a bank number to OAM.\n",
|
errx(1, "%s: Trying to assign a bank number to OAM.\n",
|
||||||
__func__);
|
__func__);
|
||||||
}
|
}
|
||||||
@@ -145,7 +149,7 @@ void script_SetCurrentSectionType(const char *type, uint32_t bank)
|
|||||||
current_real_bank = 0;
|
current_real_bank = 0;
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(type, "HRAM") == 0) {
|
} else if (strcmp(type, "HRAM") == 0) {
|
||||||
if (bank != 0) {
|
if (bank_num != 0) {
|
||||||
errx(1, "%s: Trying to assign a bank number to HRAM.\n",
|
errx(1, "%s: Trying to assign a bank number to HRAM.\n",
|
||||||
__func__);
|
__func__);
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ REPT NumberOfSymbols ; Number of symbols defined in this object file.
|
|||||||
LONG LineNum ; Line number in the file where the symbol is defined.
|
LONG LineNum ; Line number in the file where the symbol is defined.
|
||||||
|
|
||||||
LONG SectionID ; The section number (of this object file) in which
|
LONG SectionID ; The section number (of this object file) in which
|
||||||
; this symbol is defined.
|
; this symbol is defined. If it doesn't belong to any
|
||||||
|
; specific section (like a constant), this field has
|
||||||
|
; the value -1.
|
||||||
|
|
||||||
LONG Value ; The symbols value. It's the offset into that
|
LONG Value ; The symbols value. It's the offset into that
|
||||||
; symbol's section.
|
; symbol's section.
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
ERROR: divzero-instr.asm(2):
|
ERROR: divzero-instr.asm(2):
|
||||||
division by zero
|
Division by zero
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
ERROR: divzero-section-bank.asm(1):
|
ERROR: divzero-section-bank.asm(1):
|
||||||
division by zero
|
Invalid integer constant
|
||||||
|
ERROR: divzero-section-bank.asm(1):
|
||||||
|
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