March 13, 2012
Write a program to multiply a number by two using bit rotation technique.
Apparatus Used: Microprocessor, Keyboards
Assumption: In this program we have to write a program to multiply a number by two using bit rotation method. This program multiplies a hex number stored in 2050H and store the result at 2051 H using bit rotation technique.
Description of used instruction:
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
MOV: This instruction is used to copy the content from source register to destination register.
RAL: Rotate the bits of the accumulator left by one position, through carry
CMC: Complement the carry
STC: Sets the carry
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-1A
Output:
2051-34
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:1A)
· 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 (M2051) and press ENTER
· You will get your desired output.
Assumption: In this program we have to write a program to multiply a number by two using bit rotation method. This program multiplies a hex number stored in 2050H and store the result at 2051 H using bit rotation technique.
Algorithm:
- Load the number into accumulator
- Set the carry flag to zero
- Rotate accumulator through the carry
- Store the result
- End the program
Program:
Memory Add
|
Mnemonics
|
Op-code
|
Comments
|
2000
|
LXI
|
H,2050 H
|
Set the memory pointer
|
2003
|
MOV
|
A,M
|
Get the number in accumulator
|
2004
|
STC
|
Set the carry flag to 1
| |
2005
|
CMC
|
Complement the carry
| |
2006
|
RAL
|
Rotate accumulator left through carry
| |
2007
|
STA
|
2051 H
|
Store the result
|
200A
|
RST
|
5
|
Set the break point
|
200B
|
END
|
End the Program
|
Description of used instruction:
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
MOV: This instruction is used to copy the content from source register to destination register.
RAL: Rotate the bits of the accumulator left by one position, through carry
CMC: Complement the carry
STC: Sets the carry
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-1A
Output:
2051-34
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:1A)
· 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 (M2051) and press ENTER
· You will get your desired output.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment