January 24, 2012
Write a program to multiply two 8 bit numbers, output 8 bit number
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:
- Clear the accumulator.
- Store first number in Register C.
- Get second number.
- Add Second number and accumulator.
- Decrement counter by one.
- Check counter is zero or not. If counter is not zero repeat addition.
- Store output at given location.
Program:
Memory Add
|
Mnemonics
|
Op-code
|
Comments
|
2000
|
MVI
|
A, 00 H
|
Clear the accumulator
|
2002
|
LXI
|
H,2050
|
Store first input location
|
2005
|
MOV
|
B,M
|
Store first number into C
|
2006
|
INX
|
H
|
Get Second Number
|
2007
|
ADD
|
B
|
Add second Number and Accumulator
|
2008
|
DCR
|
M
|
Decrement counter by one
|
2009
|
JNZ
|
2007
|
Repeat until the value of C=0
|
200C
|
STA
|
2052
|
Store output
|
200F
|
RST
|
5
|
Set Break-point
|
2010
|
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.
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.
JNZ: If result is not zero it will jump to the target address.
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-08
2051-05
Output: A=05*08=40 (28) H and it will store at external memory 2052H.
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: 08)
- Press ENTER and Provide your Second Input (2051 :05)
- 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)
After looking over a handful of the articles on your web
ReplyDeletepage, I seriously appreciate your technique of blogging.
I book marked it to my bookmark webpage list and
will be checking back in the near future. Take
a look at my website too and tell me what
you think.
Feel free to visit my website - test