Use .Fn for defining functions.

This commit is contained in:
Anthony J. Bentley
2018-07-28 01:47:59 -06:00
parent ab1901eeac
commit 46fcebe2b5

View File

@@ -54,7 +54,7 @@ The syntax to do so is the following one:
.Pp .Pp
This works anywhere in the code except inside of strings. This works anywhere in the code except inside of strings.
To split strings it is needed to use To split strings it is needed to use
.Sy STRCAT .Fn STRCAT
like this: like this:
.Pp .Pp
.Bd -literal -offset indent .Bd -literal -offset indent
@@ -1015,19 +1015,25 @@ it left.
.Pp .Pp
Some things are different for fixed-point math, though, which is why you have Some things are different for fixed-point math, though, which is why you have
the following functions to use: the following functions to use:
.EQ
delim $$
.EN
.Pp .Pp
.Bl -column -offset indent ".Sy String" ".Sy String" .Bl -column -offset indent ".Sy String" ".Sy String"
.It Sy Name Ta Sy Operation .It Sy Name Ta Sy Operation
.It Li DIV(x,y) Ta x/y .It Fn DIV x y Ta $x \[di] y$
.It Li MUL(x,y) Ta x*y .It Fn MUL x y Ta $x \[mu] y$
.It Li SIN(x) Ta sin(x) .It Fn SIN x Ta $sin ( x )$
.It Li COS(x) Ta cos(x) .It Fn COS x Ta $cos ( x )$
.It Li TAN(x) Ta tan(x) .It Fn TAN x Ta $tan ( x )$
.It Li ASIN(x) Ta arcsin(x) .It Fn ASIN x Ta $asin ( x )$
.It Li ACOS(x) Ta arccos(x) .It Fn ACOS x Ta $acos ( x )$
.It Li ATAN(x) Ta arctan(x) .It Fn ATAN x Ta $atan ( x )$
.It Li ATAN2(x,y) Ta Angle between (x,y) and (1,0) .It Fn ATAN2 x y Ta Angle between $( x , y )$ and $( 1 , 0 )$
.El .El
.EQ
delim off
.EN
.Pp .Pp
These functions are extremely useful for automatic generation of various tables. These functions are extremely useful for automatic generation of various tables.
A circle has 65536.0 degrees. A circle has 65536.0 degrees.
@@ -1085,19 +1091,19 @@ This consists of one or more of these function (yes, you can nest them).
Note that some of these functions actually return an integer and can be used as Note that some of these functions actually return an integer and can be used as
part of an integer expression! part of an integer expression!
.Pp .Pp
.Bl -column ".Sy String" ".Sy String" .Bl -column "STRSUB_str,_pos,_len" ".Sy String"
.It Sy Name Ta Ta Ta Sy Operation .It Sy Name Ta Sy Operation
.It Li STRLEN(string) Ta Returns the number of characters in string .It Fn STRLEN string Ta Returns the number of characters in string
.It Li STRCAT(str1,str2) Ta Appends str2 to str1. .It Fn STRCAT str1 str2 Ta Appends str2 to str1.
.It Li STRCMP(str1,str2) Ta Returns negative if str1 is alphabetically lower .It Fn STRCMP str1 str2 Ta Returns negative if str1 is alphabetically lower
than str2, zero if they match, positive if str1 is greater than str2. than str2, zero if they match, positive if str1 is greater than str2.
.It Li STRIN(str1,str2) Ta Returns the position of str2 in str1 or zero if it's .It Fn STRIN str1 str2 Ta Returns the position of str2 in str1 or zero if it's
not present (first character is position 1). not present (first character is position 1).
.It Li STRSUB(str,pos,len) Ta Returns a substring from str starting at pos .It Fn STRSUB str pos len Ta Returns a substring from str starting at pos
(first character is position 1) and with len characters. (first character is position 1) and with len characters.
.It Li STRUPR(str) Ta Converts all characters in str to capitals and returns the .It Fn STRUPR str Ta Converts all characters in str to capitals and returns the
new string. new string.
.It Li STRLWR(str) Ta Converts all characters in str to lower case and returns .It Fn STRLWR str Ta Converts all characters in str to lower case and returns
the new string. the new string.
.El .El
.Pp .Pp
@@ -1134,21 +1140,30 @@ There are a few other functions that do various useful things:
.Pp .Pp
.Bl -column ".Sy String" ".Sy String" .Bl -column ".Sy String" ".Sy String"
.It Sy Name Ta Ta Ta Sy Operation .It Sy Name Ta Ta Ta Sy Operation
.It Li BANK(@/str/lbl) Ta Returns a bank number. .It Fn BANK arg Ta Returns a bank number.
If the argument is the symbol If
.Ar arg
is the symbol
.Ic @ , .Ic @ ,
this function returns the bank of the current section. this function returns the bank of the current section.
If the argument is a string, it returns the bank of the section that has that If
name. .Ar arg
If the argument is a label, it returns the bank number the label is in. is a string, it returns the bank of the section that has that name.
If
.Ar arg
is a label, it returns the bank number the label is in.
For labels, as the linker has to resolve this, it can't be used when the For labels, as the linker has to resolve this, it can't be used when the
expression has to be constant. expression has to be constant.
.It Li DEF(label) Ta Returns TRUE if label has been defined. .It Fn DEF label Ta Returns TRUE if
.It Li HIGH(r16/cnst/lbl) Ta Returns the top 8 bits of the operand if it is a .Ar label
label or constant, or the top 8-bit register if it is a 16-bit register. has been defined.
.It Li LOW(r16/cnst/lbl) Ta Returns the bottom 8 bits of the operand if it is a .It Fn HIGH arg Ta Returns the top 8 bits of the operand if
label or constant, or the bottom 8-bit register if it is a 16-bit register (AF .Ar arg
isn't a valid register for this function). is a label or constant, or the top 8-bit register if it is a 16-bit register.
.It Fn LOW arg Ta Returns the bottom 8 bits of the operand if
.Ar arg
is a label or constant, or the bottom 8-bit register if it is a 16-bit register
(AF isn't a valid register for this function).
.El .El
.Pp .Pp
.Sh MISCELLANEOUS .Sh MISCELLANEOUS