Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
(Microprocessor Programming)
Roll No. _________________ GCU Lahore Date _________________
Introduction
Multiplication
The multiplication in microprocessor can be different for signed and unsigned numbers e.g., if
we have two eight bit numbers 10000000 and 11111111 then their unsigned multiplication gives
the result equal to 32640. But if we treat these numbers as signed numbers then the resultant is
equal to -128 (128X-1). For unsigned numbers MUL instruction is used while for signed IMUL
is used.
Syntax:
MUL source
IMUL source
Division
When division is performed, we obtain two results, the quotient and the remainder. As with the
multiplication, there are separate instructions for signed and unsigned numbers division. DIV is
used for the unsigned and IDIV is used for signed numbers division.
Syntax:
DIV divisor
IDIV divisor
Divide Overflo
It is possible that the quotient will be too big to fit in the specified destination (AL or AX). This
can happen if the divisor is too small as compared to dividend. When this happens the program
terminates usually and the system displays the message “divide overflow”.
EXERCISE
1. What does CWD command do?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Microprocessor Based Systems Lab Manual 7
(Microprocessor Programming)
Roll No. _________________ GCU Lahore Date _________________
3. Give the new values of AX and CF/OF for each of the following instructions.
MUL BL, if AL contains ABh and BL contains 10h.
MUL AH, if AX contains 01ABh.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
4. Write down a program to calculate the factorial of a number.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
5. Write assembly language code for each of the following high level language assignment
statements. Suppose that A,B,C are word variables and all product will fit in 16 bits. Use
IMUL for multiplication. It is not necessary to preserve the contents of A, B, and C.
A = 5 x A – 12 x B
Microprocessor Based Systems Lab Manual 7
(Microprocessor Programming)
Roll No. _________________ GCU Lahore Date _________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________