0% found this document useful (0 votes)
46 views31 pages

Chapter 7-1

The PUSH and POP instructions store and retrieve data from the stack memory in a last-in, first-out manner. There are register, memory, and immediate forms of PUSH and POP that allow transferring data between registers, memory, and the stack. Additional instructions like LODS, STOS, MOVS, INS, and OUTS allow transferring strings of data between memory and registers or I/O devices. Other instructions like XCHG, XLAT, IN, OUT, and BSWAP provide miscellaneous data transfer functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views31 pages

Chapter 7-1

The PUSH and POP instructions store and retrieve data from the stack memory in a last-in, first-out manner. There are register, memory, and immediate forms of PUSH and POP that allow transferring data between registers, memory, and the stack. Additional instructions like LODS, STOS, MOVS, INS, and OUTS allow transferring strings of data between memory and registers or I/O devices. Other instructions like XCHG, XLAT, IN, OUT, and BSWAP provide miscellaneous data transfer functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

CHAPTER 7

Data Movement
Instructions
PUSH/POP
The PUSH and POP instructions
are important instructions that
store and retrieve data from the
LIFO (last-in, first-out) stack
memory.
The microprocessor has six forms of the
PUSH and POP instructions:

immediat
Register memory e

segment and all


register flags registers
Register addressing allows the
contents of any 16-bit register to be
transferred to or from the stack.
Memory-addressing PUSH and POP
instructions store the contents of a
16-bit or 32 bits memory location on
the stack or stack data into a memory
location.
PUSH
The 8086–80286 PUSH instruction always
transfers 2 bytes of data to the stack; the
80386 and above transfer 2 or 4 bytes,
depending on the register or size of the
memory location.
The PUSHA (push all) instruction
copies the registers to the stack in the
following order: AX, CX, DX, BX,
SP, BP, SI, and DI.
The PUSHF (push flags) instruction copies
the contents of the flag register to the stack.
 The PUSHAD and POPAD instructions push
and pop the contents of the 32-bit register set
found in the 80386 through the Pentium 4.
The PUSH instruction.
POP
The POP instruction performs the
inverse operation of a PUSH
instruction.
 The POP instruction removes data
from the stack and places it into the
target 16-bit register, segment register,
or a 16-bit memory location.
The POPF (pop flags) instruction
removes a 16-bit number from the
stack and places it into the flag
register;
The POPFD removes a 32-bit
number from the stack and places it
into the extended flag register.
the POPA (pop all) instruction
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.
The POP instructions.
STRING DATA TRANSFERS
There are five string data transfer instructions:

LODS STOS MOVS

INS OUTS
1. LODS
The LODS instruction loads AL, AX, or EAX
with data stored at the data segment offset
address indexed by the SI register.
After loading AL with a byte, AX with a
word, or EAX with a doubleword, the
contents of SI increment, if D=0 or
decrement, if D=1.
Load instructions move
data from memory to
registers.
2. STOS
The STOS instruction stores AL, AX, or EAX at
the extra segment memory location
addressed by the DI register.
As with LODS, a STOS instruction may be
appended with a B, W, or D for byte, word, or
doubleword transfers as below:
STOSB (stores a byte).
STOSW(stores a word).
STOSD (stores a doubleword).
Store instructions move
data from registers to
memory.
3. MOVS
MOVS is One of the more useful
string data transfer instructions,
because it transfers data from one
memory location to another.
This is the only memory-to-memory
transfer allowed in the 8086–Pentium 4
microprocessors.
Move instructions move
data from one register to
another.
This table shows Common operand modifiers.
4. INS
The INS (input string) instruction
transfers a byte, word, or
doubleword of data from an I/O
device into the extra segment
memory location addressed by the
DI register.
5. OUTS
The OUTS (output string)
instruction transfers a byte,
word, or doubleword of data
from the data segment
memory location address by
SI to an I/O device.
MISCELLANEOUS DATA TRANSFER INSTRUCTIONS
The data transfer instructions detailed in this section
are:

XCHG XLAT IN

OUT BSWAP
XCHG
The XCHG (exchange) instruction exchanges
the contents of a register with the contents of
any other register or memory location.
The XCHG instruction cannot exchange
segment registers or memory-to-memory
data.
Exchanges are byte-, word-, or doubleword-
sized (80386 and above).
XLAT
The XLAT (translate) instruction
converts the contents of the AL register
into a number stored in a memory
table.
This is the only instruction that adds
an 8-bit number to a l6-bit number.
IN and OUT
An IN instruction transfers data from an
external I/O device into AL, AX, or EAX.
An OUT instruction transfers data from AL,
AX, or EAX to an external I/O device.
BSWAP
The BSWAP (byte swap) instruction is
available only in the 80486–Pentium 4
microprocessors.
This instruction takes the contents of any
32-bit register and swaps the first byte with
the fourth, and the second with the third.
Example
the BSWAP EAX instruction with
• EAX = 00112233H swaps bytes in EAX,
resulting in EAX = 33221100H
exercise
Do the BSWAP EAX instruction with:

a) 11556600
b) 22113344
c) 00223344
d) 11003322
END

You might also like