Download presentation
Presentation is loading. Please wait.
1
Microprocessor and Assembly Language
Lecture-12-Multiplication and Division Instructions Muhammad Hafeez Department of Computer Science GC University Lahore
2
Today’s Agenda Signed and Unsigned Multiplication
Signed and Unsigned Division
3
Multiplication Instructions
The process of multiplication is different for signed and unsigned numbers Example: Take 2 number and As unsigned numbers are 255 and 128 Product = 32640 As signed numbers are -128 and -1 Product = 128
4
Instruction for Signed and Unsigned Multiplication
MUL is used for Unsigned multiplication IMUL is used for singed multiplication Syntax is: MUL Source IMUL Source
5
Byte Form For byte x byte, one operand must be in source
Second operand is assumed in AL register 16-bit result is stored in AX register The source must be a register or a memory location, constants are not allowed
6
Word Form For Word multiplication one number must be in source
Second number is assumed in AX register 32-bit result is stored in DX:AX DX holds the Most significant bits AX holds the Least Significant bits
7
Examples: Translate A= 5 x A – 12 X B using IMUL Instruction.
8
Examples:
9
Division Instructions
DIV instruction is used for unsigned division Syntax: DIV Divisor IDIV instruction is used for signed division Syntax IDIV Divisor
10
Division Instructions
Byte Form: The divisor is 8-bit register or memory location The dividend is 16-bit that is assumed to be in AX After division AL = Quotient AH = Remainder Divisor must not be a constant
11
Division Instructions
Word Form: The divisor is 16-bit register or memory location The dividend is 32-bit that is assumed to be in DX:AX After division AX = Quotient DX = Remainder Execution of DIV or IDIV could result in divide overflow
12
Decimal Input/ Output In memory everything is represented in binary.
Decimal Input and Output could be done through a program
13
Decimal Input/ Output In memory everything is represented in binary.
Decimal Input and Output could be done through a program
14
Decimal Output
15
Decimal Output
16
Test Program
17
Decimal Input Convert a string of ASCII digits to the binary representation of a decimal equivalent
18
Decimal Input
19
Decimal Input
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.