Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

2/26/2024

Topic-IV

80x86 Instruction Sets and ALP

T1. Barry B Brey, The Intel Microprocessors. Pearson, Eight Ed. 2009. Chapter 4-6, 8

23-02-2024

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

The effect of the PUSH AX instruction on ESP and stack memory


locations 37FFH and 37FEH. This instruction is shown at the point
after execution.
ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

1
2/26/2024

PUSH
Push data from

 Registers/Segment Register

 Memory

 Flag Register

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

PUSH
• Always transfers 2 bytes of data to the stack;
– 80386 and above transfer 2 or 4 bytes

• PUSHA instruction copies contents of the internal register set,


except the segment registers, to the stack.

• PUSHA (push all) instruction copies the registers to the stack in


the following order: AX, CX, DX, BX, SP, BP, SI, and DI.

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

2
2/26/2024

• PUSHA instruction pushes all the internal 16-bit registers onto the
stack.
• requires 16 bytes of stack memory space to
store all eight 16-bit registers
• After all registers are pushed, the contents of the SP register are
decremented by 16.
• PUSHAD instruction places 32-bit register set on the stack in
80386 - Core2.
– PUSHAD requires 32 bytes of stack storage

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

PUSHA instruction,
showing the location and order of stack data.

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

3
2/26/2024

• PUSHF (push flags) instruction copies the contents of the flag


register to the stack.

• PUSHAD instructions push the contents of the 32-bit register


set in 80386 - Pentium 4.

• PUSHA instructions do not function in the 64-bit mode of


operation for the Pentium 4

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

PUSH
Example-PUSH operation
PUSH AX
PUSH EBX
PUSH DS
PUSH WORD PTR[BX]
PUSHF
PUSHFD
PUSHA
PUSHAD
PUSH 16-imm
PUSHD 32-imm

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

4
2/26/2024

POP
 Performs the inverse operation of PUSH
 The POP instruction removes a word from the top of the stack
to the specified 16-bit register or memory location.
 The stack pointer is incremented by 2 after the execution.
 Ex: POP CX
- copies a word from the top of stack to the CX register and
increment SP by 2.
 not available as an immediate POP

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

POP
• POPF (pop flags) removes a 16-bit number from the stack and
places it in the flag register;
– POPFD removes a 32-bit number from the stack and places
it into the extended flag register
• POPA (pop all) removes 16 bytes of data from the stack and
places them into the following registers, in the order shown: DI,
SI, BP, SP, BX, DX, CX, and AX.
– reverse order from placement on the stack by PUSHA
instruction, causing the same data to return to the same
registers

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

5
2/26/2024

PUSHF

• Pushes flag register on to the stack; First the upper byte and
then the lower byte is pushed on to it. The SP (stack pointer )
is decremented by 2 for each PUSH operation.

• The FLAGS themselves are not affected.

PUSHF 10011100

Machine code format

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

POPF

• Transfers a word from the current top of the stack to the


FLAG register and increments the SP by 2.

• All the flags will be affected.

• PUSHF and POPF are used when there is a subprogram.

POPF 10010000

Machine code format

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

6
2/26/2024

End of Lecture 16

2/26/2024 35

ELECTRICAL ELECTRONICS COMMUNICATION INSTRUMENTATION

You might also like