1.EQ 2delim $$ 3.EN 4.SH 1 "Statements" 5.pp 6A source program is composed of a sequence of 7.i statements . 8Statements are separated either by new-lines 9or by semicolons. 10There are two kinds of statements: null statements 11and keyword statements. 12Either kind of statement may be preceded by 13one or more labels. 14.SH 2 "Named Global Labels" 15.pp 16A global label consists of a name followed 17by a colon. 18The effect of a name label is to assign the current 19value and type of the location counter 20to the name. 21An error is indicated in pass 1 if the 22name is already defined; 23an error is indicated in pass 2 if the 24value assigned changes the definition 25of the label. 26.pp 27A global label is referenced by its name. 28.pp 29Global labels beginning with a 30.q "\|L\|" 31are discarded unless the 32.b \-L 33option 34is in effect. 35.SH 2 "Numeric Local Labels" 36.pp 37A numeric label consists of a digit $0$ to $9$ 38followed by a colon. 39Such a label serves to define temporary symbols of the form 40.q "$n roman b$" 41and 42.q "$n roman f$" , 43where $n$ 44is the digit of the label. 45As in the case of name labels, 46a numeric label assigns 47the current value and type of the location counter 48to the temporary symbol. 49However, several numeric labels with the same digit 50may be used within the same assembly. 51References to symbols of the form 52.q "$n roman b$" 53refer to the first numeric label 54.q "$n$:" 55.i b ackwards 56from the reference; 57.q "$n roman f$" 58symbols refer to the first numeric label 59.q "$n$:" 60.i f orwards 61from the reference. 62Such numeric labels conserve the inventive powers 63of the human programmer. 64.pp 65For various reasons, 66.i as 67turns local labels into labels of the form 68$roman L n roman ".\*(DL" m$. 69Although unlikely, 70these generated labels may conflict 71with programmer defined labels. 72.SH 2 "Null statements" 73.pp 74A null statement is an empty statement ignored by the assembler. 75A null statement may be labeled, however. 76.SH 2 "Keyword statements" 77.pp 78A keyword statement begins with one of the many predefined 79keywords known to 80.i as ; 81the syntax of the remainder of the statement depends 82on the keyword. 83All instruction opcodes are keywords. 84The remaining keywords are assembler pseudo-operations, 85also called 86.i directives . 87The pseudo-operations are listed in \(sc8, 88together with the syntax they require. 89.SH 1 "Expressions" 90.pp 91An expression is a sequence of symbols representing a value. 92Its constituents are identifiers, 93constants, 94operators, 95and parentheses. 96Each expression has a type. 97.pp 98All operators in expressions are fundamentally binary in 99nature. 100Arithmetic is two's complement and has 32 bits of precision. 101.i As 102can not do arithmetic on floating point numbers, quad or octal 103precision scalar numbers. 104There are four levels of precedence, 105listed here from 106lowest precedence level to highest: 107.(b 108.TS 109center; 110c l. 111precedence operators 112_ 113binary $+$, $-$ 114binary \fI\(bv\fP\|, $&$, $italic "^"$, $!$ 115binary $*$, $/$, $%$, 116unary $-$, $italic "~"$ 117.TE 118.)b 119.pp 120All operators of the same precedence are evaluated strictly left to right, 121except for the evaluation order enforced by parenthesis. 122.SH 2 "Expression Operators" 123.pp 124The operators are: 125.(b 126.TS 127center; 128c l. 129operator meaning 130_ 131$+$ addition 132$-$ (binary) subtraction 133$*$ multiplication 134$/$ division 135$%$ modulo 136$-$ (unary) 2's complement 137$&$ bitwise and 138$\(bv$ bitwise or 139$italic "^"$ bitwise exclusive or 140$!$ bitwise or not 141$italic "~"$ bitwise 1's complement 142$>$ logical right shift 143$>>$ logical right shift 144$<$ logical left shift 145$<<$ logical left shift 146.TE 147.)b 148.pp 149Expressions may be grouped by use of parentheses, 150.q "(" 151and 152.q ")". 153.SH 2 "Data Types" 154.pp 155The assembler manipulaes several different 156types of expressions. 157The types likely to be met explicitly are: 158.nr ii \w'undefined\ \ 'u 159.ip "undefined" 160Upon first encounter, 161each symbol is undefined. 162It may become undefined if it is assigned an undefined expression. 163It is an error to attempt to assemble an undefined 164expression in pass 2; 165in pass 1, 166it is not (except that 167certain keywords require operands which are not undefined). 168.ip "undefined\ external" 169A symbol which is declared 170.b .globl 171(or 172.b .global , 173which is an equivalent definition) 174but not defined 175in the current assembly is an undefined external. 176If such a symbol is declared, 177the link editor 178.i ld 179must be used to load the assembler's output with 180another routine that defines the undefined reference. 181.ip "absolute" 182An absolute symbol is defined ultimately from a constant. 183Its value is unaffected by any possible future applications 184of the link-editor to the output file. 185.ip "text" 186The value of a text symbol is measured 187with respect to the beginning of the text segment of the program. 188If the assembler output is link-edited, 189its text symbols may change in value 190since the program need 191not be the first in the link editor's output. 192Most text symbols are defined by appearing as labels. 193At the start of an assembly, 194the value of 195.q "\|\fB.\fP\|" 196is 197.q "text 0" . 198.ip "data" 199The value of a data symbol is measured 200with respect to the origin of the data segment of a program. 201Like text symbols, 202the value of a data symbol may change 203during a subsequent link-editor run since previously 204loaded programs may have data segments. 205After the first 206.b .data 207statement, 208the value of 209.q "\|\fB.\fP\|" 210is 211.q "data 0". 212.ip "bss" 213The value of a bss symbol is measured from 214the beginning of the bss segment of a program. 215Like text and data symbols, 216the value of a bss symbol 217may change during a subsequent link-editor run, 218since previously loaded programs may have bss segments. 219.ip "external\ absolute,\ text,\ data,\ or\ bss" 220symbols declared 221.b .globl 222but defined within an assembly as absolute, 223text, 224data, 225or bss 226symbols may be used exactly as if they were not 227declared 228.b .globl ; 229however, their value and type are available 230to the link editor so that the program may be loaded with others 231that reference these symbols. 232.ip "register" 233The symbols 234.(q 235.b "r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15" 236.b "ap fp sp pc" 237.)q 238are predefined 239as register symbols. 240In addition, the 241.q "%" 242operator converts the following absolute expression whose 243value is between 0 and 15 into a register reference. 244.ip "other\ types" 245Each keyword known to the assembler has a type which 246is used to select the routine which processes 247the associated keyword statement. 248The behavior of such symbols 249when not used as keywords is the same as if they were absolute. 250.SH 2 "Type Propagation in Expressions" 251.pp 252When operands are combined by expression operators, 253the result has a type which depends on the types 254of the operands and on the operator. 255The rules involved are complex to state but 256were intended to be sensible and predictable. 257For purposes of expression evaluation the 258important types are 259.(b 260.TS 261center; 262l. 263undefined 264absolute 265text 266data 267bss 268undefined external 269other 270.TE 271.)b 272.pp 273The combination rules are then 274.nr ii 5n 275.np 276If one of the operands is undefined, 277the result is undefined. 278.np 279If both operands are absolute, 280the result is absolute. 281.np 282If an absolute is combined with one of the 283.q "other types" 284mentioned above, 285the result has the other type. 286An 287.q "other type" 288combined with an explicitly 289discussed type other than absolute 290it acts like an absolute. 291.pp 292Further rules applying to particular operators are: 293.ip "$+$" 294If one operand is text-, data-, or bss-segment 295relocatable, or is an undefined external, 296the result has the postulated type and the other operand 297must be absolute. 298.ip $-$ 299If the first operand is a relocatable 300text-, data-, or bss-segment symbol, the second operand 301may be absolute (in which case the result has the 302type of the first operand); 303or the second operand may have the same type 304as the first (in which case the result is absolute). 305If the first operand is external undefined, 306the second must be absolute. 307All other combinations are illegal. 308.ip others 309It is illegal to apply these operators to any but absolute symbols. 310