Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Assembly Language Step by Step Programming with DOS and Linux 2nd Ed 2000.pdf
Скачиваний:
168
Добавлен:
17.08.2013
Размер:
4.44 Mб
Скачать

POPFD Pop Top of Stack into EFlags (386+)

Flags affected:

O D I T S Z A P C

OF: Overflow flag TF: Trap flag AF: Aux carry

F

F

F

F

F

F

F

F

F DF: Direction

flag SF: Sign

flag

PF: Parity flag

*

*

*

*

*

*

*

*

*

IF: Interrupt

flag ZF: Zero

flag

CF: Carry flag

Legal forms:

POPFD <none>

Examples:

POPFD

Notes:

POPFD pops the double word (4 bytes) at the top of the stack into the EFlags register. In 32-bit protected mode, the top of the stack is defined as the DWORD at [ESP], and there is no way to override the SS segment with prefixes.

ESP is incremented by 4 after the word comes off the stack. Remember that ESP always points to either an empty stack or else real data. There is a separate pair of instructions, PUSH and POP, for pushing and popping other register data and memory data, in both 16-bit and 32-bit sizes.

PUSHFD and POPFD are most used in writing 32-bit interrupt service routines, where you must be able to save and restore the environment, that is, all machine registers, to avoid disrupting machine operations while servicing the interrupt.

r8 = AL AH BL BH CL CH DL DH sr = CS DS SS ES FS GS

m8 = 8-bit memory data

m32 = 32-bit memory data

i16 = 16-bit immediate data

d8 = 8-bit signed displacement

d32 = 32-bit unsigned displacement

r16 = AX BX CX DX BP SP SI DI

r32 = EAX EBX ECX EDX EBP ESP ESI E m16 = 16-bit memory data

i8 = 8-bit immediate data

i32 = 32-bit immediate data

d16 = 16-bit signed displacement

PUSH Push Operand onto Top of Stack

Flags affected:

O

D

I

T

S

Z

A

P

C

OF:

Overflow flag TF:

Trap

flag

AF:

Aux carry

F

F

F

F

F

F

F

F

F

DF:

Direction flag SF:

Sign

flag

PF:

Parity flag

<none> IF: Interrupt flag ZF: Zero flag CF: Carry flag

Legal forms:

PUSH r16

 

PUSH m16

386+

PUSH r32

PUSH m32

386+

PUSH sr

286+

PUSH i8

PUSH i16

286+

PUSH i32

386+

Examples:

PUSH WORD [BX]

PUSH EAX

PUSH DI

PUSH ES

PUSH DWORD 5

PUSH WORD 1000H

Notes:

It is impossible to push an 8-bit item onto the stack. Also remember that the top of the stack is defined (in 16bit modes) as the word at address SS:SP, and there's no way to override that using prefixes. In 32-bit modes the top of the stack is the DWORD at [ESP]. There is a separate pair of instructions, PUSHF and POPF, for pushing and popping the Flags register.

Also remember that SP/ESP is decremented before the push takes place; SP points to either an empty stack or else real data.

r8 = AL AH BL BH CL CH DL DH sr = CS DS SS ES FS GS

m8 = 8-bit memory data

m32 = 32-bit memory data

i16 = 16-bit immediate data

d8 = 8-bit signed displacement

d32 = 32-bit unsigned displacement

r16 = AX BX CX DX BP SP SI DI

r32 = EAX EBX ECX EDX EBP ESP ESI E m16 = 16-bit memory data

i8 = 8-bit immediate data

i32 = 32-bit immediate data

d16 = 16-bit signed displacement

PUSHA Push All 16-Bit GP Registers (286+)

Flags affected:

O

D

I

T

S

Z A P C

OF: Overflow flag TF: Trap flag AF: Aux carry

F

F

F

F

F

F F F F DF: Direction

flag SF: Sign

flag

PF: Parity flag

 

 

<none>

IF: Interrupt

flag ZF: Zero

flag

CF: Carry flag

Legal forms:

PUSHA

286+

Examples:

PUSHA

Notes:

PUSHA pushes all 16-bit general-purpose registers onto the stack. This instruction is present on the 286 and later CPUs and is not available in the 8086/8088.

The registers are pushed in this order:

AX, CX, DX, BX, SP, BP, SI, DI

However, note that the value of SP pushed is the value SP had before the first register was pushed onto the stack. In the course of executing PUSHA, the stack pointer is decremented by 16 bytes (8 registers x 2 bytes each).

The Flags register is not pushed onto the stack by PUSHA; see PUSHF.

r8 = AL AH BL BH CL CH DL DH sr = CS DS SS ES FS GS

m8 = 8-bit memory data

m32 = 32-bit memory data

i16 = 16-bit immediate data

d8 = 8-bit signed displacement

d32 = 32-bit unsigned displacement

r16 = AX BX CX DX BP SP SI DI r32 = EAX EBX ECX EDX EBP ESP ESI m16 = 16-bit memory data

i8 = 8-bit immediate data

i32 = 32-bit immediate data

d16 = 16-bit signed displacement

PUSHAD Push All 32-Bit GP Registers (386+)

Flags affected:

O

D

I

T

S

Z A P C

OF: Overflow flag TF: Trap flag AF: Aux carry

F

F

F

F

F

F F F F DF: Direction

flag SF: Sign

flag

PF: Parity flag

 

 

<none>

IF: Interrupt

flag ZF: Zero

flag

CF: Carry flag

Legal forms:

PUSHAD 386+

Examples:

PUSHAD

Notes:

PUSHA pushes all 32-bit general-purpose registers onto the stack. This instruction is present on the 386 and later CPUs and is not available in the 8086, 8088, or 286.

The registers are pushed in this order:

EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI

However, note that the value of ESP pushed is the value SP had before the first register was pushed onto the stack. In the course of executing PUSHAD, the stack pointer is decremented by 32 bytes (8 registers x 4 bytes each).

The EFlags register is not pushed onto the stack by PUSHAD; see PUSHFD.

r8 = AL AH BL BH CL CH DL DH sr = CS DS SS ES FS GS

m8 = 8-bit memory data

m32 = 32-bit memory data

i16 = 16-bit immediate data

d8 = 8-bit signed displacement

d32 = 32-bit unsigned displacement

r16 = AX BX CX DX BP SP SI DI

r32 = EAX EBX ECX EDX EBP ESP ESI E m16 = 16-bit memory data

i8 = 8-bit immediate data

i32 = 32-bit immediate data

d16 = 16-bit signed displacement