ref: e771d60ec0b5db03822b8a64ca1f6c92e222fcd1
parent: e2de106d7132914ef387bfcf891551c251e03619
author: Anthony J. Bentley <anthony@anjbe.name>
date: Fri Jul 27 19:58:13 EDT 2018
Eliminate \[dq] escapes and superfluous double quotes. " can be used directly except in macro lines. Also in some situations wrapping with a Dq or Ql macro can be more appropriate.
--- a/src/asm/rgbasm.5
+++ b/src/asm/rgbasm.5
@@ -35,8 +35,11 @@
.Pp
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
-\[dq]\&;\[dq] (that isn't inside a string) is a comment. There is another
-format: anything that follows a \[dq]*\[dq] that is placed right at the start of
+.Ql \&;
+(that isn't inside a string) is a comment. 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
@@ -64,11 +67,12 @@
where to put it.
.Pp
.Bd -literal -offset indent
- SECTION \[dq]CoolStuff\[dq],ROMX
+ SECTION "CoolStuff",ROMX
.Ed
.Pp
-This switches to the section called "CoolStuff" (or creates it if it doesn't
-already exist) and it defines it as a code section.
+This switches to the section called
+.Dq CoolStuff
+(or creates it if it doesn't already exist) and 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.
@@ -153,7 +157,7 @@
bank:
.Pp
.Bd -literal -offset indent
- SECTION \[dq]CoolStuff\[dq],ROMX
+ SECTION "CoolStuff",ROMX
.Ed
.Pp
If it is needed, the following syntax can be used to fix the base address of the
@@ -160,7 +164,7 @@
section:
.Pp
.Bd -literal -offset indent
- SECTION \[dq]CoolStuff\[dq],ROMX[$4567]
+ SECTION "CoolStuff",ROMX[$4567]
.Ed
.Pp
It won't, however, fix the bank number, which is left to the linker.
@@ -167,7 +171,7 @@
If you also want to specify the bank you can do:
.Pp
.Bd -literal -offset indent
- SECTION \[dq]CoolStuff\[dq],ROMX[$4567],BANK[3]
+ 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
@@ -174,7 +178,7 @@
position within the bank, that's also possible:
.Pp
.Bd -literal -offset indent
- SECTION \[dq]CoolStuff\[dq],ROMX,BANK[7]
+ SECTION "CoolStuff",ROMX,BANK[7]
.Ed
.Pp
In addition, you can specify byte alignment for a section.
@@ -188,9 +192,9 @@
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 "OAM Data",WRAM0,ALIGN[8] ; align to 256 bytes
- SECTION \[dq]VRAM Data\[dq],ROMX,BANK[2],ALIGN[4] ; align to 16 bytes
+ SECTION "VRAM Data",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
@@ -370,7 +374,7 @@
COUNTREG EQUS "[hl+]"
ld a,COUNTREG
-PLAYER_NAME EQUS \[dq]\[rs]\[dq]John\[rs]\[dq]\[dq]
+PLAYER_NAME EQUS "\[rs]"John\[rs]""
db PLAYER_NAME
.Ed
.Pp
@@ -381,13 +385,13 @@
.Pp
.Bd -literal -offset indent
ld a,[hl+]
- db \[dq]John\[dq]
+ db "John"
.Ed
.Pp
String-symbols can also be used to define small one-line macros:
.Pp
.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
.Pp
Note that a colon (:) following the label-name is not allowed.
@@ -532,14 +536,14 @@
PRINTT \[rs]1
ENDM
- PrintMacro STRCAT(\[rs]\[dq]Hello\[rs]\[dq]\[rs], \[rs]
- \[rs]\[dq] world\[rs]\[rs]n\[rs]\[dq])
+ PrintMacro STRCAT(\[rs]"Hello\[rs]"\[rs], \[rs]
+ \[rs]" world\[rs]\[rs]n\[rs]")
.Ed
.Pp
.Ic SHIFT
is a special command only available in macros.
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
will get the value of
.Ic \[rs]2 ,
@@ -582,8 +586,8 @@
and macros.
.Pp
.Bd -literal -offset indent
-Kamikaze EQUS \[dq]I don't want to live anymore\[dq]
-AOLer EQUS \[dq]Me too\[dq]
+Kamikaze EQUS "I don't want to live anymore"
+AOLer EQUS "Me too"
PURGE Kamikaze, AOLer
.Ed
.Pp
@@ -623,7 +627,7 @@
Ideal for tables and text (which is not zero-terminated).
.Pp
.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
.Pp
Alternatively, you can use
@@ -681,9 +685,9 @@
to the linker on the command line will be searched.
.Pp
.Bd -literal -offset indent
-INCBIN \[dq]titlepic.bin\[dq]
-INCBIN \[dq]sprites/hero.bin\[dq]\ ; UNIX
-INCBIN \[dq]sprites\[rs]\[rs]hero.bin\[dq]\ ; Windows
+INCBIN "titlepic.bin"
+INCBIN "sprites/hero.bin"\ ; UNIX
+INCBIN "sprites\[rs]\[rs]hero.bin"\ ; Windows
.Ed
.Pp
You can also include only part of a file with
@@ -691,7 +695,7 @@
The example below includes 256 bytes from data.bin starting from byte 78.
.Pp
.Bd -literal -offset indent
-INCBIN \[dq]data.bin\[dq],78,256
+INCBIN "data.bin",78,256
.Ed
.Ss Unions
Unions allow multiple memory allocations to share the same space in memory,
@@ -736,7 +740,7 @@
some important information.
.Pp
.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
PRINTV $FF00 + $F0
PRINTF MUL(3.14, 3987.0)
@@ -821,7 +825,7 @@
calls infinitely (or until you run out of memory, whichever comes first).
.Pp
.Bd -literal -offset indent
- INCLUDE \[dq]irq.inc\[dq]
+ INCLUDE "irq.inc"
.Ed
.Pp
.Ss Conditional assembling
@@ -836,11 +840,11 @@
.Pp
.Bd -literal -offset indent
IF NUM < 0
- PRINTT \[dq]NUM < 0\[rs]n\[dq]
+ PRINTT "NUM < 0\[rs]n"
ELIF NUM == 0
- PRINTT \[dq]NUM == 0\[rs]n\[dq]
+ PRINTT "NUM == 0\[rs]n"
ELSE
- PRINTT \[dq]NUM > 0\[rs]n\[dq]
+ PRINTT "NUM > 0\[rs]n"
ENDC
.Ed
.Pp
@@ -889,7 +893,7 @@
.It
Fixedpoint (16.16): 01234.56789
.It
-Character constant: \[dq]ABYZ\[dq]
+Character constant: "ABYZ"
.It
Gameboy graphics: \`0123
.El
@@ -988,7 +992,7 @@
.Pp
.Ss String Expressions
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
can use within a string:
.Pp
@@ -995,7 +999,7 @@
.Bl -column -offset indent ".Sy String" ".Sy String"
.It Sy String Ta Sy Meaning
.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]\[lC] Ta Curly bracket left
.It Li \[rs]\[rC] Ta Curly bracket right
@@ -1017,7 +1021,8 @@
.Sy \[lC]symbol\[rC]
construct can also be used outside strings.
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 \[lC]symbol\[rC] .
.Pp
Whenever the macro-language expects a string you can actually use a string
expression.