February 26, 2012
Write an assembly language program to convert ASCII character into hexadecimal number.
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program such that it can convert any given ASCII character into hexadecimal number. As Hex code for 31 is 0B.
Assumption: We have to write a program such that it can convert any given ASCII character into hexadecimal number. As Hex code for 31 is 0B.
Algorithm:
- Load the data into accumulator
- Subtract 30 H from the accumulator
- Compare the content of accumulator with 0A H.
- If A< 0A H, Jump to address otherwise proceed next step.
- Subtract 07 H from the accumulator
- Store the result at memory location.
- End the Program
Program:
Memory Address
|
Op-code
|
Operand
|
Comments
|
2000
|
LDA
|
2500 H
|
Memory pointer Initialization
|
2003
|
SUI
|
30 H
|
Subtract 30 from A
|
2005
|
CPI
|
0A H
|
Compare with Accumulator
|
2007
|
JC
|
200C
|
Check for carry
|
200A
|
SUI
|
07 H
|
Subtract 07 from A
|
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.
SUI: This instruction is used to subtract the given content from the content of accumulator and store output in accumulator.
CPI: Compare 8-bit data with the content of accumulator.
JC: Jump if carry at specified memory 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:
2500-31
Output:
2051-0B H
Input:
2500-31
Output:
2051-0B 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:31)
- 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)
Cheap loft beds uk is primarily set off by the desire to
ReplyDeleteown a comfy house.
Feel free to surf to my site :: flip board