Exp 04
Exp 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. Multiplication1. 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. Division1. 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.
FLOWCHART: A. MultiplicationStart Initialize H-L register pair with the address of multiplier Store the multiplier in register B Clear C & A, HL=H-L+1
A=A+[H-L]
No Increment C
Is Z=1 Yes
No
Initialize H-L pair with 4405H & store [H-L]A, [H-L+1]C Stop
PROGRAM: A. MultiplicationMemory Label Address 4200 4203 4204 4206 4207 4209 L2:
Instruction Mnemonics Operand LXI MOV MVI INX MVI ADD H, 4400H B, M C, 00H H A, 00H M
Comments Initialize H-L pair with the address of first number Store the first number (multiplier) in B Clear C to store higher byte of result Increment H-L pair to point to multiplier Move 00H in A Add A with data in memory pointed by H-L pair
420A 420D 420E 420F 4212 4215 4216 4217 4218 DivisionMemory Address 4200 4203 4205 4206 4207 4208 420B 420C 420F 4210 4211 4212 4213 4214 4215 4216 4217
L1:
L1 C B L2 H, 4405H M, A
H M, C
Jump to L1 if no carry is generated Increment the C (higher byte result) Decrement B (multiplier) Jump to L2 if B is nit zero Initialize H-L pair with the address of result Store the lower byte of result in memory Increment H-L Store higher byte of result in memory Stop
Label
Instruction Mnemonics Operand LXI MVI MOV INX SUB JC INR JMP ADD INX INX INX INX MOV INX MOV HLT H, 4400H C, 00H A, M H M L1 C L2 M H H H H M, C H M, A
Comments Initialize H-L with the address of the dividend Clear C to store quotient Take dividend in A Increment H-L to point to divisor Subtract A-[H-L] Terminate loop if A < [H-L] Increment quotient Jump to L1 Recover the remainder Increment H-L Increment H-L Increment H-L Increment H-L Store the quotient in memory Increment H-L Store the remainder in memory Stop
L2:
L1:
RESULT: MemoryA. MultiplicationMemory Address 4400 4401 4402 4403 4404 4405 4406 B. DivisionMemory Address 4400
Data
Data
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.