You are on page 1of 5

Experiment No.

: 02 Experiment Name
Objective : Familiarization with multiplication & division process in Microprocessor. Carry out multiplication & division. Familiarization with loop operation & do loop operation with factorial. Theory : MULTIPLICATION : Two hexadecimal digits can be multiplied to produce a one or two-digit product. Putting the multiplicand in AL and the multiplier in a register or memory byte. After multiplication , AX contains the product. For 16 bit , multiplicand is put into AX & the multiplier in a register or memory byte, after multiplication , AX contains the product and DX contains the higher terms(for word multiplication).
:

Study of Multiplication, Division & Loop operation

Syntax MUL reg Or, AL* reg AX* reg

Result AX [for 8 bit]

DX:AX [for 16 bit]

DIVISION : Two hexadecimal digits can be divided to produce a one or two-digit quotient. The quotient is stored as a two digit hexadecimal number. The dividend in put into AX & the divisor in a register or memory byte. for 8 bit number, after division AH contains the remainder while AL contains the quotient. for 16 bit number, after division DX contains the remainder while Ax contains the quotient.

Syntax DIV reg Or, AX / reg DX: AX / reg

Result AH(remainder) , AL(quotient) [for 8 bit] DX(remainder) , AX (quotient) [for 16 bit]

LOOP OPERATION : A loop is a sequence of instructions that is repeated. The number of times to repeat may be known in advance , or may depend on conditions. Loop address CX is used as the loop counter.

ASSEMBLY INSTRUCTION SET USED IN THIS EXPERIMENT : 1) MOV : Move Move data Format : MOV destination, source Operation : Copies byte (8 bits) or word (16 bits) from specified source to specified destination.

2) MUL : Multiply Unsigned multiplication Format : MUL source Operation : Multiply unsigned byte by byte or word by word.

3) DIV : Divide Performs unsigned division. Format : DIV source Operation : Divide unsigned byte by byte or word by word.

4) LOOP Loop until count is complete. Format : LOOP short-1 bel Operation : Loop through a sequence of instruction until CX = 0. CX is decremented by 1 & if the result is not zero then control is transferred to labeled instruction; otherwise control flows to the next instruction.

5) INT : Interrupt Transfers control to one of 256 interrupt routines. Format : INT interrupt type Operation : Interrupt program execution , call a service program.

Experiment Code :

MULTIPLICATION :

1) A Code to multiply two hexadecimal number 12 and 13 (for 8 bit * 8 bit) : Code : MOV AL,12 MOV BL,13 MUL BL INT 3 Result : AX = 0156 Comment : After multiplication with BL ,the result is saved into AX as the result is above 8 bits .

2) A Code to multiply two hexadecimal number 0431 and 0A12 (for 16 bit *16 bit) : Code : MOV AX,0431 MOV BX,0A12 MUL BX INT 3 Result : DX : AX = 002A : 3572 Comment : After multiplication with BX ,the result is saved into DX:AX as the result is above 16 bits .

DIVISION :

1) A Code to divide two hexadecimal number 145 to 12 (for 16bit / 8bit) : Code : MOV AX,145 MOV BL,12 DIV BL INT 3 Result : AX = 0112 Comment : After division with BL ,the result is saved into AX as the result is above 8 bits . As AX has two part AH & AL , the quotient of the division 12 is saved into AL and the remainder of the division 01 is saved into AH.

2) A Code to divide two hexadecimal number 0431 0A12 to F213 : (for 32 bit / 16 bit) Code : MOV DX,0431 MOV AX,0A12 MOV BX,F213 DIV BX INT 3 Result : DX : AX = B9E8 : 046E Comment : After division with BX ,the result is saved into DX:AX as the result is above 16 bits .The quotient of the division 046E is saved into AX and the remainder of the division B9E8 is saved into DX. LOOP OPERATION : We want to find the value of 5! (in hexadecimal) Using Assembly language . Code : Address 0400 0403 0406 0408 040A 040C Code MOV CX,5 MOV AX,1 MOV BX,CX MUL BX LOOP 0406 INT 3

Result : AX = 0078 ; BX = 0001 ; CX = 0000 Comment : Hexadecimal of 5! = 78 , here Loop through a sequence of instruction until CX = 0. CX is decremented by 1 ,the loop terminates when CX=0 and and the result saved into AX .

You might also like