ASCII to Decimal Conversion

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.

Post a Comment

1 Comments

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)

Close Menu