Microprocessor and Interfacing Theory Assignment-1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

11) t.

~
P>: /7.f!Jat-
p:p; 1_,t)ZcJA.__

4/111 t O o!CJ A._

Yz/-: /D{OA-

,-) (t1 V ,1,xI ,)/I/.#ct' {IXJ


l¾f-~ M,~/t ~ti~
t&~!PU_
M,A~{/JJ)
< fj ·, Pf f(~A 'f [ lt-ft(/117)

: l7.tJO Xtorf [ltJ/0..-rtJtJtt:_j


: (;o Z'V(1

/_ft{-:/> 7/t&A .P[pX-fp-:t +t1!2l1/J


: rioo I-ti) f [(oco+ oot~f-1llzoJ

rliL 8 -
:_ c;-o~tJI/
ZWL&&iiii ::...------
Microprocessor and Interfacing theory Assignment-1
Name: Sriharsha Chinta

Reg.No: 20BCE2049

Slot: D2

Question & Answer-2

The MUL instruction deals with the multiplication of two unsigned numbers. There are
types of multiplication depending on the number of bits:

• Byte with byte


• Word with Word
• Byte with word

Example-Assembly Language Program


MOV AL, 5H ; a byte is moved to AL
MOV BL, 10H ; immediate data must be in BL register
MULBL ; AX = 0050h, CF = 0

Emulator Result
16-Bit Multiplication

Example-Assembly Language Program

The following statements multiply the 16-bit value 2000H by 0100H. The Carry flag is set
because the upper part of the product (located in DX) is not equal to zero:

MOV AX, 2000H ; a word is moved to AX

MOV BX, 0100H ; immediate data must be in BX register

MULBX ; DX:AX = 00200000H, CF = 1

Emulator Result
The IMUL instruction allows the multiplication of two signed operands. The operands can
be positive or negative. When the operand is a byte, it is multiplied with AL register and
when it is a word, it is multiplied with AX register. The operation of MUL and IMUL
instructions are same. The only difference between two is one deals with the multiplication
of unsigned numbers and the other deals with signed operands.

If the product of multiplier and multiplicand produce result that fits into the destination
register DX and AX with some of the bits left unused. Then these unused bits are filled with
the copies of signed bit and clear CF and OF flags to zero.

Example-Assembly Language Program


The following instructions multiply 4 by 4, producing (-16) in AX. AH is a sign extension of AL
so the Overflow flag is clear

MOV AL, -4 ; a byte is moved to AL


MOV BL, 4 ; immediate data must be in BL register
IMULBL ; AX = FFF0H, OF = 0

Emulator Result
The main difference between MUL and IMUL is that MUL multiplies the 'unsigned
numbers'. IMUL multiplies 'signed numbers'.
Explanation:

• The MUL and IMUL are multiplication instructions. Here, MUL instructions used for
multiplying unsigned numbers. On the other hand, IMUL multiplies signed numbers.
• For these instructions, one factor should be in the accumulator register. The other
factor can be in any of the memory operand or single register.
• The IMUL instruction with multiple operands can be used for both signed – unsigned
multiplication. This is because, the 16 bit product will be same in both case.

When multiplying N-bit number by other N-bit one, the low N bits of the result are the
same no matter whether you do the signed or unsigned. So both 32-bit MUL and IMUL
produce the same low 32 bits of result. For this reason though there are additional variants
of IMUL that can store result in any 32-bit register or memory location, there are no such
for MUL, since they would do exactly the same. The difference is in case when the result is
stored as 64 bits in EDX:EAX, and high 32 bits (in EDX) may differ.

Question & Answer-3

a) 3A.3

(3A.3) ₁₆ = (3 × 16¹) + (10 × 16⁰) + (3 × 16⁻¹) = (58.1875) ₁₀

b) 219.C

(219.C) ₁₆ = (2 × 16²) + (1 × 16¹) + (9 × 16⁰) + (12 × 16⁻¹) = (537.75) ₁₀

c) CA.DC

(CA. DC) ₁₆ = (12 × 16¹) + (10 × 16⁰) + (13 × 16⁻¹) + (12 × 16⁻²) = (202.859375) ₁₀
d) FBB.3

(FBB.3) ₁₆ = (15 × 16²) + (11 × 16¹) + (11 × 16⁰) + (3 × 16⁻¹) = (4027.1875) ₁₀

e) B8B.0E

(B8B.0E) ₁₆ = (11 × 16²) + (8 × 16¹) + (11 × 16⁰) + (0 × 16⁻¹) + (14 × 16⁻²) =


(2955.0546875) ₁₀

Question & Answer-4

a) SUB CX, BX

b) SUB DH, 0EEH

c) SUB BP, 33H

d) SUB CH, [SI]

e) SUB DX, [SI+10]

f) SUB AGAIN, AL

You might also like