If you want ASCII Hex then every binary number in the range 0-9 should be added to 48 because ASCII 48 is character zero.
But what about after 9?
Well Melanie has posted a solution while back:
Code:
MyVar var word
' Variable containg 16-bit value
' MyVar's contents are destroyed on exit
MyData var byte (4)
' Four byte Array containing ASCII HEX result
' MSB is in MyData(3), LSB is in MyData(0)
CounterA var byte
' General Purpose Counter
For CounterA=0 to 3
MyData(CounterA)=MyVar&$0F
MyData(CounterA)=MyData(CounterA)+48
If MyData(CounterA)>57 then
MyData(CounterA)=MyData(CounterA)+7
endif
MyVar=MyVar>>4
Next CounterA
Hope this helps,
Ioannis
Bookmarks