x86 Assembly Language Reference Manual

Instruction Description

This section describes the SunOS x86 instruction syntax.

The assembler assumes it is generating code for a 32-bit segment, therefore, it also assumes a 32-bit address and automatically precedes word operations with a 16-bit data prefix byte.

Addressing Modes

Addressing modes are represented by the following:

[sreg:][offset][([base][,index][,scale])]

Following are some examples of addresses:


movl var, %eax

Move the contents of memory location var into %eax.


movl %cs:var, %eax

Move the contents of the memory location var in the code segment into %eax.


movl $var, %eax

Move the address of var into %eax.


movl array_base(%esi), %eax

Add the address of memory location array_base to the contents of %esi to get an address in memory. Move the contents of this address into %eax.


movl (%ebx, %esi, 4), %eax

Multiply the contents of %esi by 4 and add this to the contents of %ebx to produce a memory reference. Move the contents of this memory location into %eax.


movl struct_base(%ebx, %esi, 4), %eax

Multiply the contents of %esi by 4, add this to the contents of %ebx, and add this to the address of struct_base to produce an address. Move the contents of this address into %eax.

Expressions and Immediate Values

An immediate value is an expression preceded by a dollar sign:


immediate: "$" expr

Immediate values carry the absolute or relocatable attributes of their expression component. Immediate values cannot be used in an expression, and should be considered as another form of address, i.e., the immediate form of address.


immediate: "$" expr "," "$" expr

The first expr is 16 bits of segment. The second expr is 32 bits of offset.