atusb: Delete temporary file
[linux-libre-firmware.git] / as31 / as31 / as31.1
1 .TH AS31 1
2 .SH NAME
3 as31 - An Intel 8031/8051 assembler
4 .SH SYNOPSIS
5 .B as31
6 [-h] [-l] [-s] [-v] [-Aarg] [-Ffmt] [-Ofile]
7 .BR infile.asm
8 .SH DESCRIPTION
9 .I As31
10 assembles
11 .IR infile.asm
12 into one of several different output formats. The output
13 will be in a file called infile.obj. The .asm extenstion
14 is required.
15
16 .SH OPTIONS
17 The options must appear before the input file name. Both
18 options are optional. The text of each flag must appear
19 on the same argument as the flag. For example, "-Fod" is a
20 valid argument, but "-F od" is not.
21 .TP
22 .B \-h
23 This causes the assembler to print out a verbose message describing its options. 
24 The message is written to the standard error. 
25 .TP
26 .B \-l
27 This option tells the assembler to also generate a listing file.
28 A listing will be placed in the file infile.lst. Where 'infile' is
29 the file that is being assembled. This option may appear
30 anywhere before infile.asm. The option must occur isolated on
31 the command line.
32 .IP
33 The listing file shows the assembler generated code in hex, and up to
34 60 characters are retained from the source file.
35 .TP
36 .B \-s
37 This causes the assembler to write output to standard output.
38 .TP
39 .B \-v
40 This causes the assembler to print a version number to the standard output.
41 .TP
42 .B \-Aarg
43 This option specifies a format specific string which is
44 passed to the format generator. Both format "tdr" and the srecord
45 formats use this option.
46 .TP
47 .B \-Fformat
48 This options specifies the output format that is to be used.
49 .IP
50 Currently the only options available for this are:
51 .RS
52 .IP "hex"
53 This format is the Intel HEX format which is expected by a
54 number of EPROM programmers and the PAULMON debugger.  For
55 use with some programmers, the output file's extension may
56 have to be changed to .HEX to be recognized by the programmer.
57 No -A option is used.  This format should be the
58 default if no -F option is used.
59
60 .IP "tdr"
61 This format generates an asci file of hex digits formatted in such a
62 way, so that they can be read by tdr's debugger. An argument can be
63 specified (See -A option) which will pass a format specific string to
64 the format generator. In this case, the argument string represents
65 an offset to add to the location counter. This offset is
66 specified in decimal and defaults to 64*1024 (0x10000). To specify
67 and offset of 100, you would need "-Ftdr -A100" when invoking the
68 assembler.
69
70 .IP "byte"
71 This format is simply an address and a byte on each line, in ascii.
72 No -A option is used.
73
74 .IP "od"
75 This format is similar to the output from od(1). The format 
76 consists of an address followed by sixteen hexadecimal bytes, followed
77 by the equivilant ASCII. No -A option is used.
78
79 .IP "srec2, srec3, srec4"
80 The srecord generator is capable of generating output with any one
81 of 2, 3, or 4 byte addresses. The -A option can be used to set the
82 base address offset, the default here is 0x0000 (unlike \fBtdr\fP).
83 .RE
84 .IP
85 NOTE: This assembler allows for the output formats to be expanded to
86 include many different output formats.
87 .TP
88 .B \-Ofile
89 This option tells the assembler to write the output to a file.
90 .DE
91
92 .SH "ASSEMBLER INSTRUCTIONS"
93 This assembler accepts standard 8031/8051 instruction formats.
94 Below is a list of instructions
95 and addressing modes.
96 .IP
97 .RS
98 .nf
99 .ta +1i +2i +1i +1i
100 INSTRUCTION             BYTES   CYCLES
101 -----------             -----   ------
102 ACALL   addr11          2       24
103 ADD     A, #data8               2       12
104 ADD     A, @Ri          1       12
105 ADD     A, Rn           1       12
106 ADD     A, direct               2       12
107 ADDC    A, #data8               2       12
108 ADDC    A, @Ri          1       12
109 ADDC    A, Rn           1       12
110 ADDC    A, direct               2       12
111 AJMP    addr11          2       24
112 ANL     A, #data8               2       12
113 ANL     A, @Ri          1       12
114 ANL     A, Rn           1       12
115 ANL     A, direct               2       12
116 ANL     C, /bit         2       24
117 ANL     C, !bit         2       24
118 ANL     C, bit          2       24
119 ANL     direct, #data8          3       24
120 ANL     direct, A               2       12
121 CJNE    @Ri, #data8, rel                3       24
122 CJNE    A, #data8, rel          3       24
123 CJNE    A, direct, rel          3       24
124 CJNE    Rn, #data8, rel         3       24
125 CLR     A               1       12
126 CLR     C               1       12
127 CLR     bit             2       12
128 CPL     A               1       12
129 CPL     C               1       12
130 CPL     bit             2       12
131 DA      A               1       12
132 DEC     @Ri             1       12
133 DEC     A               1       12
134 DEC     DPTR            1       12
135 DEC     Rn              1       12
136 DEC     direct          2       12
137 DIV     AB              1       48
138 DJNZ    Rn, rel         2       24
139 DJNZ    direct, rel             3       24
140 INC     @Ri             1       12
141 INC     A               1       12
142 INC     DPTR            1       24
143 INC     Rn              1       12
144 INC     direct          2       12
145 JB      bit, rel                3       24
146 JBC     bit, rel                3       24
147 JC      relative                2       24
148 JMP     @A + DPTR               1       24
149 JMP     @DPTR + A               1       24
150 JNB     bit, rel                3       24
151 JNC     relative                2       24
152 JNZ     relative                2       24
153 JZ      relative                2       24
154 LCALL   addr16          3       24
155 LJMP    addr16          3       24
156 MOV     @Ri, #data8             2       12
157 MOV     @Ri, A          1       12
158 MOV     @Ri, direct             2       24
159 MOV     A, #data8               2       12
160 MOV     A, @Ri          1       12
161 MOV     A, Rn           1       12
162 MOV     A, direct               2       12
163 MOV     C, bit          2       12
164 MOV     DPTR, #data16           3       24
165 MOV     Rn, #data8              2       12
166 MOV     Rn, A           1       12
167 MOV     Rn, direct              2       24
168 MOV     bit, C          2       24
169 MOV     direct, #data8          3       24
170 MOV     direct, @Ri             2       24
171 MOV     direct, A               2       12
172 MOV     direct, Rn              2       24
173 MOV     direct, direct          3       24
174 MOVC    A, @A + DPTR            1       24
175 MOVC    A, @A + PC              1       24
176 MOVC    A, @DPTR + A            1       24
177 MOVC    A, @PC + A              1       24
178 MOVX    @DPTR, A                1       12
179 MOVX    @Ri, A          1       24
180 MOVX    A, @DPTR                1       24
181 MOVX    A, @Ri          1       24
182 MUL     AB              1       48
183 NOP                     1       12
184 ORL     A, #data8               2       12
185 ORL     A, @Ri          1       12
186 ORL     A, Rn           1       12
187 ORL     A, direct               2       12
188 ORL     C, /bit         2       24
189 ORL     C, !bit         2       24
190 ORL     C, bit          2       24
191 ORL     direct, #data8          3       24
192 ORL     direct, A               2       12
193 POP     direct          2       24
194 PUSH    direct          2       24
195 RET                     1       24
196 RETI                    1       24
197 RL      A               1       12
198 RLC     A               1       12
199 RR      A               1       12
200 RRC     A               1       12
201 SETB    A               1       12
202 SETB    bit             2       12
203 SJMP    relative                2       24
204 SUBB    A, #data8               2       12
205 SUBB    A, @Ri          1       12
206 SUBB    A, Rn           1       12
207 SUBB    A, direct               2       12
208 SWAP    A               1       12
209 XCH     A, #data8               2       12
210 XCH     A, @Ri          1       12
211 XCH     A, Rn           1       12
212 XCH     A, direct               2       12
213 XCHD    A, #data8               2       12
214 XCHD    A, @Ri          1       12
215 XCHD    A, Rn           1       12
216 XCHD    A, direct               2       12
217 XRL     A, #data8               2       12
218 XRL     A, @Ri          1       12
219 XRL     A, Rn           1       12
220 XRL     A, direct               2       12
221 XRL     direct, #data8          3       12
222 XRL     direct, A               2       12
223 .fi
224 .RE
225
226 .SH "ASSEMBLER DIRECTIVES"
227 As31 includes the following assembler directives:
228 .IP ".ORG expr"
229 Start assembling at the address specified by the expression expr.
230 An error occurs if the assembler starts assembling over an address
231 space that has previously been assembled into.
232
233 .IP ".EQU symbol, expr"
234 Set symbol to the value of expr. The value for expr must be
235 known during the first pass, when the line containing the .EQU
236 is encountered.
237
238 .IP ".BYTE expr, expr, ..."
239 Assemble the bytes specified by the expression into memory. A
240 string may also be specified with this directive.
241
242 .IP ".WORD expr, expr, ..."
243 Assemble the words specified by the expression into memory.
244 The byte ordering used, is that used by the 8031.
245
246 .IP ".FLAG symbol1, symbol.[0-7]"
247 Sets symbol1 to the bit address specified by the symbol.[0-7]
248 expression. Where [0-7] denotes a character between 0 and 7.
249 The resulting bit address is checked to see if it is a valid bit
250 address.
251
252 .IP ".END"
253 This directive is ignored.
254
255 .IP ".SKIP expr"
256 Adds the value of expr to the location counter. Used
257 to reserve a block of uninitialized data. Expr should
258 be in bytes.
259
260 .SH "LEXICAL CONVENTIONS"
261 .IP "-"
262 All characters following a semi-colon are ignored until a newline
263 is encountered.
264
265 .IP "-"
266 All numbers default to decimal, unless the number starts with
267 one of the following:
268 .RS
269 .IP "0x or 0X"
270 This indicates a hexadecimal number. ie. 0x00ff
271 .IP "0b or 0B"
272 This indicates a binary number. (1's and 0's). ie. 0b1100110010
273 .IP "0"
274 This indicates an octal number. ie. 0377
275 .RE
276 .IP "-"
277 All numbers default to decimal, unless the number ends with
278 one of the following characters:
279 .RS
280 .IP "b or B"
281 This indicates a binary number. Unless 0x was used above.
282 ie. 1010101b
283 .IP "h or H"
284 This always indicates a hex number, However the if the first
285 character is non-numerical, then either 0x or 0 must be specified.
286 This avoids confusing the assembler into thinking a hex number is
287 a symbol.
288 For example: 0ffh, 0xffh, 0XffH, 20h, 0x20 and 020h are means
289 to specify a valid hexdigit. But the following are not:
290 ffh, 0ff.
291 .IP "d or D"
292 This forces a number to decimal. Unless 0X was used. ie. 129d
293 .IP "o or O"
294 This causes the number to be interpreted as octal. ie. 377o
295 .RE
296
297 .IP "-"
298 A character constant can be entered as 'c' where c is some
299 character. \\b, \\n, \\r, \\t, \\' \\0 are also valid. A character
300 constant can be used anywhere that an integer value can.
301
302 .IP "-"
303 A string is entered as a set of characters enclosed in double quotes "".
304 A string is only valid with the .BYTE directive. \\b, \\n, \\r, \\t, \\"
305 are also valid escapes. However \\0 is not.
306
307 .IP "-"
308 Instructions, directives, and the symbols: R0, R1, R2, R3, R4, R5,
309 R6, R7, A, AB, and C can be entered in upper or lower case without
310 assembler confusion. These words however cannot be defined as a user symbol.
311 Any user symbol may be used, and case will be preserved. So the
312 user symbols "foo" and "Foo" are different, but "addc" is the same
313 as "aDdC".
314
315 .IP "-"
316 A symbol can be any alpha numerical character plus the underscore ('_').
317
318 .IP "-"
319 Expressions are accepted in most places where a value or a symbol is
320 needed. An expression consists of the following operators. All
321 operators evaulate to integer objects (higher precedence opertors listed
322 first):
323 .RS
324 .IP "-"
325 Unary minus
326 .IP "&"
327 Bit-wise AND.
328 .IP "|"
329 Bit-Wise OR.
330 .IP "*"
331 Integer multiplication.
332 .IP "/"
333 Integer division
334 .IP "%"
335 Integer modulus
336 .IP "+"
337 Integer addition.
338 .IP "-"
339 Integer subtraction.
340 .RE
341 .IP "-"
342 In addition to these operators, a special symbol '*' may be used
343 to represent the current location counter.
344
345 .SH EXAMPLES
346 .IP
347 Below is a sample assembly program.
348 .RS
349 .nf
350
351                 .org    0
352 start:          mov     P3, #0xff       ; use alternate fns on P3
353                                         ; leds on P1 are inverted.
354                 setb    F0              ; climbing up
355                 mov     A, #0x01        ; initial bit
356
357 write:          cpl     A               ; write it
358                 mov     P1, A
359                 cpl     A
360                 acall   delay
361                 jb      F0, climbup     ; climbing which way?
362
363 climbdn:        rr      A               ; down - shift right
364                 jnb     ACC.0, write    ; back for more
365                 setb    F0
366                 ajmp    write
367
368 climbup:        rl      A               ; up - shift left
369                 jnb     ACC.7, write    ; back for more
370                 clr     F0
371                 ajmp    write
372                 .end                    ; this directive ignored.
373 .fi
374
375
376 .SH AUTHORS
377 Ken Stauffer (University of Calgary) <stauffer@cpsc.ucalgary.ca>
378 .br
379 Martin Langer <martin-langer@gmx.de>