I386_AS(6)

NAME
i386_as - assembler for Intel 80386

SYNOPSIS
~em/lib.bin/i386/as [options] argument ...

DESCRIPTION
This assembler is made with the general framework described in uni_ass(6). It is an assembler generating relocatable object code in ack.out(5) format.

SYNTAX

segments
    An address on the Intel 80386 consists of two pieces: a segment number and an offset. Usually, the segment number resides in a segment register, and assembly language addresses only give the offset, with the exception of the address of an inter-segment jump or call (see addressing modes below).

registers
    The Intel 80386 has the following 32-bit registers:
    Four general registers: eax (accumulator), ebx (base), ecx (count), and edx (data). The low- and high order bytes of the low order words of these registers are separately addressable as ah, bh, ch, dh, and al, bl, cl, dl respectively.
    Two pointer registers: esp (stack pointer) and ebp (base pointer).
    Two index registers: esi (source index) and edi (destination index).
    Six segment registers: cs (code), ds (data), ss (stack), es (extra), fs (extra), and gs (extra).

addressing modes
    syntax		meaning
    expr		the value of expr is immediate data or
    		an address offset. There is no special
    		notation for immediate data.
    register	one of the aforementioned general registers
    		or their upper or lower halves, or one of the
    		four segment registers.
    (expr)		the value of expr is the address of the operand.
    (reg)
    expr (reg)	the value of expr (if present) + the contents of
    		reg (which must be a pointer or an index register)
    		is the address of the operand.
    (reg1) (reg2)
    expr (reg1) (reg2)
    		the value of expr (if present) + the contents of
    		reg1 + the
    		contents of reg2 is the address of the operand.
    (reg1) (reg2 * scale)
    expr (reg1) (reg2 * scale)
    		the value of expr (if present) + the contents of
    		reg1 + the
    		contents of reg2 multiplied by scale,
    		is the address of the operand.
    		scale can be either 1, 2, 4, or 8.
    		This mode is only allowed for 32-bit addressing.
    The next addressing mode is only allowed with the instructions
    "callf" or "jmpf".
    expr : expr	the value of the first expr is a segment number,
    		the value of the second expr is an address offset.
    The following two addressing modes are only allowed with Intel 80[23]87 floating
    point processor instructions:
    st
    st(num)		addresses the floating point processor stack. num
    		must be between 0 and 7. st is the same as st(0).

prefixes
    Each time an address is computed the processor decides which segment register to use. You can override the processor's choice by prefixing the instruction with one of eseg, cseg, sseg, dseg, fseg, or gseg; these prefixes indicate that the processor should choose es, cs, ss, ds, fs, or gs instead.
    Example:
    dseg movs

    There is also an address size toggle, which switches between 32-bit and 16-bit address generation: a16 or a32. Normally, the assembler generates 32-bit addresses; both of these toggles make it generate 16-bit addresses for the next instruction, and also generate code to set the processor temporarily in 16-bit address mode.

    There is also an operand size toggle, which switches between 32-bit and 16-bit operands: o16 or o32. Normally, the assembler generates 32-bit operands; both of these toggles make it generate 16-bit operands for the next instruction, and also generate code to set the processor temporarily in 16-bit operand mode.

    Prefixes only affect the next instruction.

    There are also the .use32 and .use16 assembler directives, which do not generate code, but change the assemblers default for operand and address sizes. Obviously, .use16 gives 16-bit modes, .use32 gives 32-bit modes. This is useful for assembling real mode 80386 code, or pure 16-bit modules (that do not have the D-bit set in the segment descriptor). These assembler directives stay in effect until there is another one.

SEE ALSO
uni_ass(6), ack(1), ack.out(5),
80386 Programmer's Reference Manual, 1986, Intel Corporation