Pristine Ack-5.5
[Ack-5.5.git] / man / i386_as.6
1 .\" $Id: i386_as.6,v 1.5 1994/06/24 14:01:54 ceriel Exp $
2 .TH I386_AS 6 "$Revision: 1.5 $"
3 .ad
4 .SH NAME
5 i386_as \- assembler for Intel 80386
6 .SH SYNOPSIS
7 ~em/lib.bin/i386/as [options] argument ...
8 .SH DESCRIPTION
9 This assembler is made with the general framework
10 described in \fIuni_ass\fP(6). It is an assembler generating relocatable
11 object code in \fIack.out\fP(5) format.
12 .SH SYNTAX
13 .IP segments
14 An address on the Intel 80386 consists of two pieces:
15 a segment number and an offset.
16 Usually, the segment number resides in a segment register, and
17 assembly language addresses only give the offset, with the exception of
18 the address of an inter-segment jump or call (see \fIaddressing modes\fP
19 below).
20 .IP registers
21 The Intel 80386 has the following 32-bit registers:
22 .br
23 Four general registers: eax (accumulator), ebx (base), ecx (count), and edx (data).
24 The low- and high order bytes of the low order words of these registers
25 are separately addressable as ah, bh, ch, dh, and al, bl, cl, dl respectively.
26 .br
27 Two pointer registers: esp (stack pointer) and ebp (base pointer).
28 .br
29 Two index registers: esi (source index) and edi (destination index).
30 .br
31 Six segment registers: cs (code), ds (data), ss (stack), es (extra),
32 fs (extra), and gs (extra).
33 .IP "addressing modes"
34 .nf
35 .ta 8n 16n 24n 32n 40n 48n
36 syntax          meaning
37
38 expr            the value of \fIexpr\fP is immediate data or
39                 an address offset. There is no special
40                 notation for immediate data.
41
42 register        one of the aforementioned general registers
43                 or their upper or lower halves, or one of the
44                 four segment registers.
45
46 (expr)          the value of expr is the address of the operand.
47
48 (reg)
49 expr (reg)      the value of \fIexpr\fP (if present) + the contents of
50                 \fIreg\fP (which must be a pointer or an index register)
51                 is the address of the operand.
52
53 (reg1) (reg2)
54 expr (reg1) (reg2)
55                 the value of \fIexpr\fP (if present) + the contents of
56                 \fIreg1\fP + the
57                 contents of \fIreg2\fP is the address of the operand.
58
59 (reg1) (reg2 * scale)
60 expr (reg1) (reg2 * scale)
61                 the value of \fIexpr\fP (if present) + the contents of
62                 \fIreg1\fP + the
63                 contents of \fIreg2\fP multiplied by \fIscale\fP,
64                 is the address of the operand.
65                 \fIscale\fP can be either 1, 2, 4, or 8.
66                 This mode is only allowed for 32-bit addressing.
67
68 The next addressing mode is only allowed with the instructions
69 "callf" or "jmpf".
70
71 expr : expr     the value of the first \fIexpr\fP is a segment number,
72                 the value of the second \fIexpr\fP is an address offset.
73
74 The following two addressing modes are only allowed with Intel 80[23]87 floating
75 point processor instructions:
76
77 st
78 st(num)         addresses the floating point processor stack. \fInum\fP
79                 must be between 0 and 7. st is the same as st(0).
80
81 .fi
82
83 .IP prefixes
84 Each time an address is computed the processor decides which segment register
85 to use. You can override the processor's choice by prefixing the instruction
86 with one of eseg, cseg, sseg, dseg, fseg, or gseg; these prefixes indicate that the
87 processor should choose es, cs, ss, ds, fs, or gs instead.
88 .br
89 Example: 
90 .ti +8
91 dseg movs
92 .IP ""
93 There is also an address size toggle, which switches between 32-bit and
94 16-bit address generation: a16 or a32. Normally, the assembler generates
95 32-bit addresses; both of these toggles make it generate 16-bit addresses
96 for the next instruction, and also generate code to set the processor 
97 temporarily in 16-bit address mode.
98 .IP ""
99 There is also an operand size toggle, which switches between 32-bit and
100 16-bit operands: o16 or o32. Normally, the assembler generates
101 32-bit operands; both of these toggles make it generate 16-bit operands
102 for the next instruction, and also generate code to set the processor 
103 temporarily in 16-bit operand mode.
104 .IP ""
105 Prefixes only affect the next instruction.
106 .IP ""
107 There are also the .use32 and .use16 assembler directives, which do not
108 generate code, but change the assemblers default for operand and address sizes.
109 Obviously, .use16 gives 16-bit modes, .use32 gives 32-bit modes.
110 This is useful for assembling real mode 80386 code, or pure 16-bit
111 modules (that do not have the D-bit set in the segment descriptor).
112 These assembler directives stay in effect until there is another one.
113 .SH "SEE ALSO"
114 uni_ass(6),
115 ack(1),
116 ack.out(5),
117 .br
118 80386 Programmer's Reference Manual, 1986, Intel Corporation