summaryrefslogtreecommitdiff
path: root/man/as86.1
blob: e7fff3f849333f0a270c23edb1ca09e13e158251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
.TH as86 1 "Oct, 1996"
.BY Bruce Evans
.nh
.SH NAME
as86 \- Assembler for 8086..80386 processors
.SH SYNOPSIS
.B as86
.RB [ -0123agjuw ]
.RB [ -lm [ list ]]
.RB [ -n\ name ]
.RB [ -o\ obj ]
.RB [ -b [ bin ]]
.RB [ -s\ sym ]
.B src

.B as86_encap\ prog.s\ prog.v
.RB [ prefix_ ]
.RB [ as86\ options ]

.SH DESCRIPTION
.B as86
is an assembler for the 8086..80386 processors, it's syntax is closer
to the intel/microsoft form rather than the more normal generic form of
the unix system assembler.

The
.B src
file can be '-' to assemble the standard input.

This assembler can be compiled to support the 6809 cpu and may even work.

.B as86_encap
is a shell script to call as86 and convert the created binary into a C file
.B prog.v
to be included in or linked with programs like boot block installers.
The
.B prefix_
argument is a prefix to be added to all variables defined by the source,
it defaults to the name of the source file. The variables defined include
.B prefix_start
.B prefix_size
and
.B prefix_data
to define and contain the code, plus integers containing the values of all
exported labels.
Either or both the
.B prog.s
and
.B prog.v
arguments can be '-' for standard in/out.

.\" The 'src' file can be '-' for stdin but ONLY on 'big' machines.

.SH OPTIONS

.\"defaults (off or none except for these; no output is produced without a flag):
.\"-03		native
.\"list		stdout (beware of clobbering next arg)
.\"name		basename of the source name

.TP
.B -0
start with 16-bit code segment, warn for all instructions > 8086
.TP
.B -1
start with 16-bit code segment, warn for all instructions > 80186
.TP
.B -2
start with 16-bit code segment, warn for all instructions > 80286
.TP
.B -3
start with 32-bit code segment, don't warn for any instructions. (not even
486 or 586)
.TP
.B -a
enable partial compatibility with Minix asld
.TP
.B -g
only put global symbols in object or symbol file
.TP
.B -j
replace short jumps that don't reach with 5 byte sequences, this causes the
assembler to add an extra pass to try to determine if the long jump is
really needed. If you add a second
.B -j
the assembler will keep adding passes until the labels all stabilise (to
a maximum of 30 passes)
Don't use this with hand written assembler use the explicit
.B br\ bmi\ bcc
style opcodes for 8086 code or the
.B jmp\ near
style for conditional i386 instructions.
.TP
.B -l
produce list file, filename may follow
.TP
.B -m
print macro expansions in listing
.TP
.B -n
name of module follows (goes in object instead of source name)
.TP
.B -o
produce object file, filename follows
.TP
.B -b
produce a raw binary file, filename may follow.
This is a 'raw' binary file with no header, if there's no
.B -s
option the file starts at location 0.
.TP
.B -s
produce an ASCII symbol file, filename follows.
The format of this table is designed to be easy to parse for encapsulation
and related activities in relation to binary files created with the
.B -b
option.  If a binary file doesn't start at location zero the first two
items in the table are the start and end addresses of the binary file.
.TP
.B -u
take undefined symbols as imported-with-unspecified segment
.TP
.B -w
don't print warnings
.P
.SH AS86 SOURCE
Conditionals
.TP
.B IF, ELSE, ELSEIF, ENDIF
Numeric condition
.TP
.B IFC, ELSEIFC
String compare (str1,str2)
.TP
.B FAIL .FAIL
Generate user error.
.P
Segment related
.TP
.B .TEXT .ROM .DATA .BSS
Set current segment. These can be preceded by the keyword
.B .SECT
.TP
.B LOC
Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 15=MAX
.P
Label type definition
.TP
.B EXPORT PUBLIC .DEFINE
Export label defined in this object
.TP
.B ENTRY
Force linker to include label in a.out
.TP
.B .GLOBL .GLOBAL
Define label as external and force import even if it isn't used.
.TP
.B EXTRN EXTERN IMPORT .EXTERN
Import list of externally defined labels
.br
NB: It doesn't make sense to use imports for raw binary files.
.TP
.B .ENTER
Mark entry for old binary file (obs)
.P
Data definition
.TP
.B DB .DATA1 .BYTE  FCB
List of 1 byte objects.
.TP
.B DW .DATA2 .SHORT FDB .WORD
List of 2 byte objects.
.TP
.B DD .DATA4 .LONG
List of 4 byte objects.
.TP
.B .ASCII FCC
Ascii string copied to output.
.TP
.B .ASCIZ
Ascii string copied to output with trailing
.B nul
byte.
.P
Space definition
.TP
.B .BLKB RMB .SPACE
Space is counted in bytes.
.TP
.B .BLKW .ZEROW
Space is counted in words. (2 bytes each)
.TP
.B COMM .COMM LCOMM .LCOMM
Common area data definition
.P
Other useful pseudo operations.
.TP
.B .ALIGN .EVEN
Alignment
.TP
.B EQU
Define label
.TP
.B SET
Define re-definable label
.TP
.B ORG .ORG
Set assemble location
.TP
.B BLOCK
Set assemble location and stack old one
.TP
.B ENDB
Return to stacked assemble location
.TP
.B GET INCLUDE
Insert new file (no quotes on name)
.TP
.BR USE16\  [ cpu ]
Define default operand size as 16 bit, argument is cpu type the code is
expected to run on (86, 186, 286, 386, 486, 586) instructions for cpus
later than specified give a warning.
.TP
.BR USE32\  [ cpu ]
Define default operand size as 32 bit, argument is cpu type the code is
expected to run on (86, 186, 286, 386, 486, 586) instructions for cpus
later than specified give a warning. If the cpu is not mentioned the
assembler ensures it is >= 80386.
.TP
.B END
End of compilation for this file.
.TP
.B .WARN
Switch warnings
.TP
.B .LIST
Listings on/off (1,-1)
.TP
.B .MACLIST
Macro listings on/off (1,-1)
.P
Macros, now working, the general form is like this.

    MACRO sax
       mov ax,#?1
    MEND
    sax(1)

.TP
Unimplemented/unused.
.TP
IDENT
Define object identity string.
.TP
SETDP
Set DP value on 6809
.TP
MAP
Set binary symbol table map number.
.TP
Registers
.br
BP BX DI SI
.br
EAX EBP EBX ECX EDI EDX ESI ESP
.br
AX CX DX SP
.br
AH AL BH BL CH CL DH DL
.br
CS DS ES FS GS SS 
.br
CR0 CR2 CR3 DR0 DR1 DR2 DR3 DR6 DR7
.br
TR3 TR4 TR5 TR6 TR7 ST
.TP
Operand type specifiers
BYTE DWORD FWORD FAR PTR PWORD QWORD TBYTE WORD NEAR
.TP
General instructions understood.
AAA AAD AAM AAS ADC ADD AND ARPL BCC BCS BEQ BGE BGT BHI BHIS BLE BLO
BLOS BLT BMI BNE BOUND BPC BPL BPS BR BVC BVS CALL CALLF CALLI CBW CLC
CLD CLI CMC CMP CMPS CMPSB CMPSD CMPSW CMPW CSEG CWD CWDE CDQ DAA DAS
DSEG DEC DIV ENTER ESEG FSEG GSEG HLT IDIV IMUL IN INC INS INSB INSD
INSW INT INTO INW IRET IRETD J JA JAE JB JBE JC JCXE JCXZ JECXE JECXZ JE
JG JGE JL JLE JMP JMPF JMPI JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE
JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LDS LEA LEAVE LES LOCK LODB
LODS LODSB LODSD LODSW LODW LOOP LOOPE LOOPNE LOOPNZ LOOPZ MOV MOVS
MOVSB MOVSD MOVSW MOVW MUL NEG NOP NOT OR OUT OUTS OUTSB OUTSD OUTSW
OUTW POP POPA POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR
ROL ROR REP REPE REPNE REPNZ REPZ RET RETF RETI SAHF SAL SAR SBB SCAB
SCAS SCASB SCASD SCASW SCAW SEG SHL SHR SSEG STC STD STI STOB STOS STOSB
STOSD STOSW STOW SUB TEST WAIT XCHG XLAT XLATB XOR
.TP
And more...
BSF BSR BSWAP BT BTC BTR BTS CLTS CMPXCHG INVD INVLPG LAR LFS LGDT LGS
LIDT LLDT LMSW LSL LSS LTR MOVSX MOVZX SETA SETAE SETB SETBE SETC SETE
SETG SETGE SETL SETLE SETNA SETNAE SETNB SETNBE SETNC SETNE SETNG SETNGE
SETNL SETNLE SETNO SETNP SETNS SETNZ SETO SETP SETPE SETPO SETS SETZ
SGDT SIDT SHLD SHRD SLDT SMSW STR VERR VERW WBINVD XADD ADCB ADDB ANDB
CMPB DECB DIVB IDIVB IMULB INB INCB MOVB MULB NEGB NOTB ORB OUTB RCLB
RCRB ROLB RORB SALB SARB SHLB SHRB SBBB SUBB TESTB XCHGB XORB
.TP
Floating point
F2XM1 FABS FADD FADDP FBLD FBSTP FCHS FCLEX FCOM FCOMP FCOMPP FCOS
FDECSTP FDISI FDIV FDIVP FDIVR FDIVRP FENI FFREE FIADD FICOM FICOMP
FIDIV FIDIVR FILD FIMUL FINCSTP FINIT FIST FISTP FISUB FISUBR FLD FLD1
FLDL2E FLDL2T FLDCW FLDENV FLDLG2 FLDLN2 FLDPI FLDZ FMUL FMULP FNCLEX
FNDISI FNENI FNINIT FNOP FNSAVE FNSTCW FNSTENV FNSTSW FPATAN FPREM
FPREM1 FPTAN FRNDINT FRSTOR FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT FST
FSTCW FSTENV FSTP FSTSW FSUB FSUBP FSUBR FSUBRP FTST FUCOM FUCOMP
FUCOMPP FWAIT FXAM FXCH FXTRACT FYL2X FYL2XP1
.P
.SH Using GASP

The Gnu assembler preprocessor provides some reasonable implementations
of user biased pseudo opcodes.

It can be invoked in a form similar to:
.TP
.B gasp
.RB [ -a... ]
.B file.s
.RB [ file2.s ]
.B |
.br
.B as86
.RB [ ... ]
.B -
.RB [ -o\ obj ]\ [ -b\ bin ]
.P
Be aware though that Gasp generates an error for 
.B .org
commands, if you're not using alternate syntax you can use 
.B org
instead, otherwise use 
.BR block
and
.BR endb .
The directive
.B export
is translated into
.BR .global ,
which forces an import, if you are making a file using
.B -b
use
.B public
or 
.B .define
instead.

The GASP list options have no support in as86.
.SH SEE ALSO
as(1), ld86(1), bcc(1)
.SH BUGS
The 6809 version does not support -0, -3, -a or -j.

If this assembler is compiled with BCC this is classed as a 'small'
compiler, so there is a maximum input line length of 256 characters
and the instruction to cpu checking is not included.

The checking for instructions that work on specific cpus is probably
not complete, the distinction between 80186 and 80286 is especially
problematic.

The
.B .text
and
.B .data
pseudo operators are not useful for raw binary files.

When using the
.B org
directive the assembler can generate object files that may break ld86(1).