Please update your Flash Player to view content.

                  FOLLOW  US





 
 
8-bit HEX to ASCII Convertor
Code Library - 8051 Assembly
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

                                                     .

 

Comments  

 
0 # pratyathedon 2011-11-02 11:01
Hey guyz this is a very nice code.After searching thousand places i got this.One note for pplz to add your print routine of LCD after "orl" syntax.This code works.Thank you for the Author.
Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh

 

Featured Products

Rs1 800.00

Rs1 800.00

 

Random Products

Rs17.00



Rs12.00



Rs28.00



Rs6.00



Rs280.00



Latest Video

Random Articles

  • Semiconductor Basics
    Semiconductor Basics If Resistors are the most basic passive component in...
  • The Junction Diode
    The Junction Diode The effect described in the previous tutorial is achieved...
  • Resistor Power
    Resistor Power Rating When an electrical current passes through a resistor,...
  • MOSFET as a Switch
    The MOSFET s a Switch We saw previously, that the N-channel, Enhancement-mode...

Search Products

User Login






 
 
.
 TUTORIALS
.
  8051 Tutorial
 
  Power Supply
 
CODE LIBRARY
.

  8051 Assembly
 
  C Code Library

.
 PROJECTS
.
  Project List
 
  Synopsis and Abstract
 
DOWNLOADS
.

  Datasheets
 
  Download

.
 POPULAR
.
  About Us
 
  DNA Shop
 
  Totorial
 
  Code Library
 
  Download
 

.
 CONTACT US
.

Mr. Amol Shah

DNA Technology Nashik,

Maharashtra 422009 India

Phone : 0253-3023939

Mobile : 09225145135

Email : contact@dnatechindia.com