Upload
nitesh-02
View
215
Download
0
Embed Size (px)
Citation preview
7/31/2019 Exp 04
1/5
Experiment No: 04
AIM:
A. To write and execute an assembly language program to multiply two 8-bit numbers stored in
memory at 4400 H & 4401H and store the 16-bit result from 4405H.B. To write and execute an assembly language program to multiply two 8-bit numbers stored in
memory at 4400 H & 4401H and store the quotient at 4405H and remainder at 4406H.
APPARATUS: 8085 Microprocessor trainer kit and keyboard.
ALGORITHM:
A. Multiplication-
1. Get address of first number in H-L pair.
2. Store the first number (multiplier) in register B.
3. Clear register C.
4. Increment H-L pair to point to multiplicand.5. Clear accumulator.
6. Add contents of register A and memory pointed by H-L pair.
7. Check if carry generated.
8. If no go to step 9, if yes increment register C.
9. Decrement register B.
10. Check if B is zero.
11. If yes go to step 12, if not repeat steps from 6.
12. Store the lower byte of result in register A at memory location 4405H and higher byte
result in register C at 4406H.
13. Stop.
B. Division-
1. Initialize H-L with the address of the numbers.
2. Take the dividend in A.
3. Clear C to store quotient.
4. Subtract the divisor from dividend.
5. If dividend < divisor then go to step 7.
6. Increment quotient and repeat steps 4 to 6.
7. Store the quotient and remainder in memory.
8. Stop.
7/31/2019 Exp 04
2/5
FLOWCHART:
A. Multiplication-
Start
Clear C & A, H-
L=H-L+1
Store the
multiplier in
register B
Initialize H-L
register pair with
the address of
multiplier
Stop
A=A+[H-L]
Is
CY=0
B=B-1
Increment C
Is
Z=1
Initialize H-L pair
with 4405H & store
[H-L]A,
[H-L+1]C
Yes
No
Yes
No
7/31/2019 Exp 04
3/5
B. Division-
PROGRAM:A. Multiplication-
Memory
AddressLabel
InstructionComments
Mnemonics Operand
4200 LXI H, 4400HInitialize H-L pair with the address of
first number
4203 MOV B, M Store the first number (multiplier) in B
4204 MVI C, 00H Clear C to store higher byte of result
4206 INX HIncrement H-L pair to point to
multiplier
4207 MVI A, 00H Move 00H in A
4209 L2: ADD M Add A with data in memory pointed byH-L pair
Start
H-L4400H,A[H-L], C00H
Stop
Is
CY=0
C=C+1
A=A+[H-L]
Yes
No
H-L=H-L+1
A=A-[H-L]
[H-L]=[H-L]+4
[H-L]C &
[H-L+1] A
7/31/2019 Exp 04
4/5
420A JNC L1 Jump to L1 if no carry is generated
420D INR C Increment the C (higher byte result)
420E L1: DCR B Decrement B (multiplier)
420F JNZ L2 Jump to L2 if B is nit zero
4212 LXI H, 4405H
Initialize H-L pair with the address of
result
4215 MOV M, AStore the lower byte of result in
memory
4216 INX H Increment H-L
4217 MOV M, C Store higher byte of result in memory
4218 HLT Stop
Division-
Memory
AddressLabel
InstructionComments
Mnemonics Operand
4200 LXI H, 4400H Initialize H-L with the address of thedividend
4203 MVI C, 00H Clear C to store quotient
4205 MOV A, M Take dividend in A
4206 INX H Increment H-L to point to divisor
4207 L2: SUB M Subtract A-[H-L]
4208 JC L1 Terminate loop if A < [H-L]
420B INR C Increment quotient
420C JMP L2 Jump to L1
420F L1: ADD M Recover the remainder
4210 INX H Increment H-L
4211 INX H Increment H-L
4212 INX H Increment H-L
4213 INX H Increment H-L
4214 MOV M, C Store the quotient in memory
4215 INX H Increment H-L
4216 MOV M, A Store the remainder in memory
4217 HLT Stop
RESULT:
Memory-
A. Multiplication-Memory Address Data
4400
4401
4402
4403
4404
4405
4406
B. Division-
Memory Address Data
4400
7/31/2019 Exp 04
5/5
4401
4402
4403
4404
4405
4406
QUESTIONS:
1. Write a program to find square of a given number.
2. Write a program to multiply 8-bit no using DAD instructions.