rgbasm |
[-EhVvw] [-B
param] [-b
chars] [--color
when] [-D
name[=value]]
[-g chars]
[-I path]
[-M depend_file]
[-MG] [-MC]
[-MP] [-MT
target_file] [-MQ
target_file] [-o
out_file] [-P
include_file] [-p
pad_value] [-Q
fix_precision] [-r
recursion_depth] [-s
features:state_file]
[-W warning]
[-X max_errors]
asmfile |
The rgbasm program creates an RGB object
file from an assembly source file. The object file format is documented in
rgbds(5).
rgbasm accepts the usual short and long
options, such as -V and
--version. Options later in the command line
override those set earlier, except for when duplicate options are considered
an error. Options can be abbreviated as long as the abbreviation is
unambiguous: --verb is
--verbose, but --ver is
invalid because it could also be --version.
Unless otherwise noted, passing
‘-’ (a single dash) as a file name
makes rgbasm use standard input (for input files) or
standard output (for output files). To suppress this behavior, and open a
file in the current directory actually called
‘-’, pass
‘./-’ instead. Using standard input or
output for more than one file in a single command may produce unexpected
results.
rgbasm accepts decimal, hexadecimal,
octal, and binary for numeric option arguments. Decimal numbers are written
as usual; hexadecimal numbers must be prefixed with either
‘$’ or
‘0x’; octal numbers must be prefixed
with either ‘&’ or
‘0o’; and binary numbers must be
prefixed with either ‘%’ or
‘0b’. (The prefixes
‘$’ and
‘&’ will likely need escaping or
quoting to avoid being interpreted by the shell.) Leading zeros (after the
base prefix, if any) are accepted, and letters are not case-sensitive. For
example, all of these are equivalent:
‘42’,
‘042’,
‘0x2A’,
‘0X2A’,
‘0x2a’,
‘&52’,
‘0o52’,
‘0O052’,
‘0b00101010’,
‘0B101010’.
The following options are accepted:
-B
param, --backtrace
param0allno-allcollapseno-collapse-b
chars, --binary-digits
chars--color
whenalways’,
‘never’, or
‘auto’.
‘auto’ determines whether to use
colors based on the
‘NO_COLOR’
or
‘FORCE_COLOR’
environment variables, or whether the output is to a TTY.-D
name[=value],
--define
name[=value]name
EQUS
"value"’
in code, or ‘name
EQUS
"1"’ if
value is not specified.-E,
--export-all-g
chars, --gfx-chars
chars-h,
--help-I
path, --include
pathINCLUDE (including
the implicit one from -P),
INCBIN, or READFILE is
attempted, rgbasm first looks up the provided path
from its working directory; if this fails, it tries again from each of the
“include path” directories, in the order they were
provided.-M
depend_file, --dependfile
depend_file-MG-M. This makes
rgbasm assume that missing files are
auto-generated: when any INCLUDE (including the
implicit one from -P),
INCBIN, or READFILE is
attempted on a non-existent file, it is added as a dependency, then
rgbasm exits normally or continues processing
(depending on whether -MC was enabled) instead of
erroring out. This feature is used in automatic updating of
Makefiles.-MC-MG. This makes
rgbasm continue processing after a non-existent
dependency file, instead of exiting. Note that this is
not
recommended if any non-existent dependencies would have influenced
subsequent processing, e.g. by causing an IF
condition to take a different branch.-MP-M for each dependency other than the main file.
This prevents make(1) from erroring out when dependency
files are deleted.-MT
target_file-M. The exact
string provided will be written, including spaces and special characters.
-MT
fileA -MT
fileB-MT
'fileA fileB'-MQ is specified, the output
file name is used.-MQ
target_file-MT, but additionally escapes any special
make(1) characters, essentially ‘$’.-o
out_file, --output
out_file-P
include_file, --preinclude
include_fileINCLUDE
"include_file"’ was read
before the input asmfile. Multiple files can be
pre-included in the order they were provided.-p
pad_value, --pad-value
pad_valueDS directives in ROM
sections, unless overridden. The default is 0x00.-Q
fix_precision, --q-precision
fix_precision.’ to match the Q
notation, for example, ‘-Q
.16’.-r
recursion_depth,
--recursion-depth
recursion_depthrgbasm
will assume being in an infinite loop. The default is 64.-s
features:state_file,
--state
features:state_filergbasm at the end of its input. The expected
features are a comma-separated subset of the
following:
equdef
name equ
value’.vardef
name =
value’.equsdef
name equs
"value"’.charcharmap
name,
value’.macromacro
name ...
endm’.allequ,var,equs,char,macro.This flag may be specified multiple times with different feature subsets to write them to different files (see EXAMPLES below).
-V,
--version-v,
--verbosergbasm configuration before taking
actions.Note that verbose output is only intended to be consumed by humans, and may change without notice between RGBDS releases; relying on those for scripts is not advised.
-W
warning, --warning
warning-w-X
max_errors, --max-errors
max_errors-X 0
disables this behavior. The default is 100 if
rgbasm is printing errors to a terminal, and 0
otherwise.#’) are considered comments and
ignored.
No shell processing is performed, such as wildcard
or variable expansion. There is no support for escaping or quoting
whitespace to be included in arguments. The standard
‘--’ to stop option processing
also disables at-file processing. Note that while
‘--’ can be used
inside an
at-file, it only disables option processing within that at-file, and
processing continues in the parent scope.
Warnings are diagnostic messages that indicate possibly erroneous behavior that does not necessarily compromise the assembling process. The following options alter the way warnings are processed.
-Werror-Wno-error to prevent turning all warnings into
errors.-Werror=-Werror=obsolete), and this
warning is implicitly enabled and turned into an error. This can be
negated as -Wno-error= to prevent turning a
specified warning into an error, even if -Werror
is in effect.The following warnings are “meta” warnings, that enable a collection of other warnings. If a specific warning is toggled via a meta flag and a specific one, the more specific one takes priority. The position on the command-line acts as a tie breaker, the last one taking effect.
-Wall-Wextra-WeverythingThe following warnings are actual warning flags; with each
description, the corresponding warning flag is included. Note that each of
these flags also has a negation (for example,
-Wobsolete enables the warning that
-Wno-obsolete disables; and
-Wall enables every warning that
-Wno-all disables). Only the non-default flag is
listed here. Ignoring the “no-” prefix, entries are listed
alphabetically.
-Wno-assertWARN-type
assertions fail. (See “Aborting the assembly process” in
rgbasm(5) for ASSERT).-Wbackwards-forFOR loops have their start and stop
values switched according to the step value. This warning is enabled by
-Wall.-Wbuiltin-argsSTRSLICE() with indexes outside of the string's
bounds. This warning is enabled by -Wall.-Wcharmap-redef-Wall.-Wdiv-Wempty-data-directiveDB, DW, or
DL is used without an argument in a ROM section.
This warning is enabled by -Wall.-Wempty-macro-arg-Wextra.-Wempty-strrplSTRRPL() is called with an empty string
as its second argument (the substring to replace). This warning is enabled
by -Wall.-Wexport-undefined-Wall.-Wno-large-constant-Wmacro-shift-Wextra.-Wno-nested-comment/*’ is found inside of a block
comment. Block comments cannot be nested, so the first
‘*/’ will end the whole
comment.-Wno-obsolete-Wnumeric-string=-Wnumeric-string=0 or
-Wno-numeric-string disables this warning.
-Wnumeric-string=1 or just
-Wnumeric-string warns about strings longer than
four characters, since four or fewer characters fit within a 32-bit
integer. -Wnumeric-string=2 warns about any
multi-character string.-Wpurge=-Wpurge=0 or -Wno-purge
disables this warning. -Wpurge=1 warns when
purging any exported symbol (regardless of type).
-Wpurge=2 or just -Wpurge
also warns when purging any label (even if not exported).-Wshift-Wshift-amount-Wtruncation=db
to an 8-bit value) loses some bits. -Wtruncation=0
or -Wno-truncation disables this warning.
-Wtruncation=1 or just
-Wtruncation warns when an N-bit value is 2**N or
greater, or less than -2**N. -Wtruncation=2 also
warns when an N-bit value is less than -2**(N-1), which will not fit in
two's complement encoding.-Wunmapped-char=-Wunmapped-char=0 or
-Wno-unmapped-char disables this warning.
-Wunmapped-char=1 or just
-Wunmapped-char only warns if the active charmap
is not empty. -Wunmapped-char=2 warns if the
active charmap is empty, and/or is not the default charmap
‘main’.-Wunmatched-directivePUSHC, PUSHO,
or PUSHS directive does not have a corresponding
POPC, POPO, or
POPS. This warning is enabled by
-Wextra.-Wunterminated-loadLOAD block is not terminated by an
ENDL. This warning is enabled by
-Wextra.-Wno-userWARN built-in is executed. (See
“Aborting the assembly process” in
rgbasm(5) for WARN).You can assemble a source file in two ways.
Straightforward way:
$ rgbasm -o bar.o
foo.asmPipes way:
$ cat foo.asm | rgbasm -o bar.o
-$ rgbasm -o bar.o - <
foo.asmThe resulting object file is not yet a usable ROM image—it must first be run through rgblink(1) and then rgbfix(1).
Writing the final assembler state to a file:
$ rgbasm -s all:state.dump.asm
foo.asmOr to multiple files:
$ rgbasm -s equ,var:numbers.dump.asm
-s equs:strings.dump.asm foo.asmPlease report bugs or mistakes in this documentation on GitHub.
rgbasm(5), rgblink(1), rgbfix(1), rgbgfx(1), gbz80(7), rgbasm-old(5), rgbds(5), rgbds(7)
rgbasm was originally written by
Carsten Sørensen as part of the ASMotor
package, and was later repackaged in RGBDS by Justin
Lloyd. It is now maintained by a number of contributors at
https://github.com/gbdev/rgbds.