This is the full description of the language used by
.Xrrgbasm1.
The description of the instructions supported by the Game Boy CPU is in
@@ -30,7 +29,6 @@ but any program that processes RGB object files (described in
.Xrrgbds5)
can be used in its place.
.ShSYNTAX
.Pp
The syntax is line‐based, just as in any other assembler, meaning that you do one instruction or pseudo‐op per line:
.Pp
.DlOoArlabelOcOoArinstructionOcOoAr;\commentOc
@@ -47,7 +45,8 @@ The assembler
.Emalways
ignores comments and their contents.
.Pp
There are three syntaxes for comments. The most common is that anything that follows a semicolon
There are three syntaxes for comments.
The most common is that anything that follows a semicolon
.Ql\&;
not inside a string, is a comment until the end of the line.
The second is a block comment, beginning with
@@ -81,7 +80,6 @@ like this:
"world!")
.Ed
.ShEXPRESSIONS
.Pp
An expression can be composed of many things.
Numerical expressions are always evaluated using signed 32-bit math.
Zero is considered to be the only "false" number, all non-zero numbers (including negative) are "true".
@@ -95,9 +93,7 @@ section.
.Pp
The instructions in the macro-language generally require constant expressions.
.SsNumericFormats
.Pp
There are a number of numeric formats.
.Pp
.Bl-column-offsetindent"Fixed point (16.16)""Prefix"
.ItSyFormattypeTaSyPrefixTaSyAcceptedcharacters
.ItHexadecimalTa$Ta0123456789ABCDEF
@@ -128,9 +124,7 @@ is equivalent to
.Pp
You can also use symbols, which are implicitly replaced with their value.
.SsOperators
.Pp
A great number of operators you can use in expressions are available (listed from highest to lowest precedence):
.Pp
.Bl-column-offsetindent"!= == <= >= < >"
.ItSyOperatorTaSyMeaning
.ItLi\&(\&)TaPrecedenceoverride
@@ -176,7 +170,6 @@ and
.Pp
! returns 1 if the operand was 0, and 0 otherwise.
.SsFixed‐pointExpressions
.Pp
Fixed-point numbers are basically normal (32-bit) integers, which count 65536th's instead of entire units, offering better precision than integers but limiting the range of values.
The upper 16 bits are used for the integer part and the lower 16 bits are used for the fraction (65536ths).
Since they are still akin to integers, you can use them in normal integer expressions, and some integer operators like
@@ -191,7 +184,6 @@ The following functions are designed to operate with fixed-point numbers:
When writing text that is meant to be displayed in the Game Boy, the characters used in the source code may have a different encoding than the default of ASCII.
For example, the tiles used for uppercase letters may be placed starting at tile index 128, which makes it difficult to add text strings to the ROM.
.Pp
@@ -334,9 +322,7 @@ This means that any string that the code may want to print as debug information
The output value of a mapping can be 0.
If this happens, the assembler will treat this as the end of the string and the rest of it will be trimmed.
.SsOtherfunctions
.Pp
There are a few other functions that do various useful things:
.Pp
.Bl-column"DEF(label)"
.ItSyNameTaSyOperation
.ItFnBANKargTaReturnsabanknumber.
@@ -365,7 +351,6 @@ String symbols are not expanded within the parentheses.
or 0 if only RGBLINK can compute its value.
.El
.ShSECTIONS
.Pp
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 it.
.Pp
@@ -382,7 +367,6 @@ All other sections must have a unique name, even in different source files, or t
@@ -581,7 +564,6 @@ will push the current section context on the section stack.
can then later be used to restore it.
Useful for defining sections in included files when you don't want to override the section context at the point the file was included.
.SsRAMCode
.Pp
Sometimes you want to have some code in RAM.
But then you can't simply put it in a RAM section, you have to store it in ROM and copy it to RAM at some point.
.Pp
@@ -642,7 +624,6 @@ You cannot nest
.IcLOAD
blocks, nor can you change the current section within them.
.SsUnionizedSections
.Pp
When you're tight on RAM, you may want to define overlapping blocks of variables, as explained in the
.SxUnions
section.
@@ -736,12 +717,11 @@ and the one from
.Qlbar.o
last.
.ShSYMBOLS
.Pp
RGBDS supports several types of symbols:
.Pp
.Bl-hang
.ItSyLabel
Numerical symbol designating a memory location. May or may not have a value known at assembly time.
Numerical symbol designating a memory location.
May or may not have a value known at assembly time.
.ItSyConstant
Numerical symbol whose value has to be known at assembly time.
.ItSyMacro
@@ -861,7 +841,6 @@ str_SIZEOF EQU 259
.Ed
.Pp
There are five commands in the RS group of commands:
.Pp
.Bl-column"RSSET constexpr"
.ItSyCommandTaSyMeaning
.ItIcRSRESETTaEquivalenttoQlRSSET0.
@@ -940,7 +919,6 @@ following the macro's name is required.
Macros can't be exported or imported.
.El
.SsExportingandimportingsymbols
.Pp
Importing and exporting of symbols is a feature that is very useful when your project spans many source files and, for example, you need to jump to a routine defined in another file.
.Pp
Exporting of symbols has to be done manually, importing is done automatically if
@@ -960,7 +938,6 @@ do not use it.
Note also that only exported symbols will appear in symbol and map files produced by
.Xrrgblink1.
.SsPurgingsymbols
.Pp
.IcPURGE
allows you to completely remove a symbol from the symbol table as if it had never existed.
.EmUSEWITHEXTREMECAUTION!!!
@@ -979,9 +956,7 @@ Note that, as an exception, string symbols in the argument list of a
command
.Emwillnotbeexpanded.
.SsPredeclaredSymbols
.Pp
The following symbols are defined by the assembler:
@@ -1006,7 +981,6 @@ The following symbols are defined by the assembler:
.El
.ShDEFININGDATA
.SsDeclaringvariablesinaRAMsection
.Pp
.IcDS
allocates a number of empty bytes.
This is the preferred method of allocating space in a RAM section.
@@ -1027,7 +1001,6 @@ In ROM sections, it will be filled with the value passed to the
command-line option, except when using overlays with
.FlO.
.SsDefiningconstantdata
.Pp
.IcDB
defines a list of bytes that will be stored in the final image.
Ideal for tables and text.
@@ -1079,7 +1052,6 @@ can be used in a
.IcSRAM
section.
.SsIncludingbinaryfiles
.Pp
You probably have some graphics, level data, etc. you'd like to include.
Use
.IcINCBIN
@@ -1101,9 +1073,9 @@ The example below includes 256 bytes from data.bin, starting from byte 78.
INCBIN "data.bin",78,256
.Ed
.Pp
The length argument is optional. If only the start position is specified, the bytes from the start position until the end of the file will be included.
The length argument is optional.
If only the start position is specified, the bytes from the start position until the end of the file will be included.
.SsUnions
.Pp
Unions allow multiple memory allocations to overlap, like unions in C.
This does not increase the amount of memory available, but allows re-using the same memory region for different purposes.
.Pp
@@ -1155,7 +1127,6 @@ like commands (see
.SxDeclaringvariablesinaRAMsection).
.ShTHEMACROLANGUAGE
.SsInvokingmacros
.Pp
You execute the macro by inserting its name.
.Bd-literal-offsetindent
add a,b
@@ -1217,7 +1188,6 @@ Also, a macro can have inside an
.SyEQUS
which references the same macro, which has the same problem.
.Pp
.Pp
It's possible to pass arguments to macros as well!
You retrieve the arguments by using the escape sequences
.Ic\[rs]1
@@ -1306,7 +1276,6 @@ This is the only way of accessing the value of arguments from 10 to 256.
.IcSHIFT
can optionally be given an integer parameter, and will apply the above shifting that number of times.
.SsPrintingthingsduringassembly
.Pp
The next four commands print text and values to the standard output.
Useful for debugging macros, or wherever you may feel the need to tell yourself some important information.
.Bd-literal-offsetindent
@@ -1315,7 +1284,6 @@ PRINTI (2 + 3) / 5
PRINTV $FF00 + $F0
PRINTF MUL(3.14, 3987.0)
.Ed
.Pp
.Bl-inset
.ItIcPRINTT
prints out a string.
@@ -1334,7 +1302,6 @@ prints out a fixed point value.
Be careful that none of those automatically print a line feed; if you need one, use
.IcPRINTT"\[rs]n".
.SsAutomaticallyrepeatingblocksofcode
.Pp
Suppose you want to unroll a time consuming loop without copy-pasting it.
.IcREPT
is here for that purpose.
@@ -1371,7 +1338,6 @@ As in macros, you can also use the escape sequence
.IcREPT
blocks can be nested.
.SsAbortingtheassemblyprocess
.Pp
.IcFAIL
and
.IcWARN
@@ -1392,7 +1358,6 @@ If you need to ensure some assumption is correct when compiling, you can use
and
.IcSTATIC_ASSERT.
Syntax examples are given below:
.Pp
.Bd-literal-offsetindent
Function:
xor a
@@ -1443,7 +1408,6 @@ to be emitted;
.IcFATAL
immediately aborts.
.SsIncludingothersourcefiles
.Pp
Use
.IcINCLUDE
to process another assembler file and then return to the current file when done.
@@ -1459,7 +1423,6 @@ calls infinitely (or until you run out of memory, whichever comes first).
INCLUDE "irq.inc"
.Ed
.SsConditionalassembling
.Pp
The four commands
.IcIF,ELIF,ELSE,
and
@@ -1509,7 +1472,6 @@ Also, if there is more than one
block, all of them but the first one are ignored.
.ShMISCELLANEOUS
.SsChangingoptionswhileassembling
.Pp
.IcOPT
can be used to change some of the options during assembling from within the source, instead of defining them on the command-line.
.Pp
@@ -1539,7 +1501,6 @@ can then later be used to restore them.
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.
The stack's number of entries is limited only by the amount of memory in your machine.
.SsRequestingalignment
.Pp
While
.IcALIGN
as presented in
@@ -1567,7 +1528,6 @@ is a shorthand for
.Xrrgbds7,
.Xrgbz807
.ShHISTORY
.Pp
.Nm
was originally written by Carsten S\(/orensen as part of the ASMotor package,
This toolchain is in development and new features may require adding more information to the current format, or modifying some fields, which would break compatibility with older versions.
.Pp
.ShFILESTRUCTURE
The following types are used:
.Pp
@@ -29,7 +28,6 @@ is an 8‐bit integer.
.ArSTRING
is a 0‐terminated string of
.ArBYTE.
.Pp
.Bd-literal
; Header
@@ -219,8 +217,7 @@ The
In the RGB format, RPN expressions are stored as
.ArBYTENss
with some bytes being special prefixes for integers and symbols.
To get a working ROM image from a single assembly source file:
.Pp
.Bd-literal-offsetindent
$ rgbasm \-o bar.o foo.asm
$ rgblink \-o baz.gb bar.o
@@ -26,7 +25,7 @@ $ rgbfix \-v \-p 0 baz.gb
.Xrrgbds5,
.Xrgbz807
.ShHISTORY
.Bl-ohang
.Bl-item
.It
1997, Carsten S\(/orensen (AKA SurfSmurf) writes ASMotor as a general-purpose
assembler/linker system for DOS/Win32.
@@ -37,8 +36,8 @@ assembly/machine code, and releases this version as RGBDS.
2009, Vegard Nossum adapts the code to be more UNIX-like and releases this
version as rgbds-linux on GitHub.
.It
2010, Anthony J. Bentley forks that repository. The fork becomes the reference
implementation of rgbds.
2010, Anthony J. Bentley forks that repository.
The fork becomes the reference implementation of rgbds.
.It
2017, Bentley's repository is moved to a neutral name.
It is now maintained by a number of contributors at
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.