Lab 6 Stack.

Slides:



Advertisements
Similar presentations
Program.-(9)* Write a program Input two numbers from keyboard and multiply of given values using by variables. Input value No 1 input value No2 Multiply.
Advertisements

Programming 8086 – Part IV Stacks, Macros
Array : To store multiple value in one variable, “but value must be homogenous or similar type” is called array. We can say in other word Arrangement of.
Program.(08) Write a program Divide 5 by 2 and display answer value and remainder value. 1 Store 5 into AL 2 Store BL into 2 3Divide AL Into BL 4Store.
Program.-(4)* Write a program for input two integer number with message and display their sum. Algorithm steps Algorithm steps 1.Display message for input.
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
10-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Subroutine and Interrupt.
Assembly Programming Notes for Practical2 Munaf Sheikh
Intel Computer Architecture Presented By Jessica Graziano.
Department of Computer Science and Software Engineering
Subroutines: Passing Arguments Using the Stack. Passing Arguments via the Stack Arguments to a subroutine are pushed onto the stack. The subroutine accesses.
More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.
80x86 Instruction Set Dr. Qiang Lin.
Memory model ModelDescription SMALLCode in one segment Data in one segment MEDIUMCode in > 1 segment Data in one segment COMPACTCode in one segment Data.
CS 206D Computer Organization
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
KMUTT: S. Srakaew Instructions Can Be Divided into 3 Classes Data movement instructions  Move data from a memory location or register to another memory.
IP high IP low IP high IP low BP high BP low IP high IP low BP high BP low FL high FL low CS high CS low IP high IP low _TEXTsegment byte public ‘CODE’
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
ICS312 Set 11 Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External.
8.4 Instruction Execution Times TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM.
Factorial of a number data segment x1 db 4 fact dw ? data ends
Assembly Language – Lab 5
Stack Operations LIFO structure (last-in,first-out) –The last value put into the stack is the first value taken out Runtime stack –A memory array that.
COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD.
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
Multiplication and Division Instructions & the 0Ah function.
Lecture 14 Basic I/O Interface Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
“It was the night before midterm”. Midterm rule (March 16 nd, 2005) - Student ID is required. Open books, note exam - Don’t: - Leave the exam room after.
Strings, Procedures and Macros
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
L AB 2. P ROGRAM STRUCTURE The assembly language program consist of code, data and stack. Data segment: contains all the variable definition..Data Code.
Program Control Instructions
Lecture 9 (The Stack and Procedures). 1 Lecture Outline Introduction The Stack The PUSH Instruction The POP Instruction Terminology of Procedures INDEC.
1 The Stack and Procedures Chapter 5. 2 A Process in Virtual Memory  This is how a process is placed into its virtual addressable space  The code is.
University of Tehran 1 Microprocessor System Design Omid Fatemi Machine Language Programming
Assembly Programming Practical2. Initialising Variables (Recap) Initialising variables are done in the.data section Initialising variables are done in.
BITS Pilani Pilani Campus Pawan Sharma Lecture /12/ EEE /INSTR/CS F241 ES C263 Microprocessor Programming and Interfacing.
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
Procedures Dr. Hadi Al Saadi Large problems can be divided into smaller tasks to make them more manageable A procedure is the ASM equivalent of a Java.
Format of Assembly language
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Additional Assembly Programming Concepts
Microprocessor and Assembly Language
Microprocessor and Assembly Language
Assembly Language Programming Part 2
(The Stack and Procedures)
Chapter 3 Addressing Modes
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Chapter 4: Instructions
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
Microprocessor Lab CSL1543 0:0:2
(Array and Addressing Modes)
(The Stack and Procedures)
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Miscellaneous Topics.
(The Stack and Procedures)
The JUMP GROUP Unconditional Jump (JMP).
Procedures & Macros Introduction Syntax Difference.
(The Stack and Procedures)
(Array and Addressing Modes)
Procedures and Macros.
Presentation transcript:

Lab 6 Stack

Push & Pop Instructions PUSH source POP destination Last in First Out, First in Last Out SP initialized to 100H which represent empty stack. SP might contain offset address. (Stack Not Empty) PUSH decreases SP by 2 POP increases SP by 2

Example 1 Swap contents of CX = 30H and BX=32H, display it before and after swapping org 100h MOV CX,30H ;moving contents into registers MOV BX,32H MOV AH,2 ;display first content MOV DX,CX INT 21H MOV AH,2 ;display second content MOV DX,BX MOV AH,9 ;display newline LEA DX,NL PUSH CX ;swapping contents PUSH BX POP CX POP BX MOV AH,2 ;display first contents MOV DX,CX INT 21H MOV AH,2 ;display second contents MOV DX,BX ret NL DB 0DH,0AH,"$"

Procedures Invoking procedures: CALL name name PROC ;body of procedure ret name ENDP Invoking procedures: CALL name

INDEC / OUTDEC Input and display it in a new line. org 100h CALL INDEC MOV BX,AX MOV AH,9 LEA DX,NL INT 21H MOV AX,BX CALL OUTDEC ret NL DB 0DH,0AH,"$" INCLUDE 'PGM9_1.ASM' INCLUDE 'PGM9_3.ASM' END

Exercise Let the user input 2 numbers and display the result of multiplication.

Solution org 100h CALL INDEC MOV BX,AX CALL NEWL XOR AX,AX MUL BX XOR BX,BX MOV AX,BX CALL OUTDEC ret NL DB 0DH,0AH,"$" NEWL PROC MOV AH,9 LEA DX,NL INT 21H RET NEWL ENDP INCLUDE 'PGM9_1.ASM' INCLUDE 'PGM9_3.ASM' END