Product categories

Have You Seen

B0505S-1WR3 MORNSUN Isolated DC - DC Converter

B0505S-1WR3 MORNSUN Isolated DC - DC Converter

Mornsun B0505S-1WR3 DC-DC Isolated ConverterMORNSUN B0505S 1WR3 1 watt, 5 Volts Isolated DC to DC Po..

Rs.106.20 (inc GST)
Rs.90.00 + GST

SKU: 2969 | DAE663
Stock: 40
XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)

XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)

XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)XL1509-Adj E1 Buck DC to DC Converter IC, Ad..

Rs.25.96 (inc GST)
Rs.22.00 + GST

SKU: 3657 | DAF397
Stock: 485

8-bit HEX to ASCII Convertor



This subroutine converts 8 bit Hexadecimal number into its equivalent ASCII value. The number to be converted should be in the Accumulator. The output ASCII number is stored in R0, R1 and R2. R0 contains the MSB i.e. the Hundreds place, R1 contains the Tens Place and R2 contains the LSB i.e. the Units Place.
The ASCII code for numbers 0-9 is 48-57 i.e. 30h – 39h

hextoascii:

mov r0,#30h

mov r1,#30h

mov r2,#30h

cjne a,#00h,c1_hextobcd //check if number is 0 if not then continue
ret

c1_hextobcd:

clr c

mov b,#100

//divide by 100

div ab

orl a,r0

mov r0,a

//save 100th place in R0

clr c

mov a,b

mov b,#10

//Divide by 10

div ab

orl a,r1

mov r1,a

//Save 10th place in R1

mov a,b

orl a,r2

mov r2,a

//Save  units place in R2

ret

.

Written by Administrator

Administrator

Administrator