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
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 @@ This tells the assembler what kind of information follows and, if it is code,
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,28 +157,28 @@ The following example defines a section that can be placed anywhere in any ROMX
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
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.
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
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 @@ 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.
.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 @@ If you are familiar with C you can think of it as the same as #define.
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 @@ This will be interpreted as:
.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 @@ PrintMacro : MACRO
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 @@ In fact, it's probably not even safe to purge anything other than string symbols
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 @@ defines a list of bytes that will be stored in the final image.
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 @@ 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.
.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 @@ You can also include only part of a file with
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 @@ Useful for debugging macros or wherever you may feel the need to tell yourself
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 @@ You may nest
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 @@ This is a powerful feature commonly used in macros.
.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 @@ Binary: %01
.It
Fixedpoint (16.16): 01234.56789
.It
Character constant: \[dq]ABYZ\[dq]
Character constant: "ABYZ"
.It
Gameboy graphics: \`0123
.El
@@ -988,14 +992,14 @@ ANGLE SET ANGLE+256.0
.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
.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 @@ HINT: The
.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.