Assembly Language – Lab 5

Slides:



Advertisements
Similar presentations
Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4.
Advertisements

1 x86’s instruction sets. 2 Instruction Set Classification  Transfer Move  Arithmetic Add / Subtract Mul / Div, etc.  Control Jump Call / Return, etc.
Department of Computer Science and Software Engineering
Computer Organization & Assembly Language
Assembly Language Lecture 9
1 Multiplication, Division, and Numerical Conversions Chapter 6.
80x86 Instruction Set Dr. Qiang Lin.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, MUL Instruction The MUL (unsigned multiply) instruction.
1 Lecture 7 Integer Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may.
Shift and Rotate Instructions
Chapter 4 Basic Instructions. 4.1 Copying Data mov Instructions mov (“move”) instructions are really copy instructions, like simple assignment statements.
CE302 Outline Multiplication Division Program Segment Prefix Command Line Parameters.
MUL Instruction (Unsigned Multiply) Multiplies an 8-, 16-, or 32-bit operand by either AL, AX or EAX. MUL r/m8 MUL r/m16 MUL r/m32.
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.
ASCII and BCD Arithmetic Chapter 11 S. Dandamudi.
Multiplication and Division Instructions & the 0Ah function.
Arithmetic Flags and Instructions
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Integer Arithmetic Computer Organization and Assembly Languages Yung-Yu Chuang 2007/12/24 with slides by Kip Irvine.
Assembly Language for Intel-Based Computers Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may modify and copy.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman.
Lab 6 Stack.
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 6.
Assembly Language for Intel-Based Computers, 4 th Edition Unpacked and Packed Integers (c) Pearson Education, All rights reserved. You may modify.
Lecture 9 (The Stack and Procedures). 1 Lecture Outline Introduction The Stack The PUSH Instruction The POP Instruction Terminology of Procedures INDEC.
Microprocessor MA Rahim Khan Computer Engineering and Networks Department.
Chapter 7: Integer Arithmetic. 2 Chapter Overview Shift and Rotate Instructions Shift and Rotate Applications Multiplication and Division Instructions.
Irvine, Kip R. Assembly Language for Intel-Based Computers. Chapter 7: Integer Arithmetic Slides to Accompany Assembly Language for Intel-Based Computers,
ICS 312 SET 10 Multiplication & Division & input using function 0Ah.
The Assemble, Unassemble commands of the debugger: U Command for converting machine code language source Equivalent machine code instructions Equivalent.
Introduction Arithmetic instructions are used to perform arithmetic operation such as Addition Subtraction Multiplication Division These operations can.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
ECE 353 Introduction to Microprocessor Systems Michael J. Schulte Week 6.
Multiplication and Division instructions Dr.Hadi AL Saadi.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
Computer Architecture and Assembly Language
Format of Assembly language
Data Transfers, Addressing, and Arithmetic
Assembly Language for Intel-Based Computers, 5th Edition
Multiplication and Division Instructions
Assembly Language Programming Part 2
CS-401 Computer Architecture & Assembly Language Programming
(The Stack and Procedures)
4.2 Arithmetic Instructions
X86’s instruction sets.
Chapter 4: Instructions
Stack and Subroutines Module M17.1 Section 11.2.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Microprocessor and Assembly Language
8086 Registers Module M14.2 Sections 9.2, 10.1.
(The Stack and Procedures)
Multiplication and Division Instructions
Assembly Language for Intel-Based Computers, 4th Edition
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 5th Edition
Computer Architecture and System Programming Laboratory
EECE.3170 Microprocessor Systems Design I
Chapter 5 Arithmetic and Logic Instructions
Multiplication and Division Instructions
Multiplication and Division Instructions
(The Stack and Procedures)
Division instruction.
Computer Architecture and System Programming Laboratory
(The Stack and Procedures)
Presentation transcript:

Assembly Language – Lab 5 MUL, DIV, Stack, INDEC, OUTDEC

MUL/IMUL Instructions The MUL (Multiply) instruction handles unsigned data and the IMUL (Integer Multiply) handles signed data. Example - 8-bit unsigned multiplication (5 * 10h): MOV AL,5H MOV BL,10H MUL BL ; CF=0

Example 1 Program to multiply two 8 bit numbers.

DIV/IDIV Instructions The division operation generates two elements - a quotient and a remainder. The DIV instruction is used or unsigned data and the IDIV is used or signed data.

DIV/IDIV Instructions (Example) Divide 8003h by 100h, using 16-bit operands: MOV DX,0 ; clear dividend, high MOV AX,8003H ; dividend, low MOV CX,100H ; divisor DIV CX ; AX = 0080h, DX = 3

CBW, CWD Instructions CBW (convert byte to word) extends AL into AH If bit 7 of AL is a 1, the instruction will place FF in AH. If bit 7 of AL is a 0, the instruction will place 00 in AH. CWD (convert word to doubleword) extends AX into DX If bit 15 of AX is a 1, the instruction will place FFFF in DX. If bit 15 of AX is a 0, the instruction will place 0000 in DX. NOTE: Use this instruction only with signed arithmetic.

Example 2 Divide 16 bit numbers by an 8 bit numbers.

PUSH/POP Instructions (Stack) LIFO (Last-In, First-Out) data structure, items are added and removed from one end of the structure. To ‘push’ an item means to insert it, and to ‘pop’ an item means to remove it. Managed by the CPU, using two registers: SS (stack segment) ESP (stack pointer): point to the top of the stack. SS stack segment ESP memory

Example 3 Program to swap the content of AX and BX.

Procedures The procedure start with the name of the procedure followed by PROC (reserved word), at the end of procedure write RET, also the procedure name followed with ENDP. To invoke a procedure, the CALL instruction is used. name PROC . RET name ENDP

INDEC / OUTDEC Procedures Procedures used to read and print decimal data. INDEC Code of INDEC exist in file PGM9_3.ASM OUTDEC Code of OUTDEC exist in file PGM9_1.ASM Include the two files using INCLUDE directive. Syntax: INCLUDE C:\emu8086\MySource/PGM9_3.ASM INCLUDE C:\emu8086\MySource/PGM9_1.ASM

OUTDEC Procedure PGM9_1.ASM

INDEC Procedure PGM9_3.ASM

INDEC Procedure PGM9_3.ASM

INDEC / OUTDEC Procedures MAIN PROGRAM