EC-333 Microprocessor and Interfacing Techniques

Similar documents
6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

EEM336 Microprocessors I. Addressing Modes

Chapter 3: Addressing Modes

Assembly Language Each statement in an assembly language program consists of four parts or fields.

EEM336 Microprocessors I. Data Movement Instructions

EC 333 Microprocessor and Interfacing Techniques (3+1)

On 386 and later machines, segment had a size of 64 KB. Therefore, to get the actual physical address, we can calculate it in the following way:

EC-333 Microprocessor and Interfacing Techniques

EC 333 Microprocessor and Interfacing Techniques (3+1)

Assembling, Linking and Executing 1) Assembling: .obj obj .obj.lst .crf Assembler Types: a) One pass assembler:

Intel 8086: Instruction Set

ORG ; TWO. Assembly Language Programming

BAHAR DÖNEMİ MİKROİŞLEMCİLER LAB3 FÖYÜ

CC411: Introduction To Microprocessors

UMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents.

CS401 Assembly Language Solved MCQS From Midterm Papers

Intel 8086 MICROPROCESSOR ARCHITECTURE

Code segment Stack segment

Intel 8086 MICROPROCESSOR. By Y V S Murthy

9/25/ Software & Hardware Architecture

Assembler Programming. Lecture 2

Addressing Modes on the x86

Experiment 8 8 Subroutine Handling Instructions and Macros

Assembly Language. Dr. Esam Al_Qaralleh CE Department Princess Sumaya University for Technology. Overview of Assembly Language

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

Computer Architecture 1 ح 303

if 2 16bit operands multiplied the result will be

A4 Sample Solution Ch3

MICROPROCESSOR TECHNOLOGY

SHEET-2 ANSWERS. [1] Rewrite Program 2-3 to transfer one word at a time instead of one byte.

4- MACHINE LANGUAGE CODING 4-1THE INSTRUCTION SET:

Computer Organization & Assembly Language Programming. CSE 2312 Lecture 15 Addressing and Subroutine

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998

Lecture 16: Passing Parameters on the Stack. Push Examples. Pop Examples. CALL and RET

Microcomputer Architecture..Second Year (Sem.2).Lecture(2) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات

THE UNIVERSITY OF TRINIDAD & TOBAGO

PESIT Bangalore South Campus

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

MODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

CS-202 Microprocessor and Assembly Language

The Stack. Lecture 15: The Stack. The Stack. Adding Elements. What is it? What is it used for?

PHY4635/5635 Spring Lecture 8: Program Control Instructions

3- ADDRESSING MODES in 8086: In this section we use the MOV instruction to describe the data-addressing modes. Figure 3-1 shows the MOV instruction.

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Data Movement Instructions

1. Introduction to Assembly Language

CS401 - Computer Architecture and Assembly Language Programming Glossary By

icroprocessor istory of Microprocessor ntel 8086:

The x86 Architecture

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)

Chapter 4: Data Movement Instructions. 4 1 MOV Revisited

Transfer of Control. Lecture 10 JMP. JMP Formats. Jump Loop Homework 3 Outputting prompts Reading single characters

db "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'

Hardware and Software Architecture. Chapter 2

Computer Architecture and System Software Lecture 06: Assembly Language Programming

Experiment 3 3 Basic Input Output

Basic characteristics & features of 8086 Microprocessor Dr. M. Hebaishy

Assembly Language Lab # 9

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

Tutorial Letter 103/3/2012 Computer Organization COS2621 Semesters 1 & 2

Come and join us at WebLyceum

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

x86 Assembly Tutorial COS 318: Fall 2017

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

UNIT 4. Modular Programming

Module 3 Instruction Set Architecture (ISA)

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Chapter Three Addressing Mode MOV AX, BX

Basic Assembly SYSC-3006

Project 1: Bootloader. COS 318 Fall 2015

Experiment N o 8. String Handling Instructions

Registers. Ray Seyfarth. September 8, Bit Intel Assembly Language c 2011 Ray Seyfarth

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

Intel x86 Memory. Architecture. The x86 isn't all that complex it just doesn't make a lot of sense. Program Segments. x86 Data and Address Ranges

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

CS499. Intel Architecture

Week 2 The 80x86 Microprocessor Architecture

Week /8086 Microprocessor Programming II

8086 INTERNAL ARCHITECTURE

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

.code. lea dx,msg2. Page 1/8. Problem 1: Programming in Assembly [25 Points]

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

Lesson 1. Fundamentals of assembly language

CG2007 Microprocessor systems.

CS401 Assembly Language Solved Subjective MAY 03,2012 From Midterm Papers. MC

Experiment N o 3 Segmentation and Addressing Modes

Assembly Language: g Part III. First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Objectives. ICT106 Fundamentals of Computer Systems Topic 8. Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee

Assignment no:4 on chapter no :3 : Instruction set of 8086

ADVANCE MICROPROCESSOR & INTERFACING

8086 ALP TOOLS (CH 2) CHAPTER 2

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

Transcription:

EC-333 Microprocessor and Interfacing Techniques Lecture 4 Addressing Modes Dr Hashim Ali Spring - 2018 Department of Computer Science and Engineering HITEC University Taxila Slides taken from Computer Organisation and Architecture by William Stallings. 1

Addressing Modes in Microprocessor (8086/88) Addressing mode provides different ways for access an address to given data to a processor. When 8086 executes an instruction, it performs the specified function on data. Operated data is stored in the memory location. There are various techniques to specify address of data. These techniques are called Addressing Modes. Types of Addressing Modes:- Data Addressing Modes Program Memory Addressing Modes Stack Memory Addressing Modes 2

Data-Addressing Modes: This mode is related to data transfer operation, that is, data is transferred either from the memory to internal registers of 8086 processors or from one register to another register. Example: MOV AX, DX Program Memory Addressing Modes: This mode involves program memory addresses during various operations. Example: JMP AX, in this instruction, the code execution control jumps to the current code segment location addressed by the contents of AX register. Stack Memory Addressing Modes: This mode involves stack registry operations. Example: PUSH AX, this instruction copies the contents of AX register to the stack. 3

Data-Addressing Modes An addressing mode means the method by which an operand can be specified in a register or a memory location. 8086/88 provide seven Addressing Modes: 1. Register Addressing 2. Immediate Addressing 3. Direct Data Addressing 4. Register Indirect Addressing 5. Base-Plus-Index Addressing 6. Register Relative Addressing 7. Base Relative-Plus-Index Addressing 4

Opcode and Operand in Microprocessor An opcode is a short of operation code An opcode is a singe instruction can be executed by the CPU. In machine language it is a binary or hexadecimal value such as B7 loaded into the instruction register. In assembly language mnemonic form an opcode is a command such as MOV or ADD or JMP. Example: MOV AX, 1000H ; MOV is the opcode ; AX (register) is an operand Operands are manipulated by the opcode. In this example, the operands are the register AX and the value 1000H. 8-bit 8-bit 8-bit Opcode Operand 1 Byte 1 or 2 Byte 5

Data-Addressing Modes MOV instruction is a common and flexible instruction. provides a basis for explanation of data-addressing modes Figure 3 1 illustrates the MOV instruction and defines the direction of data flow. Source is to the right and destination the left, next to the opcode MOV. an opcode, or operation code, tells the microprocessor which operation to perform 6

Figure 3 1 The MOV instruction showing the source, destination, and direction of data flow. The MOV AX, BX instruction transfers the contents of source register (BX) into the destination register (AX). The source never changes, but the destination always changes. MOV copies the source data into the destination. The source and destination are often called operands. 7

Figure 3 2 8086 Core2 data-addressing modes. 8

1. Register Addressing The most common form of data addressing. Once register names learned, easiest to apply. The microprocessor contains these 8-bit register names used with register addressing: AH, AL, BH, BL, CH, CL, DH, and DL. 16-bit register names: AX, BX, CX, DX, SP, BP, SI, and DI. Register addressing transfers a copy of a byte or word from the source register or contents of a memory location to the destination register or memory location. Ex: MOV CX, DX 9

Important for instructions to use registers that are the same size. Never mix an 8-bit with a 16-bit register, an 8- or a 16-bit register with a 32-bit register This is not allowed by the microprocessor and results in an error when assembled. Use of registers to hold the data to be manipulated Memory is not accessed when this addressing mode is executed Example: MOV BX, DX ; copy the contents of DX into BX MOV ES, AX ; copy the contents of AX into ES ADD AL, BH ; add the contents of BH to contents of AL Source and destination registers must have the same size 10

11

2. Immediate Addressing Transfers the source, an immediate byte or word of data, into the destination register or memory location The source operand is a constant The operand comes immediately after the opcode For this reason, this addressing mode executes quickly Immediate addressing mode can be used to load information into any of the registers except the segment registers and flag registers. 12

Example: MOV AX, 2550H MOV CX, 625 MOV BL, 40H ; move 2550H into AX ; load the decimal value 625 into CX ; load 40H into BL The data must first be moved to a general-purpose register and then to the segment register. Example: MOV AX, 2550H MOV DS, AX MOV DS, 0123H ; illegal instruction! 13

In symbolic assembly language, the symbol # precedes immediate data in some assemblers. - MOV AX,#1234H instruction is an example. Most assemblers do not use the # symbol, but represent immediate data as in the MOV AX,1234H instruction. - An older assembler used with some Hewlett-Packard logic development does, as may others. - In this text, the # is not used for immediate data. 14

The symbolic assembler portrays immediate data in many ways. The letter H appends hexadecimal data. If hexadecimal data begin with a letter, the assembler requires the data start with a 0. - to represent a hexadecimal F2, 0F2H is used in assembly language. Decimal data are represented as is and require no special codes or adjustments. - An example is the 100 decimal in the MOV AL,100 instruction. 15

An ASCII-coded character or characters may be depicted in the immediate form if the ASCII data are enclosed in apostrophes. - Ex: MOV AL, A Binary data are represented if the binary number is followed by the letter B. - in some assemblers, the letter Y - Ex: MOV CL,11001110B 16

17

Parts of Assembly Language Each statement in an assembly language program consists of four parts or fields. The leftmost field is called the label. used to store a symbolic name for the memory location it represents All labels must begin with a letter or one of the following special characters: @, $, -, or?. a label may any length from 1 to 35 characters The label appears in a program to identify the name of a memory location for storing data and for other purposes. 18

The next field to the right is the opcode field. - designed to hold the instruction, or opcode - the MOV part of the move data instruction is an example of an opcode Right of the opcode field is the operand field. - contains information used by the opcode - the MOV AL,BL instruction has the opcode MOV and operands AL and BL The comment field, the final field, contains a comment about the instruction(s). - comments always begin with a semicolon (;) 19

3. Direct Data Addressing Moves a byte or word between a memory location and a register. The data is in some memory location(s) and the address of the data in memory comes immediately after the instruction - usually a 3-byte long instruction This address is the offset address Example: MOV AL, [8088] ; move content of DS:8088 into AL The physical address is calculated by combining the contents of offset location 2400 with DS 20

Example: Find the physical address of the memory location and its contents after the execution of the following, assuming that DS = 1512H. MOV AL, 3BH MOV [3518], AL Solution: - First 3BH is copied into AL - Then in line two, the contents of AL are moved to logical address DS:3518 which is 1512:3518. - Shifting DS left and adding it to the offset gives the physical address of 18638H (15120H + 3518H = 18638H). - After the execution of the second instruction, the memory location with address 18638H will contain the value 3BH. 21

Few More Examples 22

4. Register Indirect Addressing Transfers a byte or word between a register and a memory location addressed by an index or base register. The address of the memory location where the operand resides is held by a register. The registers used for this purpose are SI, DI, and BX. They must be combined with DS (by default) in order to generate the 20-bit physical address. - The register BP uses the stack segment (SS) by default. 23

For example: - MOV AL, [BX] - MOV AL, [BP] - MOV AL, [SI] - MOV AL, [DI] Segment override prefix symbols can be used if you wish to access data in different segments. - MOV AL, CS:[BX] - MOV AL, DS:[BP] - MOV AL, SS:[SI] - MOV AL, ES:[DI] 24

Example: MOV AX, [BX] The physical address is calculated as ; moves into AX the contents of the memory location pointed to by DS:BX, 1000:1234 1000x10+1234=11234H The same rules apply when using register SI or DI. Example: MOV CL, [SI] ; move contents of DS:SI into CL MOV [DI], AH ; move contents of AH into DS:DI 25

Example: - Assume that DS = 1120H, SI = 2498H, and AX = 17FEH Show the contents of memory locations after the execution of Solution: MOV [SI], AX ; move contents of AX into DS:SI - The contents of AX are moved into memory locations with logical address DS:SI and DS:SI + 1 (Two bytes because of AX) - The physical address starts at DS (shifted left) + SI = 13698. According to the little endian convention, - Low address 13698H contains FE, the low byte, - High address 13699H will contain 17, the high byte. 26

Few Examples 27

5. Base-Plus-Index Addressing Transfers a byte or word between a register and the memory location addressed by a base register (BP or BX) plus an index register (DI or SI). Combining based and indexed addressing modes. One base register and one index register are used. Examples: MOV [BX+DI], CL ; move contents of CL into DS:BX+DI - Physical Address = DSx10 + BX+DI MOV CH, [BX+SI] ; move contents of the DS:BX+SI into CH - Physical Address = DSx10 + BX+SI MOV AH, [BP+DI] ; move contents of the SS:BP+SI into AH - Physical Address = SSx10 + BP+DI MOV [BP+SI], AL - Physical Address = SSx10 + BP+SI ; move contents of AL into SS:BP+SI 28

Few Examples 29

6. Register Relative Addressing Moves a byte or word between a register and the memory location addressed by an index or base register plus a displacement. The data in a segment of memory are addressed by adding the displacement to the contents of a base or an index register (BP, BX, DI, or SI). Examples: MOV AX, [BX+4] ; move contents of DS:BX+4 into AX - Physical Address = DSx10 + BX+4 MOV CH, [SI+5] ; move contents of the DS:SI+5 into CH - Physical Address = DSx10 +SI+5 MOV AH, [DI+1] ; move contents of the DS:DI+1 into AH - Physical Address = DSx10 + DI+1 MOV [BP+2], AL ; move contents of AL into SS:BP+2 - Physical Address = SSx10 + BP+2 30

Example: Assume that DS = 4500, SS = 2000, BX = 2100, SI = 1486, DI = 8500, BP= 7814, and AX = 2512. Show the exact physical memory location where AX is stored in each of the following. All values are in hex. 1- MOV [BX+20], AX 2- MOV [SI+10], AX 3- MOV [DI+4], AX 4- MOV [BP+12], AX Solution: Physical Address = segment reg. x 10 + (offset reg.) + displacement 1- DS:BX+20 2- DS:SI+10 3- DS:DI+4 4- SS:BP+12 location 47120 = (12) and 47121 = (25) location 46496 = (12) and 46497 = (25 ) location 4D504 = (12) and 4D505 = (25) location 27826 = (12) and 27827 = (25) 31

Few Examples 32

7. Base Relative-Plus-Index Addressing The base relative-plus-index addressing mode is similar to the baseplus-index addressing mode, but adds a displacement besides using a base register and an index register to form the memory address. This type of addressing mode often addresses a twodimensional array of memory data. The data in a segment of memory are addressed by adding the displacement to the contents of a base and an index register (BP, BX, DI, or SI). 33

Examples: MOV [BX+DI+1], AX ; move contents of AX into DS:BX+DI+1 - Physical Address = DSx10 + BX+DI+1H MOV AX, [BX+SI+10] ; move contents of the DS:BX+SI+10 into AX - Physical Address = DSx10 + BX+SI+10H MOV AH, [BP+DI+3] ; move contents of the SS:BP+SI+3 into AH - Physical Address = SSx10 + BP+DI+3H MOV AX, FILE[BX+DI] ; move contents of the DS:FILE+BX+DI into AX - Physical Address = DSx10 + BX+DI+FILE 34

Few Examples 35

Offset Registers For Various Segments The following Table provides a summary of the offset registers that can be used with the four segment registers of the 8086/8088. Segment Register CS DS ES SS Offset Register IP SI, DI, BX SI, DI, BX SP, BP 36

Easy Way to Remember 8086/88 Addressing Modes Total 17 different memory addressing modes:- - DISP, [BX], [BP], [SI], [DI], [BX+DISP], [BP+DISP],[SI+DISP], [DI+DISP], [BX+SI], [BX+DI], [BP+SI], [BP+DI],[BX+SI+DISP], [BX+DI+DISP], [BP+SI+DISP], and [BP+DI+DISP] DISP = Displacement 37

Assembly Language There is a one-to-one relationship between assembly and machine language instructions. What is found is that a compiled machine code implementation of a program written in a high-level language results in inefficient code. - More machine language instructions than an assembled version of an equivalent handwritten assembly language program. Two key benefits of assembly language programming. - It takes up less memory - It executes much faster 38

Languages in-terms of Applications One of the most beneficial uses of assembly language programming is real-time applications. Real time means the task required by the application must be completed before any other input to the program that will alter its operation can occur For example the device service routine which controls the operation of the floppy disk drive is a good example that is usually written in assembly language Assembly language not only good for controlling hardware devices but also performing pure software operations - searching through a large table of data for a special string of characters - Code translation from ASCII to EBCDIC - Table sort routines - Mathematical routines Assembly language: perform real-time operations High-level languages: Those operations mostly not critical in time. 39

Assembly Instructions 40

Assembler Directives Model: Selects the size of the memory model. -.MODEL SMALL : Reserves 64KB memory for Code Segment (CS) and 64KB for Data Segment (DS). -.MODEL MEDIUM : CS can exceed 64KB but DS must fit in 64KB of memory. -.MODEL COMPACT : CS is of fixed 64KB size but DS can vary. -.MODEL LARGE : Both CS & DS can exceed 64KB but only one of them. -.MODEL HUGE : Both can exceed its 64KB memory size. -.MODEL TINY : Used with compact (com) files in which CS & DS must fit into 64KB. 41

Assembly Code Template.MODEL SMALL.STACK ; beginning of the stack segment.data ; beginning of the data segment.code ; beginning of the code segment Ex:.DATA DATAW DW 213FH DATAB DB 52H SUM DB? ;nothing stored but storage is assigned Ex:.CODE ProcedureName PROC Attribute ProcedureName ENDP END ProcedureName ; name of the procedure ; procedure statements PROC is a statement used to indicate the beginning of a procedure or subroutine. ENDP indicates the end of the procedure. ProcedureName may be any valid identifier. Attribute is NEAR if the Procedure is in the same code segment as the calling program; or FAR if in a different code segment. 42

Simple Program Hello World! ; This program displays Hello, World!.MODEL SMALL.STACK 100H.DATA message DB Hello, World!, 0dh, 0ah, $ ; newline+eoc.code MAIN PROC mov ax, @data ; address of DS mov ds, ax mov ah, 9 mov dx, offset message ; displacement message starting at 0 int 21h mov ax, 4C00h ; halt the program and return int 21h main endp end main 43

PROGRAM MEMORY ADDRESSING MODES Program memory-addressing modes, used with the JMP and CALL instructions, consist of three distinct forms: 1. Direct Program Memory Addressing 2. Relative Program Memory Addressing 3. Indirect Program Memory Addressing 44

1. Direct Program Memory Addressing Used for all jumps and calls by early microprocessor; also used in high-level languages, such as BASIC. - GOTO and GOSUB instructions The microprocessor uses this form, but not as often as relative and indirect program memory addressing. The instructions for direct program memory addressing store the address with the opcode. 45

Figure 3 14 The 5-byte machine language version of a JMP [10000H] instruction. This JMP instruction loads CS with 1000H and IP with 0000H to jump to memory location 10000H for the next instruction. - an intersegment jump is a jump to any memory location within the entire memory system Often called a far jump because it can jump to any memory location for the next instruction. - in real mode, any location within the first 1M byte 46

The only other instruction using direct program addressing is the intersegment or far CALL instruction. Usually, the name of a memory address, called a label, refers to the location that is called or jumped to instead of the actual numeric address. When using a label with the CALL or JMP instruction, most assemblers select the best form of program addressing. 47

2. Relative Program Memory Addressing Not available in all early microprocessors, but it is available to this family of microprocessors. The term relative means relative to the instruction pointer (IP). The JMP instruction is a 1-byte instruction, with a 1-byte or a 2-byte displacement that adds to the instruction pointer. An example is shown in Figure 3 15. 48

Figure 3 15 A JMP [2] instruction. This instruction skips over the 2 bytes of memory that follow the JMP instruction. 49

3. Indirect Program Memory Addressing The microprocessor allows several forms of program indirect memory addressing for the JMP and CALL instructions. In 80386 and above, an extended register can be used to hold the address or indirect address of a relative JMP or CALL. - for example, the JMP EAX jumps to the location address by register EAX 50

If a relative register holds the address, the jump is considered to be an indirect jump. For example, JMP [BX] refers to the memory location within the data segment at the offset address contained in BX. at this offset address is a 16-bit number used as the offset address in the intrasegment jump this type of jump is sometimes called an indirect-indirect or doubleindirect jump Figure 3 16 shows a jump table that is stored, beginning at memory location TABLE. 51

Figure 3 16 A jump table that stores addresses of various programs. The exact address chosen from the TABLE is determined by an index stored with the jump instruction. 52

3 3 STACK MEMORY-ADDRESSING MODES The stack plays an important role in all microprocessors. - holds data temporarily and stores return addresses used by procedures Stack memory is LIFO (last-in, first-out) memory - describes the way data are stored and removed from the stack Data are placed on the stack with a PUSH instruction; removed with a POP instruction. Stack memory is maintained by two registers: - the stack pointer (SP or ESP) - the stack segment register (SS) 53

Whenever a word of data is pushed onto the stack, the high-order 8 bits are placed in the location addressed by SP 1. - low-order 8 bits are placed in the location addressed by SP 2 The SP is decremented by 2 so the next word is stored in the next available stack location. - the SP/ESP register always points to an area of memory located within the stack segment. In protected mode operation, the SS register holds a selector that accesses a descriptor for the base address of the stack segment. When data are popped from the stack, the low-order 8 bits are removed from the location addressed by SP. - High-order 8 bits are removed; the SP register is incremented by 2. 54

Figure 3 17 The PUSH and POP instructions: (a) PUSH BX places the contents of BX onto the stack; (b) POP CX removes data from the stack and places them into CX. Both instructions are shown after execution. 55

Note that PUSH and POP store or retrieve words of data never bytes in 8086-80286. 80386 and above allow words or doublewords to be transferred to and from the stack. Data may be pushed onto the stack from any 16-bit register or segment register. - in 80386 and above, from any 32-bit extended register Data may be popped off the stack into any register or any segment register except CS. 56

PUSHA and POPA instructions push or pop all except segment registers, on the stack. Not available on early 8086/8088 processors. 80386 and above allow extended registers to be pushed or popped. - 64-bit mode for Pentium and Core2 does not contain a PUSHA or POPA instruction 57

Figure 3 14 The 5-byte machine language version of a JMP [10000H] instruction. 58