RGBASM(1)
π rgbasm β Game Boy assembler π
β¨ from the General Commands Manual β¨
okay so this is the whole vibe of rgbasm(1), and if you're here you're probably trying to turn your assembly source into a Game Boy object file. Which, honestly? Iconic. Let's get into it, bestie. π
β¨ NAME β¨
rgbasm β Game Boy assembler. Short, sweet, main character energy. π
πΈ SYNOPSIS πΈ
rgbasm [-EhVw] [-v [-v ...]] [-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
π¦ DESCRIPTION π¦
The rgbasm program creates an RGB object file from an assembly source file. The object file format is documented in rgbds(5). That's the whole description, but like... it's doing a lot. π
π ARGUMENTS π
okay so 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. iykyk.
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. so maybe don't do that unless you're feeling chaotic.
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. slay.
The following options are accepted:
-B param,--backtrace paramβ Configures how location backtraces are printed if warnings or errors occur. This flag may be specified multiple times with different parameters that combine meaningfully. If param is a positive number, it specifies the maximum backtrace depth, abbreviating deeper ones. Other valid parameter values are the following:0β Do not limit the maximum backtrace depth; this is the default.allβ Force all locations to be printed, even "quiet" ones (see βExcluding locations from backtracesβ inrgbasm(5)for details).no-allβ Do not print "quieted" locations in backtraces; this is the default.collapseβ Print all locations on one line.no-collapseβ Print one location per line; this is the default.
-b chars,--binary-digits charsβ Allow two characters to be used for binary constants in addition to the default0and1. Valid characters are numbers other than0and1, letters,.,#, or@.--color whenβ Specify when to highlight warning and error messages with color:always,never, orauto.autodetermines whether to use colors based on theNO_COLOR: https://no-color.org/orFORCE_COLOR: https://force-color.org/environment variables, or whether the output is to a TTY.-D name[=value],--define name[=value]β Add a string symbol to the compiled source code. This is equivalent toname EQUS "value"in code, orname EQUS "1"if value is not specified.-E,--export-allβ Export all labels, including unreferenced and local labels.-g chars,--gfx-chars charsβ Allow four characters to be used for graphics constants in addition to the default0,1,2, and3. Valid characters are numbers other than0to3, letters,.,#, or@. The defaults are0123.-h,--helpβ Print help text for the program and exit. (Help text wraps to the value of theCOLUMNSenvironment variable if that is defined as nonzero; or else to the console window width if output is to a TTY.)-I path,--include pathβ Add a new βinclude pathβ; path must point to a directory. When anyINCLUDE(including the implicit one from-P),INCBIN, orREADFILEis attempted,rgbasmfirst 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β Writemake(1)dependencies to depend_file.-MGβ To be used in conjunction with-M. This makesrgbasmassume that missing files are auto-generated: when anyINCLUDE(including the implicit one from-P),INCBIN, orREADFILEis attempted on a non-existent file, it is added as a dependency, thenrgbasmexits normally or continues processing (depending on whether-MCwas enabled) instead of erroring out. This feature is used in automatic updating of Makefiles.-MCβ Implies-MG. This makesrgbasmcontinue 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 anIFcondition to take a different branch.-MPβ When enabled, this adds a phony target to the rules emitted by-Mfor each dependency other than the main file. This preventsmake(1)from erroring out when dependency files are deleted.-MT target_fileβ Add a target to the rules emitted by-M. The exact string provided will be written, including spaces and special characters.
-MT fileA -MT fileB
is equivalent to
-MT 'fileA fileB'
If neither this nor -MQ is specified, the output file name is used.
-MQ target_fileβ Same as-MT, but additionally escapes any specialmake(1)characters, essentially$.-o out_file,--output out_fileβ Write an object file to the given filename.-P include_file,--preinclude include_fileβ Pre-include a file. This acts as if aINCLUDE "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_valueβ Use this as the value forDSdirectives in ROM sections, unless overridden. The default is0x00.-Q fix_precision,--q-precision fix_precisionβ Use this as the precision of fixed-point numbers after the decimal point, unless they specify their own precision. The default is16, so fixed-point numbers areQ16.16(since they are 32-bit integers). The argument may start with a.to match the Q notation, for example,-Q .16.-r recursion_depth,--recursion-depth recursion_depthβ Specifies the recursion depth past whichrgbasmwill assume being in an infinite loop. The default is64.-s features:state_file,--state features:state_fileβ Write the specified features to state_file, based on the final state ofrgbasmat the end of its input. The expected features are a comma-separated subset of the following:equβ Write all numeric constants asdef name equ value.varβ Write all variables asdef name = value.equsβ Write all string constants asdef name equs "value".charβ Write all characters ascharmap name, value.macroβ Write all macros asmacro name ... endm.allβ Acts likeequ,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β Print the version of the program and exit.-v,--verboseβ Be verbose. The verbosity level is increased by one each time the flag is specified, with each level including the previous:- Print the
rgbasmconfiguration before taking actions. - Print a notice before significant actions.
- Print some of the actions' intermediate results.
- Print some internal debug information.
- Print detailed internal information.
- Print the
The verbosity level does not go past 6.
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β Set warning flag warning. A warning message will be printed if warning is an unknown warning flag. See the βDIAGNOSTICSβ section for a list of warnings.-wβ Disable all warning output, even when turned into errors.-X max_errors,--max-errors max_errorsβ If more than this number of errors (not warnings) occur, then abort the assembly process;-X 0disables this behavior. The default is100ifrgbasmis printing errors to a terminal, and0otherwise.@at_fileβ Read more options and arguments from a file, as if its contents were given on the command line. Arguments are separated by whitespace or newlines. Lines starting with a hash sign (#) 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.
π DIAGNOSTICS π
Okay so listen β warnings are these lil diagnostic messages that are like "hey bestie, this might be a little wrong" but they don't necessarily ruin the whole assembling thing. Think of them as a friend going "girlβ¦" instead of a full intervention. π The options below change how warnings get handled.
-Werrorβ turns every warning into a full-on error. Dramatic, but valid. You can negate it with-Wno-errorso nothing gets turned into an error.-Werror=β turns one specific warning or meta warning into an error. You just slap the warning's name on the end (like-Werror=obsolete) and boom, that warning is implicitly enabled and promoted to error status. Negate it with-Wno-error=and you stop a specific warning from becoming an error, even if-Werroris already doing its thing. π«Ά
β¨ the meta warnings β¨
These are the "meta" warnings β they're not one warning, they're a whole collection of other warnings. If a specific warning gets toggled by both a meta flag and a specific one, the more specific one takes priority. And if it's still a tie? Position on the command-line decides, and the last one takes effect. Periodt. π
-Wallβ enables warnings that are likely to indicate an error or just undesired behavior, and that can easily be fixed. The "please just be normal" pack.-Wextraβ enables extra warnings that are less likely to pose a problem, but that you may still want. The "hmm, maybe?" pack.-Weverythingβ enables literally every warning. No cap. Literally all of them.
π the actual warning flags π
So these are the real warning flags; with each description, the corresponding flag is included right there. Note that every one of these 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. Yes, alphabetically. We're cute and organised. π
-Wno-assertβ warns whenWARN-type assertions fail. (See "Aborting the assembly process" inrgbasm(5)forASSERT.)-Wbackwards-forβ warns whenFORloops have their start and stop values switched according to the step value. This one's enabled by-Wall.-Wbuiltin-argsβ warns about incorrect arguments to built-in functions, likeSTRSLICE()with indexes outside of the string's bounds. Enabled by-Wall.-Wcharmap-redefβ warns when you re-define a charmap mapping. Rude. This is enabled by-Wall.-Wdivβ warns when you divide the smallest negative integer (-2**31) by-1, which yields itself due to integer overflow. Math said no. π-Wempty-data-directiveβ warns whenDB,DW, orDLis used without an argument in a ROM section. Enabled by-Wall.-Wempty-macro-argβ warns when a macro argument is empty. Enabled by-Wextra.-Wempty-strrplβ warns whenSTRRPL()is called with an empty string as its second argument (the substring to replace). Enabled by-Wall.-Wexport-undefinedβ warns when exporting an undefined symbol. Enabled by-Wall.-Wno-large-constantβ warns when a constant too large to fit in a signed 32-bit integer shows up.-Wmacro-shiftβ warns when shifting macro arguments past their limits. Enabled by-Wextra.-Wno-nested-commentβ warns when the block comment start sequence/*is found inside of a block comment. Block comments cannot be nested, bestie β the first*/will end the whole comment. π-Wno-obsoleteβ warns when obsolete features are encountered, which have been deprecated and may later be removed. Use the new thing, it's giving main character energy.-Wnumeric-string=β warns when a multi-character string is treated as a number.-Wnumeric-string=0or-Wno-numeric-stringdisables this warning.-Wnumeric-string=1or just-Wnumeric-stringwarns about strings longer than four characters, since four or fewer characters fit within a 32-bit integer.-Wnumeric-string=2warns about any multi-character string. Pick your level of pickiness. π-Wpurge=β warns when purging symbols which are likely to have been necessary.-Wpurge=0or-Wno-purgedisables this warning.-Wpurge=1warns when purging any exported symbol (regardless of type).-Wpurge=2or just-Wpurgealso warns when purging any label (even if not exported). Choices, choices.-Wshiftβ warns when shifting right a negative value. Use a division by2**Ninstead. Trust.-Wshift-amountβ warns when a shift's operand is negative or greater than32.-Wtruncation=β warns when an implicit truncation (for example,dbto an 8-bit value) loses some bits.-Wtruncation=0or-Wno-truncationdisables this warning.-Wtruncation=1or just-Wtruncationwarns when an N-bit value is2**Nor greater, or less than-2**N.-Wtruncation=2also warns when an N-bit value is less than-2**(N-1), which will not fit in two's complement encoding. Bits are getting lost bestie, we must report it. π«Ά-Wunmapped-char=β warns when a character goes through charmap conversion but has no defined mapping.-Wunmapped-char=0or-Wno-unmapped-chardisables this warning.-Wunmapped-char=1or just-Wunmapped-charonly warns if the active charmap is not empty.-Wunmapped-char=2warns if the active charmap is empty, and/or is not the default charmapmain. The ladder of "how much do I care". β¨-Wunmatched-directiveβ warns when aPUSHC,PUSHO, orPUSHSdirective does not have a correspondingPOPC,POPO, orPOPS. This warning is enabled by-Wextra.-Wunterminated-loadβ warns when aLOADblock is not terminated by anENDL. Enabled by-Wextra.-Wno-userβ warns when theWARNbuilt-in is executed. (See "Aborting the assembly process" inrgbasm(5)forWARN.)
πΈ EXAMPLES πΈ
You can assemble a source file in two ways, and both are iconic in their own right.
The straightforward way:
$ rgbasm -o bar.o foo.asm
The pipes way:
$ cat foo.asm | rgbasm -o bar.o -
$ rgbasm -o bar.o - < foo.asm
Now, the resulting object file is not yet a usable ROM image β it must first be run through rgblink(1) and then rgbfix(1). It's a whole journey, not a one-step situation. π¦
Writing the final assembler state to a file:
$ rgbasm -s all:state.dump.asm foo.asm
Or to multiple files:
$ rgbasm -s equ,var:numbers.dump.asm -s equs:strings.dump.asm foo.asm
π BUGS π
Found a bug or a mistake in this documentation? Please report it on GitHub, we're literally right here:
https://github.com/gbdev/rgbds/issues
π SEE ALSO π
rgbasm(5), rgblink(1), rgbfix(1), rgbgfx(1), gbz80(7), rgbasm-old(5), rgbds(5), rgbds(7)
π HISTORY π
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. Look at the legacy, we love to see it. π
Okay that's the whole page bestie, go assemble something gorgeous. π β¨
Debian build, dated September 22, 2026 β RGBASM(1), slay.
π¦ where this page comes from
- arch rolling: rgbds 1.0.4-1 Β· MIT
- nixpkgs unstable: rgbds 1.0.4
- π the page's license: MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms