1RGBASM(5) BSD File Formats Manual RGBASM(5)
2
4 rgbasm — language documentation
5
7 This is the full description of the language used by rgbasm(1). The
8 description of the instructions supported by the GameBoy CPU is in
9 gbz80(7).
10
12 Syntax
13 The syntax is line‐based, just as in any other assembler, meaning that
14 you do one instruction or pseudo‐op per line:
15
16 [label] [instruction] [;comment]
17
18 Example:
19
20 John: ld a,87 ;Weee
21
22 All pseudo‐ops, mnemonics and registers (reserved keywords) are case‐
23 insensitive and all labels are case‐sensitive.
24
25 Sections
26 Before you can start writing code, you must define a section. This tells
27 the assembler what kind of information follows and, if it is code, where
28 to put it.
29
30 SECTION "CoolStuff",ROMX
31
32 This switches to the section called "CoolStuff" (or creates it if it
33 doesn't already exist) and it defines it as a code section. All sections
34 assembled at the same time that have the same name, type, etc, are con‐
35 sidered to be the same one, and their code is put together in the object
36 file generated by the assembler. All other sections must have a unique
37 name, even in different source files, or the linker will treat it as an
38 error.
39
40 Possible section types are as follows:
41
42 ROM0 A ROM section. Mapped to memory at $0000–$3FFF (or $0000-$7FFF
43 if tiny ROM mode is enabled in rgblink(1)).
44
45 ROMX A banked ROM section. Mapped to memory at $4000–$7FFF. Valid
46 banks range from 1 to 511. Not available if tiny ROM mode is
47 enabled in rgblink(1).
48
49 VRAM A banked video RAM section. Mapped to memory at $8000–$9FFF.
50 Can only allocate memory, not fill it. Valid banks are 0 and 1
51 but bank 1 isn't available if DMG mode is enabled in rgblink(1).
52
53 SRAM A banked external (save) RAM section. Mapped to memory at
54 $A000–$BFFF. Can only allocate memory, not fill it. Valid banks
55 range from 0 to 15.
56
57 WRAM0 A general-purpose RAM section. Mapped to memory at $C000–$CFFF,
58 or $C000-$DFFF if DMG mode is enabled in rgblink(1). Can only
59 allocate memory, not fill it.
60
61 WRAMX A banked general-purpose RAM section. Mapped to memory at
62 $D000–$DFFF. Can only allocate memory, not fill it. Valid banks
63 range from 1 to 7. Not available if DMG mode is enabled in
64 rgblink(1).
65
66 OAM An object attributes RAM section. Mapped to memory at
67 $FE00-$FE9F. Can only allocate memory, not fill it.
68
69 HRAM A high RAM section. Mapped to memory at $FF80–$FFFE. Can only
70 allocate memory, not fill it.
71
72 NOTE: If you use this method of allocating HRAM the assembler
73 will NOT choose the short addressing mode in the LD instructions
74 LD [$FF00+n8],A and LD A,[$FF00+n8] because the actual address
75 calculation is done by the linker. If you find this undesirable
76 you can use RSSET / RB / RW instead or use the LDH [$FF00+n8],A
77 and LDH A,[$FF00+n8] syntax instead. This forces the assembler
78 to emit the correct instruction and the linker to check if the
79 value is in the correct range.
80
81 A section is usually defined as a floating one, but the code can restrict
82 where the linker can place it.
83
84 If a section is defined with no indications, it is a floating section.
85 The linker will decide where to place it in the final binary and it has
86 no obligation to follow any specific rules. The following example
87 defines a section that can be placed anywhere in any ROMX bank:
88
89 SECTION "CoolStuff",ROMX
90
91 If it is needed, the following syntax can be used to fix the base address
92 of the section:
93
94 SECTION "CoolStuff",ROMX[$4567]
95
96 It won't, however, fix the bank number, which is left to the linker. If
97 you also want to specify the bank you can do:
98
99 SECTION "CoolStuff",ROMX[$4567],BANK[3]
100
101 And if you only want to force the section into a certain bank, and not
102 it's position within the bank, that's also possible:
103
104 SECTION "CoolStuff",ROMX,BANK[7]
105
106 In addition, you can specify byte alignment for a section. This ensures
107 that the section starts at a memory address where the given number of
108 least-significant bits are 0. This can be used along with BANK, if
109 desired. However, if an alignment is specified, the base address must be
110 left unassigned. This can be useful when using DMA to copy data or when
111 it is needed to align the start of an array to 256 bytes to optimize the
112 code that accesses it.
113
114 SECTION "OAM Data",WRAM0,ALIGN[8]; align to 256 bytes
115
116 SECTION "VRAM Data",ROMX,BANK[2],ALIGN[4]; align to 16 bytes
117
118 HINT: If you think this is a lot of typing for doing a simple ORG type
119 thing you can quite easily write an intelligent macro (called ORG for
120 example) that uses @ for the section name and determines correct section
121 type etc as arguments for SECTION.
122
123 POPS and PUSHS provide the interface to the section stack. PUSHS will
124 push the current section context on the section stack. POPS can then
125 later be used to restore it. Useful for defining sections in included
126 files when you don't want to destroy the section context for the program
127 that included your file. The number of entries in the stack is limited
128 only by the amount of memory in your machine.
129
130 Sections can also be placed by using a linkerscript file. The format is
131 described in rgblink(5). They allow the user to place floating sections
132 in the desired bank in the order specified in the script. This is useful
133 if the sections can't be placed at an address manually because the size
134 may change, but they have to be together.
135
137 Symbols
138 RGBDS supports several types of symbols:
139
140 Label Used to assign a memory location with a name
141
142 EQUate Give a constant a name.
143
144 SET Almost the same as EQUate, but you can change the value of a SET
145 during assembling.
146
147 Structure (the RS group) Define a structure easily.
148
149 String equate (EQUS) Give a frequently used string a name. Can also be
150 used as a mini-macro, like #define in C.
151
152 MACRO A block of code or pseudo instructions that you invoke like any
153 other mnemonic. You can give them arguments too.
154
155 A symbol cannot have the same name as a reserved keyword.
156
157 Label
158
159 One of the assembler's main tasks is to keep track of addresses
160 for you so you don't have to remember obscure numbers but can
161 make do with a meaningful name, a label.
162
163 This can be done in a number of ways:
164
165 GlobalLabel
166 AnotherGlobal:
167 .locallabel
168 .yet_a_local:
169 AnotherGlobal.with_another_local:
170 ThisWillBeExported:: ;note the two colons
171 ThisWillBeExported.too::
172
173 In the line where a label is defined there musn't be any white‐
174 space before it. Local labels are only accessible within the
175 scope they are defined. A scope starts after a global label and
176 ends at the next global label. Declaring a label (global or
177 local) with :: does an EXPORT at the same time. Local labels can
178 be declared as scope.local or simply as as .local. If the former
179 notation is used, the scope must be the actual current scope.
180
181 Labels will normally change their value during the link process
182 and are thus not constant. The exception is the case in which
183 the base address of a section is fixed, so the address of the
184 label is known at assembly time.
185
186 The subtraction of two labels is only constant (known at assembly
187 time) if they are two local labels that belong to the same scope,
188 or they are two global labels that belong to sections with fixed
189 base addresses.
190
191 EQU
192
193 EQUates are constant symbols. They can, for example, be used for
194 things such as bit-definitions of hardware registers.
195
196 EXIT_OK EQU $00
197 EXIT_FAILURE EQU $01
198
199 Note that a colon (:) following the label-name is not allowed.
200 EQUates cannot be exported and imported. They don't change their
201 value during the link process.
202
203 SET
204
205 SETs are similar to EQUates. They are also constant symbols in
206 the sense that their values are defined during the assembly
207 process. These symbols are normally used in macros.
208
209 ARRAY_SIZE EQU 4
210 COUNT SET 2
211 COUNT SET ARRAY_SIZE+COUNT
212
213 Note that a colon (:) following the label-name is not allowed.
214 SETs cannot be exported and imported. Alternatively you can use
215 = as a synonym for SET.
216
217 COUNT = 2
218
219 RSSET, RERESET, RB, RW
220
221 The RS group of commands is a handy way of defining structures:
222
223 RSRESET
224 str_pStuff RW 1
225 str_tData RB 256
226 str_bCount RB 1
227 str_SIZEOF RB 0
228
229 The example defines four equated symbols:
230
231 str_pStuff = 0
232 str_tData = 2
233 str_bCount = 258
234 str_SIZEOF = 259
235
236 There are four commands in the RS group of commands:
237
238 Command Meaning
239 RSRESET Resets the _RS counter to zero.
240 RSSET constexpr Sets the _RS counter to constexpr.
241 RB constexpr Sets the preceding symbol to _RS and adds
242 constexpr to _RS.
243 RW constexpr Sets the preceding symbol to _RS and adds
244 constexpr * 2 to _RS.
245 RL constexpr Sets the preceding symbol to _RS and adds
246 constexpr * 4 to _RS.
247
248 Note that a colon (:) following the symbol-name is not allowed.
249 RS symbols cannot be exported and imported. They don't change
250 their value during the link process.
251
252 EQUS
253
254 EQUS is used to define string-symbols. Wherever the assembler
255 meets a string symbol its name is replaced with its value. If
256 you are familiar with C you can think of it as the same as
257 #define.
258
259 COUNTREG EQUS "[hl+]"
260 ld a,COUNTREG
261
262 PLAYER_NAME EQUS "\"John\""
263 db PLAYER_NAME
264
265 Note that : following the label-name is not allowed, and that
266 strings must be quoted to be useful.
267
268 This will be interpreted as:
269
270 ld a,[hl+]
271 db "John"
272
273 String-symbols can also be used to define small one-line macros:
274
275 PUSHA EQUS "push af\npush bc\npush de\npush hl\n"
276
277 Note that a colon (:) following the label-name is not allowed.
278 String equates can't be exported or imported.
279
280 Important note: An EQUS can be expanded to a string that contains
281 another EQUS and it will be expanded as well. This means that,
282 if you aren't careful, you may trap the assembler into an infi‐
283 nite loop if there's a circular dependency in the expansions.
284 Also, a MACRO can have inside an EQUS which references the same
285 MACRO, which has the same problem.
286
287 MACRO
288
289 One of the best features of an assembler is the ability to write
290 macros for it. Macros also provide a method of passing arguments
291 to them and they can then react to the input using IF-constructs.
292
293 MyMacro: MACRO
294 ld a,80
295 call MyFunc
296 ENDM
297
298 Note that a colon (:) following the macro-name is required.
299 Macros can't be exported or imported. It's valid to call a macro
300 from a macro (yes, even the same one).
301
302 The above example is a very simple macro. You execute the macro
303 by typing its name.
304
305 add a,b
306 ld sp,hl
307 MyMacro ;This will be expanded
308 sub a,87
309
310 When the assembler meets MyMacro it will insert the macrodefini‐
311 tion (the text enclosed in MACRO / ENDM).
312
313 Suppose your macro contains a loop.
314
315 LoopyMacro: MACRO
316 xor a,a
317 .loop ld [hl+],a
318 dec c
319 jr nz,.loop
320 ENDM
321
322 This is fine. That is, if you only use the macro once per scope.
323 To get around this problem there is a special label string equate
324 called \@ that you can append to your labels and it will then
325 expand to a unique string.
326
327 \@ also works in REPT-blocks should you have any loops there.
328
329 LoopyMacro: MACRO
330 xor a,a
331 .loop\@ ld [hl+],a
332 dec c
333 jr nz,.loop\@
334 ENDM
335
336 Important note: Since a MACRO can call itself (or a different
337 MACRO that calls the first one) there can be problems of circular
338 dependency. They trap the assembler in an infinite loop, so you
339 have to be careful when using recursion with MACROs. Also, a
340 MACRO can have inside an EQUS which references the same MACRO,
341 which has the same problem.
342
343 Macro Arguments
344
345 I'd like LoopyMacro a lot better if I didn't have to pre-load the
346 registers with values and then call it. What I'd like is the
347 ability to pass it arguments and it then loaded the registers
348 itself.
349
350 And I can do that. In macros you can get the arguments by using
351 the special macro string equates \1 through \9, \1 being the
352 first argument specified on the calling of the macro.
353
354 LoopyMacro: MACRO
355 ld hl,\1
356 ld c,\2
357 xor a,a
358 .loop\@ ld [hl+],a
359 dec c
360 jr nz,.loop\@
361 ENDM
362
363 Now I can call the macro specifying two arguments. The first
364 being the address and the second being a bytecount. The macro
365 will then reset all bytes in this range.
366
367 LoopyMacro MyVars,54
368
369 Arguments are passed as string equates. There's no need to
370 enclose them in quotes. An expression will not be evaluated
371 first but passed directly. This means that it's probably a very
372 good idea to use brackets around \1 to \9 if you perform further
373 calculations on them. For instance, if you pass 1 + 2 as the
374 first argument and then do PRINTV \1 * 2 you will get the value 5
375 on screen and not 6 as you might have expected.
376
377 In reality, up to 256 arguments can be passed to a macro, but you
378 can only use the first 9 like this. If you want to use the rest,
379 you need to use the keyword SHIFT.
380
381 SHIFT is a special command only available in macros. Very useful
382 in REPT-blocks. It will "shift" the arguments by one "to the
383 left". \1 will get the value of \2, \2 will get the value in \3
384 and so forth.
385
386 This is the only way of accessing the value of arguments from 10
387 to 256.
388
389 Exporting and importing symbols
390 Importing and exporting of symbols is a feature that is very useful when
391 your project spans many source-files and, for example, you need to jump
392 to a routine defined in another file.
393
394 Exporting of symbols has to be done manually, importing is done automati‐
395 cally if the assembler doesn't know where a symbol is defined.
396
397 EXPORT label [, label , ...]
398
399 The assembler will make label accessible to other files during the link
400 process.
401
402 GLOBAL label [, label , ...]
403
404 If label is defined during the assembly it will be exported, if not, it
405 will be imported. Handy (very!) for include-files. Note that, since
406 importing is done automatically, this keyword has the same effect as
407 EXPORT.
408
409 Purging symbols
410 PURGE allows you to completely remove a symbol from the symbol table as
411 if it had never existed. USE WITH EXTREME CAUTION!!! I can't stress
412 this enough, you seriously need to know what you are doing. DON'T purge
413 symbol that you use in expressions the linker needs to calculate. In
414 fact, it's probably not even safe to purge anything other than string
415 symbols and macros.
416
417 Kamikaze EQUS "I don't want to live anymore"
418 AOLer EQUS "Me too"
419 PURGE Kamikaze, AOLer
420
421 Note that string symbols that are part of a PURGE command WILL NOT BE
422 EXPANDED as the ONLY exception to this rule.
423
424 Predeclared Symbols
425 The following symbols are defined by the assembler:
426
427 Type Name Contents
428 EQU @ PC value
429 EQU _PI Fixed point π
430 SET _RS _RS Counter
431 EQU _NARG Number of arguments passed to macro
432 EQU __LINE__ The current line number
433 EQUS __FILE__ The current filename
434 EQUS __DATE__ Today's date
435 EQUS __TIME__ The current time
436 EQUS __ISO_8601_LOCAL__ ISO 8601 timestamp (local)
437 EQUS __ISO_8601_UTC__ ISO 8601 timestamp (UTC)
438 EQU __UTC_YEAR__ Today's year
439 EQU __UTC_MONTH__ Today's month number, 1-12
440 EQU __UTC_DAY__ Today's day of the month, 1-31
441 EQU __UTC_HOUR__ Current hour, 0-23
442 EQU __UTC_MINUTE__ Current minute, 0-59
443 EQU __UTC_SECOND__ Current second, 0-59
444
446 Defining constant data
447 DB defines a list of bytes that will be stored in the final image. Ideal
448 for tables and text.
449
450 DB 1,2,3,4,"This is a string"
451
452 Alternatively, you can use DW to store a list of words. Strings are not
453 allowed as arguments to DW.
454
455 You can also use DB and DW without arguments. This works exactly like DS
456 1 and DS 2 respectively. Consequently, DB and DW can be used in a WRAM0
457 / WRAMX / HRAM / VRAM / SRAM section.
458
459 Declaring variables in a RAM section
460 DS allocates a number of bytes. The content is undefined. This is the
461 preferred method of allocationg space in a RAM section. You can, how‐
462 ever, use DB and DW without any arguments instead.
463
464 DS str_SIZEOF ;allocate str_SIZEOF bytes
465
466 Including binary files
467 You probably have some graphics you'd like to include. Use INCBIN to
468 include a raw binary file as it is. If the file isn't found in the cur‐
469 rent directory, the include-path list passed to the linker on the command
470 line will be searched.
471
472 INCBIN "titlepic.bin"
473 INCBIN "sprites/hero.bin" ; UNIX
474 INCBIN "sprites\\hero.bin" ; Windows
475
476 You can also include only part of a file with INCBIN. The example below
477 includes 256 bytes from data.bin starting from byte 78.
478
479 INCBIN "data.bin",78,256
480
482 Printing things during assembly
483 These three instructions type text and values to stdout. Useful for
484 debugging macros or wherever you may feel the need to tell yourself some
485 important information.
486
487 PRINTT "I'm the greatest programmer in the whole wide world\n"
488 PRINTV (2+3)/5
489 PRINTF MUL(3.14,3987.0)
490
491 PRINTT prints out a string.
492
493 PRINTV prints out an integer value or, as in the example, the result of a
494 calculation. Unsurprisingly, you can also print out a constant symbols
495 value.
496
497 PRINTF prints out a fixed point value.
498
499 Automatically repeating blocks of code
500 Suppose you're feeling lazy and you want to unroll a time consuming loop.
501 REPT is here for that purpose. Everything between REPT and ENDR will be
502 repeated a number of times just as if you done a copy/paste operation
503 yourself. The following example will assemble add a,c four times:
504
505 REPT 4
506 add a,c
507 ENDR
508
509 You can also use REPT to generate tables on the fly:
510
511 ; --
512 ; -- Generate a 256 byte sine table with values between 0 and 128
513 ; --
514 ANGLE SET 0.0
515 REPT 256
516 DB (MUL(64.0,SIN(ANGLE))+64.0)>>16
517 ANGLE SET ANGLE+256.0
518 ENDR
519
520 REPT is also very useful in recursive macros and, as in macros, you can
521 also use the special label operator \@. REPT-blocks can be nested.
522
523 Aborting the assembly process
524 FAIL and WARN can be used to print errors and warnings respectively dur‐
525 ing the assembly process. This is especially useful for macros that get
526 an invalid argument. FAIL and WARN take a string as the only argument
527 and they will print this string out as a normal error with a line number.
528
529 FAIL stops assembling immediately while WARN shows the message but con‐
530 tinues afterwards.
531
532 Including other source files
533 Use INCLUDE to process another assembler-file and then return to the cur‐
534 rent file when done. If the file isn't found in the current directory
535 the include-path list will be searched. You may nest INCLUDE calls in‐
536 finitely (or until you run out of memory, whichever comes first).
537
538 INCLUDE "irq.inc"
539
540 Conditional assembling
541 The three commands IF, ELSE and ENDC are used to conditionally assemble
542 parts of your file. This is a powerful feature commonly used in macros.
543
544 IF 2+2==4
545 PRINTT "2+2==4\n"
546 ELSE
547 PRINTT "2+2!=4\n"
548 ENDC
549
550 The ELSE block is optional. IF / ELSE / ENDC blocks can be nested.
551
552 Integer and Boolean expressions
553 An expression can be composed of many things. Expressions are always
554 evaluated using signed 32-bit math.
555
556 The most basic expression is just a single number.
557
558 Numeric Formats
559
560 There are a number of numeric formats.
561
562 - Hexadecimal: $0123456789ABCDEF. Case-insensitive
563 - Decimal: 0123456789
564 - Octal: &01234567
565 - Binary: %01
566 - Fixedpoint (16.16): 01234.56789
567 - Character constant: "ABYZ"
568 - Gameboy graphics: `0123
569
570 The last one, Gameboy graphics, is quite interesting and useful. The
571 values are actually pixel values and it converts the “chunky” data to
572 “planar” data as used in the Gameboy.
573
574 DW `01012323
575
576 Admittedly, an expression with just a single number is quite boring. To
577 spice things up a bit there are a few operators you can use to perform
578 calculations between numbers.
579
580 Operators
581
582 A great number of operators you can use in expressions are available
583 (listed in order of precedence):
584
585 Operator Meaning
586 () Precedence override
587 FUNC() Function call
588 ~ + - Unary not/plus/minus
589 * / % Multiply/divide/modulo
590 << >> Shift left/right
591 & | ^ Binary and/or/xor
592 + - Add/subtract
593 != == <= Boolean comparison
594 >= < > Boolean comparison (Same precedence as the others)
595 && || Boolean and/or
596 ! Unary Boolean not
597
598 The result of the boolean operators is zero if when FALSE and non-zero
599 when TRUE. It is legal to use an integer as the condition for IF blocks.
600 You can use symbols instead of numbers in your expression if you wish.
601
602 An expression is said to be constant when it doesn't change its value
603 during linking. This basically means that you can't use labels in those
604 expressions. The instructions in the macro-language all require expres‐
605 sions that are constant. The only exception is the subtraction of labels
606 in the same section or labels that belong to sections with a fixed base
607 addresses, all of which must be defined in the same source file (the cal‐
608 culation cannot be passed to the object file generated by the assembler).
609 In this case, the result is a constant that can be calculated at assembly
610 time.
611
612 Fixed‐point Expressions
613 Fixed point constants are basically normal 32-bit constants where the
614 upper 16 bits are used for the integer part and the lower 16 bits are
615 used for the fraction (65536ths). This means that you can use them in
616 normal integer expression, and some integer operators like plus and minus
617 don't care whether the operands are integer or fixed-point. You can eas‐
618 ily convert a fixed-point number to an integer by shifting it right 16
619 bits. It follows that you can convert an integer to a fixed-point number
620 by shifting it left.
621
622 Some things are different for fixed-point math, though, which is why you
623 have the following functions to use:
624
625 Name Operation
626 DIV(x,y) x/y
627 MUL(x,y) x*y
628 SIN(x) sin(x)
629 COS(x) cos(x)
630 TAN(x) tan(x)
631 ASIN(x) arcsin(x)
632 ACOS(x) arccos(x)
633 ATAN(x) arctan(x)
634 ATAN2(x,y) Angle between (x,y) and (1,0)
635
636 These functions are extremely useful for automatic generation of various
637 tables. A circle has 65536.0 degrees. Sine values are between [-1.0;
638 1.0].
639
640 ; --
641 ; -- Generate a 256 byte sine table with values between 0 and 128
642 ; --
643 ANGLE SET 0.0
644 REPT 256
645 DB (MUL(64.0,SIN(ANGLE))+64.0)>>16
646 ANGLE SET ANGLE+256.0
647 ENDR
648
649 String Expressions
650 The most basic string expression is any number of characters contained in
651 double quotes ("for instance"). Like in C, the escape character is \,
652 and there are a number of commands you can use within a string:
653
654 String Meaning
655 \\ Backslash
656 \" Double quote
657 \, Comma
658 \{ Curly bracket left
659 \} Curly bracket right
660 \n Newline ($0A)
661 \t Tab ($09)
662 \1 - \9 Macro argument (Only the body of a macros)
663 \@ Label name suffix (Only in the body of macros and repts)
664
665 A funky feature is {symbol} withing a string. This will examine the type
666 of the symbol and insert its value accordingly. If symbol is a string
667 symbol, the symbols value is simply copied. If it's a numeric symbol,
668 the value is converted to hexadecimal notation and inserted as a string.
669
670 HINT: The {symbol} construct can also be used outside strings. The sym‐
671 bol's value is again inserted as a string. This is just a short way of
672 doing "{symbol}".
673
674 Whenever the macro-language expects a string you can actually use a
675 string expression. This consists of one or more of these function (yes,
676 you can nest them). Note that some of these functions actually return an
677 integer and can be used as part of an integer expression!
678
679 Name Operation
680 STRLEN(string) Returns the number of characters in string
681 STRCAT(str1,str2) Appends str2 to str1.
682 STRCMP(str1,str2) Returns negative if str1 is alphabetically lower than
683 str2, zero if they match, positive if str1 is greater
684 than str2.
685 STRIN(str1,str2) Returns the position of str2 in str1 or zero if it's
686 not present (first character is position 1).
687 STRSUB(str,pos,len) Returns a substring from str starting at pos (first
688 character is position 1) and with len characters.
689 STRUPR(str) Converts all characters in str to capitals and
690 returns the new string.
691 STRLWR(str) Converts all characters in str to lower case and
692 returns the new string.
693
694 Other functions
695 There are a few other functions that do various useful things:
696
697 Name Operation
698 BANK(label) Returns the bank number label is in. The linker will
699 have to resolve this so it can't be used when the
700 expression has to be constant.
701 DEF(label) Returns TRUE if label has been defined.
702 HIGH(r16/cnst/lbl) Returns the top 8 bits of the operand if it is a
703 label or constant, or the top 8-bit register if it is
704 a 16-bit register.
705 LOW(r16/cnst/lbl) Returns the bottom 8 bits of the operand if it is a
706 label or constant, or the bottom 8-bit register if it
707 is a 16-bit register (AF isn't a valid register for
708 this function).
709
711 Changing options while assembling
712 OPT can be used to change some of the options during assembling the
713 source instead of defining them on the commandline.
714
715 OPT takes a comma-seperated list of options as its argument:
716
717 PUSHO
718 OPT g.oOX ;Set the GB graphics constants to use these characters
719 DW `..ooOOXX
720 POPO
721 DW `00112233
722
723 The options that OPT can modify are currently: b, e and g.
724
725 POPO and PUSHO provide the interface to the option stack. PUSHO will
726 push the current set of options on the option stack. POPO can then later
727 be used to restore them. Useful if you want to change some options in an
728 include file and you don't want to destroy the options set by the program
729 that included your file. The stacks number of entries is limited only by
730 the amount of memory in your machine.
731
733 @
734 __DATE__
735 __FILE__
736 __ISO_8601_LOCAL__
737 __ISO_8601_UTC__
738 __LINE__
739 __TIME__
740 _NARG
741 _PI
742 _RS
743 ACOS
744 ASIN
745 ATAN
746 ATAN2
747 BANK
748 COS
749 DB
750 DEF
751 DIV
752 DS
753 DW
754 ELSE
755 ENDC
756 ENDM
757 ENDR
758 EQU
759 EQUS
760 EXPORT
761 FAIL
762 GLOBAL
763 HIGH
764 HRAM
765 IF
766 INCBIN
767 INCLUDE
768 LOW
769 MACRO
770 MUL
771 OPT
772 POPO
773 POPS
774 PRINTF
775 PRINTT
776 PRINTV
777 PURGE
778 PUSHO
779 PUSHS
780 REPT
781 RB
782 RL
783 ROM0
784 ROMX
785 RSRESET
786 RSSET
787 RW
788 SECTION
789 SET
790 SHIFT
791 SIN
792 SRAM
793 STRCAT
794 STRCMP
795 STRIN
796 STRLEN
797 STRLWR
798 STRSUB
799 STRUPR
800 TAN
801 VRAM
802 WRAM0
803 WRAMX
804 WARN
805
807 rgbasm(1), rgblink(1), rgblink(5), rgbds(5), rgbds(7), gbz80(7)
808
810 rgbds was originally written by Carsten Sørensen as part of the ASMotor
811 package, and was later packaged in RGBDS by Justin Lloyd. It is now
812 maintained by a number of contributors at .:
813 https://github.com/rednex/rgbds
814
815RGBDS Manual April 17, 2017 RGBDS Manual