IA-32 Assembly Language Reference Manual

Segment Register Instructions

The following are the segment register instructions supported by the IA--32 processor.

Load Full Pointer (lds,les, lfs, lgs, and lss)

lds{wl} 	mem[32|48], reg[16|32]
les{wl} 	mem[32|48], reg[16|32]
lfs{wl} 	mem[32|48], reg[16|32]
lgs{wl} 	mem[32|48], reg[16|32]
lss{wl} 	mem[32|48], reg[16|32]
Operation

mem[32|48] -> reg[16|32]

Description

Reads a full pointer from memory and stores it in the specified segment register (DS, ES, FS, GS or SS) with a 16- or 32-bit offset value.

Example

Load a 16-bit pointer from memory location 0x44444444 into the DX register:

ldsw 0x44444444, %dx

Load a 32-bit pointer from memory location 0x33333333 into the EDX register:

ldsl 0x33333333, %edx

Pop Stack into Word (pop)

pop{wl}			r/m[16|32]
pop{l}			[%ds|%ss|%es|%fs|%gs]
Operation

stack -> r/m[16|32]

stack -> segment register

Description

Replaces the previous contents of the register or memory operand with a word or long from the top of the stack.

Replaces the previous contents of the segment register operand with a long.

For a word, SP + 2; for a long, SP + 4.

Example

Replace the contents of the memory location pointed to by the EDI register, plus an offset of 4, with the word from the top of the stack:

popw 4(edi)

Replace the contents of the memory location pointed to by the EAX register with the long from the top of the stack:

popl %eax

Push Word/Long onto Stack (push)

push{wl}		r/m[16|32]
push{wl}		imm[8|16|32]
push{l}		[%cs|%ds|%ss|%es|%fs|%gs]
Operation

r/m[16|32] -> stack segment register -> stack

Description

For a word, SP - 2; for a long, SP - 4. Replaces the new top of stack, pointed to by SP, with the register, memory, immediate, or segment register operand.

Example

Replaces the new top of stack with the 16-bit immediate value, -126:

pushw $-126

Replaces the new top of stack with the 32-bit immediate value, 23456789:

pushl $23456789

Replaces the new top of stack with the content of the AX register:

pushw %ax

Replaces the new top of stack with the content of the EBX register:

pushl %ebx