3 as31 - An Intel 8031/8051 assembler
6 [-h] [-l] [-s] [-v] [-Aarg] [-Ffmt] [-Ofile]
12 into one of several different output formats. The output
13 will be in a file called infile.obj. The .asm extenstion
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.
23 This causes the assembler to print out a verbose message describing its options.
24 The message is written to the standard error.
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
33 The listing file shows the assembler generated code in hex, and up to
34 60 characters are retained from the source file.
37 This causes the assembler to write output to standard output.
40 This causes the assembler to print a version number to the standard output.
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.
48 This options specifies the output format that is to be used.
50 Currently the only options available for this are:
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.
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
71 This format is simply an address and a byte on each line, in ascii.
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.
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).
85 NOTE: This assembler allows for the output formats to be expanded to
86 include many different output formats.
89 This option tells the assembler to write the output to a file.
92 .SH "ASSEMBLER INSTRUCTIONS"
93 This assembler accepts standard 8031/8051 instruction formats.
94 Below is a list of instructions
100 INSTRUCTION BYTES CYCLES
101 ----------- ----- ------
119 ANL direct, #data8 3 24
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
139 DJNZ direct, rel 3 24
164 MOV DPTR, #data16 3 24
169 MOV direct, #data8 3 24
173 MOV direct, direct 3 24
174 MOVC A, @A + DPTR 1 24
176 MOVC A, @DPTR + A 1 24
191 ORL direct, #data8 3 24
221 XRL direct, #data8 3 12
226 .SH "ASSEMBLER DIRECTIVES"
227 As31 includes the following assembler directives:
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.
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
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.
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.
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
253 This directive is ignored.
256 Adds the value of expr to the location counter. Used
257 to reserve a block of uninitialized data. Expr should
260 .SH "LEXICAL CONVENTIONS"
262 All characters following a semi-colon are ignored until a newline
266 All numbers default to decimal, unless the number starts with
267 one of the following:
270 This indicates a hexadecimal number. ie. 0x00ff
272 This indicates a binary number. (1's and 0's). ie. 0b1100110010
274 This indicates an octal number. ie. 0377
277 All numbers default to decimal, unless the number ends with
278 one of the following characters:
281 This indicates a binary number. Unless 0x was used above.
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
288 For example: 0ffh, 0xffh, 0XffH, 20h, 0x20 and 020h are means
289 to specify a valid hexdigit. But the following are not:
292 This forces a number to decimal. Unless 0X was used. ie. 129d
294 This causes the number to be interpreted as octal. ie. 377o
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.
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.
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
316 A symbol can be any alpha numerical character plus the underscore ('_').
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
331 Integer multiplication.
342 In addition to these operators, a special symbol '*' may be used
343 to represent the current location counter.
347 Below is a sample assembly program.
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
357 write: cpl A ; write it
361 jb F0, climbup ; climbing which way?
363 climbdn: rr A ; down - shift right
364 jnb ACC.0, write ; back for more
368 climbup: rl A ; up - shift left
369 jnb ACC.7, write ; back for more
372 .end ; this directive ignored.
377 Ken Stauffer (University of Calgary) <stauffer@cpsc.ucalgary.ca>
379 Martin Langer <martin-langer@gmx.de>