Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

byte to ansi converter

Status
Not open for further replies.

TKS

New Member
Hi all, think this is a common problem??/

I have a value in an byte for example.. 255

but what i want is that it sends this out as "255" sow in stead of sending out the port 255 it should send 50,53,53 (ansII numbers of the digits)

anyone can help???

Regards,

Tks
 
Here ya go.

Code:
Bin2Decimal     clrf    Decimal100
Count100s       incf    Decimal100,F
                addlw   100h-100;	-100
                btfsc   STATUS,C
                goto    Count100s
                addlw   100
                clrf    Decimal10
Count10s        incf    Decimal10,F
                addlw   0f6h;		-10
                btfsc   STATUS,C
                goto    Count10s
                movwf   Units
                movfw   Decimal100
                addlw   2fh
                movwf   Decimal100
                movfw   Decimal10
                addlw   2fh
                movwf   Decimal10
                movfw   Units
                addlw   30h+0ah
                movwf   Units
                return

Call it with the value in W.

Mike.
 
....

isn't that binary to decimal converter??

don't you need an lookup table or something for the ascii number of the digit??

anyway i invented a trick in the compiler i use sow its already solved...

Tks
 
It does exactly what you asked for in your first post. Place 255 in W, call the code and 50,53 & 53 will be in Decimal100, Decimal10 and Units. All magically done without a lookup table.

Mike.
 
yeah okey!

sow what we now need is to look up the 100's for example 2 and search the right ansii number for it..wich is 50...

etc.. right??

its the base??

Tks

if i'm wrong in wich part the ansii code is added??
 
Re: yeah okey!

TKS said:
sow what we now need is to look up the 100's for example 2 and search the right ansii number for it..wich is 50...

etc.. right??

its the base??

Tks

if i'm wrong in wich part the ansii code is added??

If you look at the code after the line "goto Count10s" the calculated values have constants added to them to make them into the ascii (ansii) code. The added values vary due to the way the code works.

If you have MPLAB then just copy it into it and run the simulator.

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top