February 13, 2012
Write a program to multiply two 8 bit numbers, output more than 8 bit number using memory location and repetitive addition method.
Apparatus Used: Microprocessor kit, Keyboards
Assumption: Suppose in this case first number is stored at 2050 and second number is stored at 2051. Multiplication can be achieved by adding the multiplicand repeatedly as many times as the multiplier. As 05*08. 05+05+05+05+05+05+05+05=40
Algorithm:
- Start the Program by loading HL register pair with address of memory location.
- Move data in Register B.
- Get second number and load into accumulator.
- Add Second number and accumulator.
- Check for the carry
- Increment the value of carry.
- Check whether repeated addition is over and the store the value of product and carry at memory location.
- End the Program.
Program:
Memory Add
|
Mnemonics
|
Op-code
|
Comments
|
2000
|
MVI
|
D, 00 H
|
Initialize register D to 00
|
2002
|
MVI
|
A,00 H
|
Clear the accumulator
|
2004
|
LXI
|
H,2050
|
Store first input location
|
2007
|
MOV
|
B,M
|
Store first number into B
|
2008
|
INX
|
H
| |
2009
|
MOV
|
C,M
|
Get Second Number in Register C
|
200A
|
ADD
|
B
|
Add Register B and Accumulator
|
200B
|
JNC
|
200F
|
Jump of no carry at 200F
|
200E
|
INR
|
D
|
Increment content of Register D
|
200F
|
DCR
|
C
|
Decrement counter by one
|
2010
|
JNZ
|
200A
|
Repeat until the value of C=0
|
2013
|
STA
|
2052
|
Store output
|
2016
|
MOV
|
A,D
| |
2017
|
STA
|
2053
|
Store the carry at this location
|
201A
|
RST
|
5
|
Set Break-point
|
201B
|
END
|
End the program
|
Description of used instruction:
MVI: This instruction is used to store 8 bit data in specified register.
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
MOV rd,M: This instruction copies data from the Memory to destination register.
INX: This instruction is used to increment the content of register pair by one.
ADD: This instruction is used to add the content of specified register to the content of accumulator and store output in accumulator.
DCR: This instruction is used decrement the content of specified register by 1.
JNC: Jump if not carry at specified memory address.
JNZ: If result is not zero it will jump to the target address.
INR: It will increment the content of specified register by one.
STA: This instruction is used to store the content of accumulator at specified memory address.
RST 5: This instruction is used to set break-point for the execution.
END: This instruction is used to execute the program.
Result:
Input:
2050-FF
2051-FF
Output:
2052 H- 01 H
2053 H- FE H
Procedure to look output
· After press ENTER, You will get first screen
· Press G and Provide Initial address (as 2000)
· Press SHIFT+4,You will get first screen again
· Press M and Provide Input location for Input (M2050)
· Press ENTER and Provide your Input at location (2050: FF)
· Press ENTER and Provide your Second Input (2051 :FF)
· Press SHIFT+4
· Press G and Provide Initial address (as 2000)
· Press SHIFT+4,You will get first screen again
· Press M and Provide address for output (M2052) and press ENTER
· You will get your desired output.
Subscribe to:
Post Comments (Atom)
Load 89H in C register and Mask higher 4 bits and store lower 4 bits in a memory location.
ReplyDeleteShikhar Sharma
shikharraj@rediffmail.com
ANI 0FH
DeleteHi Shekar
ReplyDeleteIn days I m little busy in my exam schedule. After this definitely i will post answer of it. Just wait till 23 Feb. You will get answer of this.
not getting program at 1 point sir, i.e..
ReplyDeletewhy decremented counter,as we have not set any counter in the beginning..
rply plzz
@(rahulsingh062@gmail.com)
HI rahul
ReplyDeletelook at
2009 MOV C,M Get Second Number in Register C
you will get your answer...