Sunday, September 13, 2009

ASCII to Decimal Conversion (8085)

Statement: convert the ASCII number in memory to its equivalent decimal number


Source Program:
LXI H, 4150 : Point to data
MOV A, M : Get operand
SUI 30 : convert to decimal
CPI 0A : Check whether it is valid decimal number
JC LOOP : yes, store result
MVI A, FF : No, make result=FF
LOOP: INX H
MOV M, A
HLT : (A) = (4151)
.

Note: The ASCII Code (American Standard Code for Information Interchange) is commonly used for communication. It is a seven bit code. In this code number 0 through 9 are represented as 30 through 39 respectively and letters A through Z are represented as 41H through 5AH. Therefore, by subtracting 30H we can convert an ASCII number into its decimal equivalent.
google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);

No comments:

Post a Comment