March 12, 2012
Write a program to covert two nibbles into a hexadecimal number (packed number).
Apparatus Used: Microprocessor, Keyboards
Result:
Procedure to look output
Assumption: In this program we have to combine two nibble into a hexadecimal number. Let nibble are stored at 2501 and 2502 and we have to store hex number at 2503 H.
Algorithm:
- Load the MSB of number into accumulator
- Shift the four bits towards the left
- Store the shifted information into accumulator
- Point the next number(LSB) and perform the OR operation with accumulator
- Store the result
- End the program
Program:
Memory Add
|
Mnemonics
|
Op-code
|
Comments
|
2000
|
LXI
|
H,2501 H
|
Initialize memory pointer
|
2003
|
MOV
|
A,M
|
Move number into accumulator
|
2004
|
RLC
|
Move it to MSB
| |
2005
|
RLC
| ||
2006
|
RLC
| ||
2007
|
RLC
| ||
2008
|
INX
|
H
|
Get LSB of the Number
|
2009
|
ORA
|
M
|
Perform OR operation
|
200A
|
STA
|
2503 H
|
Store the result
|
200D
|
RST
|
5
|
Set Break-point
|
200E
|
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.
RLC: Each binary bit of the accumulator is rotated left by one. Bit D7 is placed in the position of D0 as well as carry flag.
MOV: This instruction is used to copy the content from source register to destination register.
INX: This instruction is used to increment the content of register pair by one.
ORA: Logically OR the contents of register/memory with the accumulator.
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.
Input:
2501-04
2502-05
Output:
2503-45
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 (M2501)
- Press ENTER and Provide your Input at location (2501:04)
- Press ENTER and Provide your Input at location (2502: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 (M2503) and press ENTER
- You will get your desired output.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment