1as86(1)                     General Commands Manual                    as86(1)
2
3
4

NAME

6       as86 - Assembler for 8086..80386 processors
7

SYNOPSIS

9       as86  [-0123agjuw]  [-lm[list]]  [-n name]  [-o obj] [-b[bin]] [-s sym]
10       [-t textseg] src
11
12       as86_encap prog.s prog.v [prefix_] [as86_options]
13
14

DESCRIPTION

16       as86 is an assembler for the 8086..80386  processors,  it's  syntax  is
17       closer  to the intel/microsoft form rather than the more normal generic
18       form of the unix system assembler.
19
20       The src file can be '-' to assemble the standard input.
21
22       This assembler can be compiled to support the 6809  cpu  and  may  even
23       work.
24
25       as86_encap  is  a  shell  script  to  call as86 and convert the created
26       binary into a C file prog.v to be included in or linked  with  programs
27       like  boot  block  installers.   The prefix_ argument is a prefix to be
28       added to all variables defined by the source, it defaults to  the  name
29       of   the  source  file.  The  variables  defined  include  prefix_start
30       prefix_size and prefix_data  to  define  and  contain  the  code,  plus
31       integers  containing the values of all exported labels.  Either or both
32       the prog.s and prog.v arguments can be '-' for standard in/out.
33
34
35

OPTIONS

37       -0     start with 16-bit code segment, warn for all instructions > 8086
38
39       -1     start with 16-bit code segment,  warn  for  all  instructions  >
40              80186
41
42       -2     start  with  16-bit  code  segment,  warn for all instructions >
43              80286
44
45       -3     start with 32-bit code segment, don't warn for any instructions.
46              (not even 486 or 586)
47
48       -a     enable  partial  compatibility  with  Minix asld. This swaps the
49              interpretation of round brackets and square brackets as well  as
50              making  alterations  to the code generation and syntax for 16bit
51              jumps and calls. ("jmp @(bx)" is then a valid instruction)
52
53       -g     only put global symbols in object or symbol file
54
55       -j     replace all short jumps with similar 16 or 32 bit jumps, the  16
56              bit  conditional branches are encoded as a short conditional and
57              a long unconditional branch.
58
59       -O     this causes the assembler to add extra  passes  to  try  to  use
60              forward   references   to  reduce  the  bytes  needed  for  some
61              instructions.  If the labels move on the last pass the assembler
62              will  keep  adding  passes  until the labels all stabilise (to a
63              maximum of 30 passes) It's probably not a good idea to use  this
64              with  hand  written  assembler use the explicit br bmi bcc style
65              opcodes for 8086 code or the jmp near style for conditional i386
66              instructions and make sure all variables are defined before they
67              are used.
68
69       -l     produce list file, filename may follow
70
71       -m     print macro expansions in listing
72
73       -n     name of module follows (goes in object instead of source name)
74
75       -o     produce object file, filename follows
76
77       -b     produce a raw binary file, filename may follow.  This is a 'raw'
78              binary  file  with  no  header, if there's no -s option the file
79              starts at location 0.
80
81       -s     produce an ASCII symbol file, filename follows.  The  format  of
82              this table is designed to be easy to parse for encapsulation and
83              related activities in relation to binary files created with  the
84              -b  option.  If a binary file doesn't start at location zero the
85              first two items in the table are the start and end addresses  of
86              the binary file.
87
88       -u     assume undefined symbols are imported-with-unspecified segment.
89
90       -w-    allow the assembler to print warning messages.
91
92       -t n   move all text segment data in segment n+3.
93

AS86 SOURCE

95       Special characters
96
97       *      Address of the start of the current line.
98
99       ; !    Either  of  these  marks the start of a comment. In addition any
100              'unexpected' character at the start of a line is assumed to be a
101              comment (but it's also displayed to the terminal).
102
103       $      Prefix  for  hexadecimal  numbers, the 'C' syntax, eg 0x1234, is
104              also accepted.
105
106       %      Prefix for binary numbers.
107
108       #      Prefix for immediate operands.
109
110       [ ]    Specifies an indirect operand.
111              Unlike MASM the assembler has no type information on labels just
112              a  segment and offset. This means that the way this operator and
113              the immediate prefix work are like traditional assemblers.
114
115              Examples:
116                   mov     ax,bx
117                   jmp     bx
118              Direct register addressing, the jump copies BX into PC.
119
120                   mov ax,[bx]
121                   jmp [bx]
122              Simple indirect register addressing, the jump moves the contents
123              of the location specified by BX into the PC.
124
125                   mov ax,#1234
126              Immediate value, ax becomes 1234.
127
128                   mov ax,1234
129                   mov ax,_hello
130                   mov ax,[_hello]
131              Absolute  addressing,  ax  is  set to contents of location 1234.
132              Note the third option is not strictly consistant but is in place
133              mainly for asld compatibility.
134
135
136                   mov ax,_table[bx]
137                   mov ax,_table[bx+si]
138                   mov eax,_table[ebx*4]
139
140                   mov ax,[bx+_table]
141                   mov ax,[bx+si+_table]
142                   mov eax,[ebx*4+_table]
143              Indexed  addressing,  both  formats are ok, I think the first is
144              more correct but I tend to used the second. :-)
145
146       Conditionals
147
148       IF, ELSE, ELSEIF, ENDIF
149              Numeric condition
150
151       IFC, ELSEIFC
152              String compare (str1,str2)
153
154       FAIL .FAIL
155              Generate user error.
156
157       Segment related
158
159       .TEXT .ROM .DATA .BSS
160              Set current segment. These can be preceded by the keyword .SECT
161
162       LOC    Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 14=MAX.  The segment
163              order  set  by  the linker is now 0,4,5,6,7,8,9,A,B,C,D,E,1,2,3.
164              Segment 0 and all segments  above  3  are  assumed  to  be  text
165              segment.   Note  the  64k  size restrictions are not imposed for
166              segments 3-14.
167
168       Label type definition
169
170       EXPORT PUBLIC .DEFINE
171              Export label defined in this object
172
173       ENTRY  Force linker to include the specified label in a.out
174
175       .GLOBL .GLOBAL
176              Define label as external and force import even if it isn't used.
177
178       EXTRN EXTERN IMPORT .EXTERN
179              Import list of externally defined labels
180              NB: It doesn't make sense to use imports for raw binary files.
181
182       .ENTER Mark entry for old binary file (obs)
183
184       Data definition
185
186       DB .DATA1 .BYTE FCB
187              List of 1 byte objects.
188
189       DW .DATA2 .SHORT FDB .WORD
190              List of 2 byte objects.
191
192       DD .DATA4 .LONG
193              List of 4 byte objects.
194
195       .ASCII FCC
196              Ascii string copied to output.
197
198       .ASCIZ Ascii string copied to output with trailing nul byte.
199
200       Space definition
201
202       .BLKB RMB .SPACE
203              Space is counted in bytes.
204
205       .BLKW .ZEROW
206              Space is counted in words. (2 bytes each)
207
208       COMM .COMM LCOMM .LCOMM
209              Common area data definition
210
211       Other useful pseudo operations.
212
213       .ALIGN .EVEN
214              Alignment
215
216       EQU    Define label
217
218       SET    Define re-definable label
219
220       ORG .ORG
221              Set assemble location
222
223       BLOCK  Set assemble location and stack old one
224
225       ENDB   Return to stacked assemble location
226
227       GET INCLUDE
228              Insert new file (no quotes on name)
229
230       USE16 [cpu]
231              Define default operand size as 16 bit, argument is cpu type  the
232              code  is  expected  to  run  on  (86,  186,  286, 386, 486, 586)
233              instructions for cpus later than specified give a warning.
234
235       USE32 [cpu]
236              Define default operand size as 32 bit, argument is cpu type  the
237              code  is  expected  to  run  on  (86,  186,  286, 386, 486, 586)
238              instructions for cpus later than specified give  a  warning.  If
239              the cpu is not mentioned the assembler ensures it is >= 80386.
240
241       END    End of compilation for this file.
242
243       .WARN  Switch warnings
244
245       .LIST  Listings on/off (1,-1)
246
247       .MACLIST
248              Macro listings on/off (1,-1)
249
250       Macros, now working, the general form is like this.
251
252           MACRO sax
253              mov ax,#?1
254           MEND
255           sax(1)
256
257
258       Unimplemented/unused.
259
260       IDENT  Define object identity string.
261
262       SETDP  Set DP value on 6809
263
264       MAP    Set binary symbol table map number.
265
266       Registers
267              BP BX DI SI
268              EAX EBP EBX ECX EDI EDX ESI ESP
269              AX CX DX SP
270              AH AL BH BL CH CL DH DL
271              CS DS ES FS GS SS
272              CR0 CR2 CR3 DR0 DR1 DR2 DR3 DR6 DR7
273              TR3 TR4 TR5 TR6 TR7 ST
274
275       Operand type specifiers
276              BYTE DWORD FWORD FAR PTR PWORD QWORD TBYTE WORD NEAR
277
278              The  'near and 'far' do not allow multi-segment programming, all
279              'far' operations are specified explicitly through the use of the
280              instructions:  jmpi, jmpf, callf, retf, etc. The 'Near' operator
281              can be  used  to  force  the  use  of  80386  16bit  conditional
282              branches.  The 'Dword' and 'word' operators can control the size
283              of operands on far jumps and calls.
284
285       General instructions.
286              These are in general the same as the instructions found  in  any
287              8086 assembler, the main exceptions being a few 'Bcc' (BCC, BNE,
288              BGE, etc) instructions which are shorthands for a  short  branch
289              plus  a  long  jump  and 'BR' which is the longest unconditional
290              jump (16 or 32 bit).
291
292       Long branches
293              BCC BCS BEQ BGE BGT BHI BHIS BLE BLO BLOS BLT BMI  BNE  BPC  BPL
294              BPS BVC BVS BR
295
296       Intersegment
297              CALLI CALLF JMPI JMPF
298
299       Segment modifier instructions
300              ESEG FSEG GSEG SSEG
301
302       Byte operation instructions
303              ADCB  ADDB  ANDB  CMPB  DECB DIVB IDIVB IMULB INB INCB MOVB MULB
304              NEGB NOTB ORB OUTB RCLB RCRB ROLB RORB SALB SARB SHLB SHRB  SBBB
305              SUBB TESTB XCHGB XORB
306
307       Standard instructions
308              AAA  AAD AAM AAS ADC ADD AND ARPL BOUND BSF BSR BSWAP BT BTC BTR
309              BTS CALL CBW CDQ CLC CLD CLI CLTS CMC CMP CMPS CMPSB CMPSD CMPSW
310              CMPW  CMPXCHG  CSEG CWD CWDE DAA DAS DEC DIV DSEG ENTER HLT IDIV
311              IMUL IN INC INS INSB INSD INSW INT INTO  INVD  INVLPG  INW  IRET
312              IRETD  J JA JAE JB JBE JC JCXE JCXZ JE JECXE JECXZ JG JGE JL JLE
313              JMP JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE JNO JNP JNS  JNZ
314              JO JP JPE JPO JS JZ LAHF LAR LDS LEA LEAVE LES LFS LGDT LGS LIDT
315              LLDT LMSW LOCK LODB LODS  LODSB  LODSD  LODSW  LODW  LOOP  LOOPE
316              LOOPNE LOOPNZ LOOPZ LSL LSS LTR MOV MOVS MOVSB MOVSD MOVSW MOVSX
317              MOVW MOVZX MUL NEG NOP NOT OR OUT OUTS OUTSB  OUTSD  OUTSW  OUTW
318              POP POPA POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR
319              RDMSR REP REPE REPNE REPNZ REPZ RET RETF RETI ROL ROR  SAHF  SAL
320              SAR  SBB  SCAB  SCAS  SCASB SCASD SCASW SCAW SEG SETA SETAE SETB
321              SETBE SETC SETE SETG SETGE SETL SETLE SETNA SETNAE SETNB  SETNBE
322              SETNC  SETNE  SETNG  SETNGE SETNL SETNLE SETNO SETNP SETNS SETNZ
323              SETO SETP SETPE SETPO SETS SETZ SGDT SHL SHLD SHR SHRD SIDT SLDT
324              SMSW  STC  STD STI STOB STOS STOSB STOSD STOSW STOW STR SUB TEST
325              VERR VERW WAIT WBINVD WRMSR XADD XCHG XLAT XLATB XOR
326
327       Floating point
328              F2XM1 FABS FADD FADDP FBLD FBSTP FCHS FCLEX  FCOM  FCOMP  FCOMPP
329              FCOS  FDECSTP  FDISI  FDIV  FDIVP  FDIVR FDIVRP FENI FFREE FIADD
330              FICOM FICOMP FIDIV FIDIVR FILD FIMUL FINCSTP  FINIT  FIST  FISTP
331              FISUB  FISUBR  FLD FLD1 FLDL2E FLDL2T FLDCW FLDENV FLDLG2 FLDLN2
332              FLDPI FLDZ FMUL FMULP FNCLEX FNDISI  FNENI  FNINIT  FNOP  FNSAVE
333              FNSTCW  FNSTENV  FNSTSW FPATAN FPREM FPREM1 FPTAN FRNDINT FRSTOR
334              FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT  FST  FSTCW  FSTENV  FSTP
335              FSTSW  FSUB  FSUBP  FSUBR FSUBRP FTST FUCOM FUCOMP FUCOMPP FWAIT
336              FXAM FXCH FXTRACT FYL2X FYL2XP1
337

Using GASP

339       The Gnu assembler preprocessor provides some reasonable implementations
340       of user biased pseudo opcodes.
341
342       It can be invoked in a form similar to:
343
344       gasp   [-a...]  file.s [file2.s] |
345              as86 [...]  - [-o obj] [-b bin]
346
347       Be  aware  though  that  Gasp  generates an error for .org commands, if
348       you're not using alternate syntax you can use  org  instead,  otherwise
349       use  block  and endb.  The directive export is translated into .global,
350       which forces an import, if you are making a file using -b use public or
351       .define instead.
352
353       The GASP list options have no support in as86.
354

SEE ALSO

356       as(1), ld86(1), bcc(1)
357

BUGS

359       The 6809 version does not support -0, -3, -a or -j.
360
361       If  this  assembler  is  compiled with BCC this is classed as a 'small'
362       compiler, so there is a maximum input line length of 256 characters and
363       the instruction to cpu checking is not included.
364
365       The  checking  for  instructions that work on specific cpus is probably
366       not complete, the distinction between 80186  and  80286  is  especially
367       problematic.
368
369       The  .text  and  .data  pseudo  operators are not useful for raw binary
370       files.
371
372       When using the org directive the assembler can  generate  object  files
373       that may break ld86(1).
374
375
376
377
378                                   Mar, 1999                           as86(1)
Impressum