February 29, 2012
Write an assembly language program to shift an eight bit data four bits right.
Apparatus Used: Microprocessor Kit, Keyboard
Algorithm:
- Load the data into accumulator
- Rotate the content of accumulator 4 times
- Store the result at memory location.
- End the Program
Program:
Memory Address
|
Op-code
|
Operand
|
Comments
|
2000
|
LDA
|
2500 H
|
Get Data into Accumulator
|
2003
|
RAR
|
Rotate accumulator right
| |
2004
|
RAR
|
Rotate accumulator right
| |
2005
|
RAR
|
Rotate accumulator right
| |
2006
|
RAR
|
Rotate accumulator right
| |
2007
|
STA
|
2501 H
|
Store output at location
|
200A
|
RST
|
5
|
Set Breakpoint
|
200B
|
END
|
End the program
|
2nd Method
Memory Address
|
Op-code
|
Operand
|
Comments
|
2000
|
LDA
|
2500 H
|
Get Data into Accumulator
|
2003
|
RRC
|
30 H
|
Rotate right without carry
|
2005
|
RRC
|
0A H
|
Rotate right without carry
|
2007
|
RRC
|
200C
|
Rotate right without carry
|
200A
|
RRC
|
07 H
|
Rotate right without carry
|
200C
|
STA
|
2501 H
|
Store output at location
|
200F
|
RST
|
5
|
Set Break-point
|
2010
|
END
|
End the program
|
Used Instruction:
LDA address: Load data into register A (accumulator) directly from the address given within the instruction.
RAR: Rotates the bits of accumulator right by one position, through the carry
RRC: Rotate the bits of the accumulator right by one position
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:
2500-58
Output:
2051-85 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 (M2500)
- Press ENTER and Provide your Input at location (2500:58)
- 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 (M2501) and press ENTER
- You will get your desired output.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment