(The Stack and Procedures)

Slides:



Advertisements
Similar presentations
Intel 8086.
Advertisements

Programming 8086 – Part IV Stacks, Macros
Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
Registers of the 8086/ /2002 JNM.
There are two types of addressing schemes:
Procedures and Stacks. Outline Stack organization PUSH and POP instructions Defining and Calling procedures.
DAT x86 “Real” Memory Addressing © Alan T. Pinck / Algonquin College; 2003.
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
Stack Memory H H FFFFF H FFFFE H SS 0105 SP 0008 TOS BOS BOS = FFFF = 1104F H H 1104F H.
Data Movement Instructions
Addressing modes – 1 The way in which an operand is specified is called the Address Mode.
CS 206D Computer Organization
ICS312 Set 3 Pentium Registers. Intel 8086 Family of Microprocessors All of the Intel chips from the 8086 to the latest pentium, have similar architectures.
80x86 Processor Architecture
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Assembly Language – Lab 5
An Introduction to 8086 Microprocessor.
© 2010 Kettering University, All rights reserved..
Types of Registers (8086 Microprocessor Based)
Lecture 18: 11/5/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Module R3 Process Scheduling. Module R3 involves the creation of a simple “Round Robin” dispatcher. The successful completion of this module will require.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
4-Oct Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept  direct mode: OK for static addresses  indirect register mode:
INTRODUCTION TO MICROPROCESSOR Engr. Ammar Anwar Khan.
Microprocessor Microprocessor (cont..) It is a 16 bit μp has a 20 bit address bus can access upto 220 memory locations ( 1 MB). It can support.
Lab 6 Stack.
Lecture 9 (The Stack and Procedures). 1 Lecture Outline Introduction The Stack The PUSH Instruction The POP Instruction Terminology of Procedures INDEC.
University of Tehran 1 Microprocessor System Design Omid Fatemi Machine Language Programming
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Khaled A. Al-Utaibi  Introduction  The MOV Instruction  The LEA Instruction  The Stack Instructions  The String Data Transfer.
Internal Programming Architecture or Model
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
Assembly language programming
Instruction set Architecture
Format of Assembly language
Part of the Assembler Language Programmers Toolbox
Microprocessor Systems Design I
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
16.317: Microprocessor System Design I
Microprocessor and Assembly Language
University of Gujrat Department of Computer Science
(The Stack and Procedures)
Assembly Lang. – Intel 8086 Addressing modes – 1
Chapter 3 Addressing Modes
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Subject Name: Microprocesor Subject Code: 10CS45
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
Stack and Subroutines Module M17.1 Section 11.2.
Programming 8086 – Part IV Stacks, Macros
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
(The Stack and Procedures)
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Chapter 6 - Procedures and Macros
Morgan Kaufmann Publishers Computer Organization and Assembly Language
CNET 315 Microprocessor & Assembly Language
Lecture 06 Programming language.
Microprocessor and Assembly Language
Chapter 6 –Symbolic Instruction and Addressing
(The Stack and Procedures)
Intel 8086.
(Array and Addressing Modes)
Procedures and Macros.
Presentation transcript:

(The Stack and Procedures) Lecture 8 (The Stack and Procedures)

Lecture Outline Introduction The Stack The PUSH Instruction The POP Instruction Terminology of Procedures INDEC / OUTDEC procedures 1

Introduction The stack segment of a program is used for temporary storage of data and addresses. PUSH and POP instructions are used to add and remove words from the stack. 2

The Stack A stack is a one-dimensional data structure. Items are added and removed from one end of the structure; that is, it processes in a “last-in-first-out” manner. A program must set aside a block of memory to hold the stack. Ex: .STACK 100H When the program is assembled and loaded in memory: SS will contain the segment number of the stack segment. SP is initialized to 100H, which represents the empty stack position. When the stack is not empty, SP contains the offset address of the top of the stack. 3

The PUSH Instruction To add a new word to the stack we PUSH it on. Syntax: PUSH source Execution of PUSH causes the following to happen: SP is decreased/decremented by 2. A copy of the source content is moved to the address specified by SS:SP. The source is unchanged. 16-bit register or memory location 4

The PUSH Instruction 1234 5678 AX BX Offset 00F8 00FA 00FC 00FE 0100 Empty Stack SP 1234 Offset 00F8 00FA 00FC 00FE 0100 After PUSH AX SP 1234 Offset 00F8 00FA 00FC 00FE 0100 AFTER PUSH BX SP 5678 5

The POP Instruction To remove the top item from the stack, we POP it. Syntax: POP destination Execution of POP causes the following to happen: The content of SS:SP (the top of the stack) is moved to the destination. SP is increased by 2. 16-bit register (except IP) or memory location 6

The POP Instruction 5678 1234 Offset 00F8 00FA 00FC 00FE 0100 FFFF 0001 CX DX 5678 1234 Offset 00F8 00FA 00FC 00FE 0100 After POP CX SP 0001 CX DX 5678 1234 Offset 00F8 00FA 00FC 00FE 0100 After POP DX SP CX DX 1234 Offset 00F8 00FA 00FC 00FE 0100 Stack SP 5678 7

Exercise 1 Write assembly code that uses the stack operations to swap the content of AX and DX. PUSH AX PUSH DX POP AX POP DX 8