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.
This commit is contained in:
Anthony J. Bentley
2018-07-27 23:58:13 -06:00
parent e2de106d71
commit e771d60ec0

View File

@@ -35,8 +35,11 @@ and all labels are casesensitive.
.Pp .Pp
There are two syntaxes for comments. In both cases, a comment ends at the end of 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 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 .Ql \&;
format: anything that follows a \[dq]*\[dq] that is placed right at the start of (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 a line is a comment. The assembler removes all comments from the code before
doing anything else. doing anything else.
.Pp .Pp
@@ -64,11 +67,12 @@ This tells the assembler what kind of information follows and, if it is code,
where to put it. where to put it.
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
SECTION \[dq]CoolStuff\[dq],ROMX SECTION "CoolStuff",ROMX
.Ed .Ed
.Pp .Pp
This switches to the section called "CoolStuff" (or creates it if it doesn't This switches to the section called
already exist) and it defines it as a code section. .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 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 considered to be the same one, and their code is put together in the object file
generated by the assembler. generated by the assembler.
@@ -153,28 +157,28 @@ The following example defines a section that can be placed anywhere in any ROMX
bank: bank:
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
SECTION \[dq]CoolStuff\[dq],ROMX SECTION "CoolStuff",ROMX
.Ed .Ed
.Pp .Pp
If it is needed, the following syntax can be used to fix the base address of the If it is needed, the following syntax can be used to fix the base address of the
section: section:
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
SECTION \[dq]CoolStuff\[dq],ROMX[$4567] SECTION "CoolStuff",ROMX[$4567]
.Ed .Ed
.Pp .Pp
It won't, however, fix the bank number, which is left to the linker. It won't, however, fix the bank number, which is left to the linker.
If you also want to specify the bank you can do: If you also want to specify the bank you can do:
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
SECTION \[dq]CoolStuff\[dq],ROMX[$4567],BANK[3] SECTION "CoolStuff",ROMX[$4567],BANK[3]
.Ed .Ed
.Pp .Pp
And if you only want to force the section into a certain bank, and not it's And if you only want to force the section into a certain bank, and not it's
position within the bank, that's also possible: position within the bank, that's also possible:
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
SECTION \[dq]CoolStuff\[dq],ROMX,BANK[7] SECTION "CoolStuff",ROMX,BANK[7]
.Ed .Ed
.Pp .Pp
In addition, you can specify byte alignment for a section. In addition, you can specify byte alignment for a section.
@@ -188,9 +192,9 @@ This can be useful when using DMA to copy data or when it is needed to align the
start of an array to 256 bytes to optimize the code that accesses it. start of an array to 256 bytes to optimize the code that accesses it.
.Pp .Pp
.Bd -literal -offset indent .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 .Ed
.Pp .Pp
HINT: If you think this is a lot of typing for doing a simple HINT: If you think this is a lot of typing for doing a simple
@@ -370,7 +374,7 @@ If you are familiar with C you can think of it as the same as #define.
COUNTREG EQUS "[hl+]" COUNTREG EQUS "[hl+]"
ld a,COUNTREG ld a,COUNTREG
PLAYER_NAME EQUS \[dq]\[rs]\[dq]John\[rs]\[dq]\[dq] PLAYER_NAME EQUS "\[rs]"John\[rs]""
db PLAYER_NAME db PLAYER_NAME
.Ed .Ed
.Pp .Pp
@@ -381,13 +385,13 @@ This will be interpreted as:
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
ld a,[hl+] ld a,[hl+]
db \[dq]John\[dq] db "John"
.Ed .Ed
.Pp .Pp
String-symbols can also be used to define small one-line macros: String-symbols can also be used to define small one-line macros:
.Pp .Pp
.Bd -literal -offset indent .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 .Ed
.Pp .Pp
Note that a colon (:) following the label-name is not allowed. Note that a colon (:) following the label-name is not allowed.
@@ -532,14 +536,14 @@ PrintMacro : MACRO
PRINTT \[rs]1 PRINTT \[rs]1
ENDM ENDM
PrintMacro STRCAT(\[rs]\[dq]Hello\[rs]\[dq]\[rs], \[rs] PrintMacro STRCAT(\[rs]"Hello\[rs]"\[rs], \[rs]
\[rs]\[dq] world\[rs]\[rs]n\[rs]\[dq]) \[rs]" world\[rs]\[rs]n\[rs]")
.Ed .Ed
.Pp .Pp
.Ic SHIFT .Ic SHIFT
is a special command only available in macros. is a special command only available in macros.
Very useful in REPT-blocks. 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 .Ic \[rs]1
will get the value of will get the value of
.Ic \[rs]2 , .Ic \[rs]2 ,
@@ -582,8 +586,8 @@ In fact, it's probably not even safe to purge anything other than string symbols
and macros. and macros.
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
Kamikaze EQUS \[dq]I don't want to live anymore\[dq] Kamikaze EQUS "I don't want to live anymore"
AOLer EQUS \[dq]Me too\[dq] AOLer EQUS "Me too"
PURGE Kamikaze, AOLer PURGE Kamikaze, AOLer
.Ed .Ed
.Pp .Pp
@@ -623,7 +627,7 @@ defines a list of bytes that will be stored in the final image.
Ideal for tables and text (which is not zero-terminated). Ideal for tables and text (which is not zero-terminated).
.Pp .Pp
.Bd -literal -offset indent .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 .Ed
.Pp .Pp
Alternatively, you can use Alternatively, you can use
@@ -681,9 +685,9 @@ If the file isn't found in the current directory, the include-path list passed
to the linker on the command line will be searched. to the linker on the command line will be searched.
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
INCBIN \[dq]titlepic.bin\[dq] INCBIN "titlepic.bin"
INCBIN \[dq]sprites/hero.bin\[dq]\ ; UNIX INCBIN "sprites/hero.bin"\ ; UNIX
INCBIN \[dq]sprites\[rs]\[rs]hero.bin\[dq]\ ; Windows INCBIN "sprites\[rs]\[rs]hero.bin"\ ; Windows
.Ed .Ed
.Pp .Pp
You can also include only part of a file with You can also include only part of a file with
@@ -691,7 +695,7 @@ You can also include only part of a file with
The example below includes 256 bytes from data.bin starting from byte 78. The example below includes 256 bytes from data.bin starting from byte 78.
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
INCBIN \[dq]data.bin\[dq],78,256 INCBIN "data.bin",78,256
.Ed .Ed
.Ss Unions .Ss Unions
Unions allow multiple memory allocations to share the same space in memory, Unions allow multiple memory allocations to share the same space in memory,
@@ -736,7 +740,7 @@ Useful for debugging macros or wherever you may feel the need to tell yourself
some important information. some important information.
.Pp .Pp
.Bd -literal -offset indent .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 PRINTI (2 + 3) / 5
PRINTV $FF00 + $F0 PRINTV $FF00 + $F0
PRINTF MUL(3.14, 3987.0) PRINTF MUL(3.14, 3987.0)
@@ -821,7 +825,7 @@ You may nest
calls infinitely (or until you run out of memory, whichever comes first). calls infinitely (or until you run out of memory, whichever comes first).
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
INCLUDE \[dq]irq.inc\[dq] INCLUDE "irq.inc"
.Ed .Ed
.Pp .Pp
.Ss Conditional assembling .Ss Conditional assembling
@@ -836,11 +840,11 @@ This is a powerful feature commonly used in macros.
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
IF NUM < 0 IF NUM < 0
PRINTT \[dq]NUM < 0\[rs]n\[dq] PRINTT "NUM < 0\[rs]n"
ELIF NUM == 0 ELIF NUM == 0
PRINTT \[dq]NUM == 0\[rs]n\[dq] PRINTT "NUM == 0\[rs]n"
ELSE ELSE
PRINTT \[dq]NUM > 0\[rs]n\[dq] PRINTT "NUM > 0\[rs]n"
ENDC ENDC
.Ed .Ed
.Pp .Pp
@@ -889,7 +893,7 @@ Binary: %01
.It .It
Fixedpoint (16.16): 01234.56789 Fixedpoint (16.16): 01234.56789
.It .It
Character constant: \[dq]ABYZ\[dq] Character constant: "ABYZ"
.It .It
Gameboy graphics: \`0123 Gameboy graphics: \`0123
.El .El
@@ -988,14 +992,14 @@ ANGLE SET ANGLE+256.0
.Pp .Pp
.Ss String Expressions .Ss String Expressions
The most basic string expression is any number of characters contained in double 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 Like in C, the escape character is \[rs], and there are a number of commands you
can use within a string: can use within a string:
.Pp .Pp
.Bl -column -offset indent ".Sy String" ".Sy String" .Bl -column -offset indent ".Sy String" ".Sy String"
.It Sy String Ta Sy Meaning .It Sy String Ta Sy Meaning
.It Li \[rs]\[rs] Ta Backslash .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], Ta Comma
.It Li \[rs]\[lC] Ta Curly bracket left .It Li \[rs]\[lC] Ta Curly bracket left
.It Li \[rs]\[rC] Ta Curly bracket right .It Li \[rs]\[rC] Ta Curly bracket right
@@ -1017,7 +1021,8 @@ HINT: The
.Sy \[lC]symbol\[rC] .Sy \[lC]symbol\[rC]
construct can also be used outside strings. construct can also be used outside strings.
The symbol's value is again inserted as a string. 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 .Pp
Whenever the macro-language expects a string you can actually use a string Whenever the macro-language expects a string you can actually use a string
expression. expression.