Searching \ for '[PIC]: Binary to Decimal conversion help' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/math/index.htm?key=binary+to+decimal
Search entire site for: 'Binary to Decimal conversion help'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Binary to Decimal conversion help'
2002\02\05@153323 by Tim Webb

flavicon
face
I have a number from 0 to 35 and I want to seperate the tens and the ones
into two seperate file registers
How do I do it using a 16F877 ?

Most of examples that I have found on the piclist are using instructions the
16f877 does not have.

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\02\05@154355 by Roman Black

flavicon
face
Tim Webb wrote:
>
> I have a number from 0 to 35 and I want to seperate the tens and the ones
> into two seperate file registers
> How do I do it using a 16F877 ?
>
> Most of examples that I have found on the piclist are using instructions the
> 16f877 does not have.


Just subtract 10 in a loop, checking for
carry, and inc the hi register once for
each subtract. I imagine your input number
is always <=99 so it is 10 subtracts at most
and will be a very quick calculation.
-Roman

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2002\02\05@154952 by Kevin Olalde

flavicon
face
Why doesn't something like Scott Dattalo's routine work for you?

http://www.piclist.com/techref/microchip/math/radix/b2bhp-8b3d.htm

Tim Webb wrote:
>
> I have a number from 0 to 35 and I want to seperate the tens and the ones
> into two seperate file registers
> How do I do it using a 16F877 ?
>
> Most of examples that I have found on the piclist are using instructions the
> 16f877 does not have.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2002\02\05@155154 by WEBB,TIM (A-Sonoma,ex1)

flavicon
face
Actually, I am taking a binary number from 0 - 255 and I want to display it
in decimal on an LCD Display.

That means that I will have to calculate each of the three numbers and then
add 0x30 to convert them to ASCII.

{Original Message removed}

2002\02\05@155607 by Andrew Warren

flavicon
face
Tim Webb <.....PICLISTKILLspamspam.....mitvma.mit.edu> wrote:

> I have a number from 0 to 35 and I want to seperate the tens and the
> ones into two seperate file registers How do I do it using a 16F877 ?
>
> Most of examples that I have found on the piclist are using
> instructions the 16f877 does not have.

Tim:

I'm certain that the "instructions that the 16F877 does not have" are
macros built-in to MPASM that the 16F877 DOES have.  Try using some
of the code from piclist.com; I think you'll find that it assembles
just fine.

Here's some code, by the way:

   ;Convert INPUT (0-99) to two decimal digits, stored in TENS and
   ;ONES.

       MOVF    INPUT,W
       MOVWF   ONES

       CLRF    TENS

   LOOP:

       MOVLW   10
       SUBWF   ONES,W
       BNC     DONE

       MOVWF   ONES
       INCF    TENS
       GOTO    LOOP

   DONE:

-Andy

=== Andrew Warren -- EraseMEaiwspam_OUTspamTakeThisOuTcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2002\02\05@155810 by Tim Webb

flavicon
face
This example might work except that I don't have the SKPDC and SKPNDC
instructions on the 16F877

This example is titled as:  "Binary to BCD half-packed 8 bit to 3 digit"

What does "half-packed" mean?



{Original Message removed}

2002\02\05@155815 by Bob Barr

flavicon
face
On Fri, 1 Feb 2002 17:37:53 -0700, Tim Webb <@spam@tim_webbKILLspamspamAGILENT.COM>
wrote:

>I have a number from 0 to 35 and I want to seperate the tens and the ones
>into two seperate file registers
>How do I do it using a 16F877 ?
>
>Most of examples that I have found on the piclist are using instructions the
>16f877 does not have.

Could you post some of the instructions that you are referring to?
The '877 has an instruction set that isn't particularly different from
the rest of the PIC's.


Regards, Bob

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2002\02\05@160410 by Andrew Warren

flavicon
face
WEBB,TIM (A-Sonoma,ex1) <RemoveMEPICLISTTakeThisOuTspammitvma.mit.edu> wrote:

> Actually, I am taking a binary number from 0 - 255 and I want to
> display it in decimal on an LCD Display.
>
> That means that I will have to calculate each of the three numbers and
> then add 0x30 to convert them to ASCII.

Tim:

From my web page, at:

   http://home.netcom.com/~fastfwd/answers.html#PIC00008

    LIST    R=DEC

        ASCIIO  EQU     ....    ;A FILE REGISTER.
        ASCIIT  EQU     ....    ;ANOTHER FILE REGISTER.
        ASCIIH  EQU     ....    ;ANOTHER FILE REGISTER.

   ; ENTER WITH ORIGINAL 8-BIT VALUE IN "ASCIIO".  EXITS WITH ASCII
   ; REPRESENTATION OF ONES' DIGIT IN "ASCIIO", TENS' DIGIT IN
   ;"ASCIIT", AND HUNDREDS' DIGIT IN "ASCIIH".

   CONVRT  MOVLW   '0'
           MOVWF   ASCIIH
           MOVWF   ASCIIT

   DO100S  MOVLW   100
           SUBWF   ASCIIO,W
           BNC     DO10S

           MOVWF   ASCIIO
           INCF    ASCIIH
           GOTO    DO100S

   DO10S   MOVLW   10
           SUBWF   ASCIIO,W
           BNC     ADJUST

           MOVWF   ASCIIO
           INCF    ASCIIT
           GOTO    DO10S

   ADJUST  MOVLW   '0'
           ADDWF   ASCIIO

-Andy

=== Andrew Warren -- spamBeGoneaiwspamBeGonespamcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


2002\02\05@160420 by Andrew Warren

flavicon
face
Tim Webb <RemoveMEPICLISTspamTakeThisOuTmitvma.mit.edu> wrote:

> This example might work except that I don't have the SKPDC and SKPNDC
> instructions on the 16F877

   Yes, you do.  Those are the "built-in MPASM macros" I mentioned
   before.  Read the MPASM manual, or search the piclist archives
   for "pseudo-op".

   -Andy

=== Andrew Warren -- aiwEraseMEspam.....cypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2002\02\05@160441 by jim

picon face
Put the 35 into a register and successively subtract 10 from it
and every time through the loop add 1 to another register.
Check the status flags for an underflow, and when you get one,
add back the latest '10' you subtracted and put the remainder in
the third register.   See the following run through...

w = 35                                                ; Initial number
num    equ    0x20                                ; Temporary holding place
for number
tens    equ    0x21                                ; Holding place for Tens
ones   equ    0x22                                ; Holding place for Ones

movwf    num                                        ; Put num in holding
register
movlw    0x0A                                     ; Subtract 10d from num
register
subwf     num,1                                    ; place result back in
temp register
btfss       0x03,1                                   ; Check for underflow
goto        rmdr                                      ; If underflow, go get
the units count
movlw    0x01                                      ; Add one to tens
register to count
movwf    tens                                       ; this time through the
loop
goto       $-6                                        ; If not, go back and
subtract another 10d

rmdr:                                                   ; Get units count
addwf    num,0                                    ; add the last 10d back
into the number
movwf    ones                                      ; 'w' now contains the
ones remaining
return                                                   ; Go back to
calling program


So we subtract 10 from 35, put the result (25) in num, and check for
underflow.
No underflow, so we subtract another 10 and put result in num (15), check
for underflow.
No underflow, so we subtract another 10 and put result in num (5), check for
underflow.
No underflow, so we subtract another 10 and put result in num (-5), check
for underflow.
We have underflow this time, so we add the last subtract back into num
making it 5 again.
And we save this number in the Ones register.

So at this point we have 'w' containing 5, num containing 5, Tens containing
3, and ones containing 5














{Original Message removed}

2002\02\05@163451 by uter van ooijen & floortje hanneman

picon face
> The '877 has an instruction set that isn't particularly different from
> the rest of the PIC's.

How do you know? My f877 datasheet does not list the instructions in detail!
Any source for knowing whether the 87x's do (officially) support tris?

Wouter van Ooijen

Van Ooijen Technische Informatica: http://www.voti.nl
Jal compiler for PIC uC's:  http://www.voti.nl/jal
PICs kopen? http://www.voti.nl/shop

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu


2002\02\05@181153 by Bob Barr

flavicon
face
On Tue, 5 Feb 2002 18:07:33 +0100, wouter van ooijen & floortje
hanneman <RemoveMEwfspam_OUTspamKILLspamXS4ALL.NL> wrote:

>> The '877 has an instruction set that isn't particularly different from
>> the rest of the PIC's.
>
>How do you know? My f877 datasheet does not list the instructions in detail!
>Any source for knowing whether the 87x's do (officially) support tris?
>

Check the DS30292B 'datasheet'. (I use quotes because it's about 200
pages long.) It covers the 16F87X (873,874,876,877) parts.

Section 13 (pages 137 through 144) has a complete instruction set
reference. Although I didn't do a line-by-line comparison, it appears
to be the same as other 16C and 16F parts.

On the OPTION and TRIS instructions, there's a note recommending
against using them (as there is in most of Microchip's newer data
sheets). They appear in neither the summary table nor the detailed
list of instructions.

Regards, Bob

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspamspammitvma.mit.edu


2002\02\06@012242 by uter van ooijen & floortje hanneman

picon face
> >How do you know? My f877 datasheet does not list the instructions in
detail!
> >Any source for knowing whether the 87x's do (officially) support tris?
> >
>
> Check the DS30292B 'datasheet'. (I use quotes because it's about 200
> pages long.) It covers the 16F87X (873,874,876,877) parts.

Your are right, I have a print of the DS30292A, which has only the summary
page.

> On the OPTION and TRIS instructions, there's a note recommending
> against using them (as there is in most of Microchip's newer data
> sheets). They appear in neither the summary table nor the detailed
> list of instructions.

I know the bullshit advise against using them, but just wanted to know
whether they are supported - on the same 'you should not use-m' base - as on
the 16x84 etc. I guess they are officially dropped now, although they still
work.

Wouter van Ooijen

Van Ooijen Technische Informatica: http://www.voti.nl
Jal compiler for PIC uC's:  http://www.voti.nl/jal
PICs kopen? http://www.voti.nl/shop

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\02\06@063042 by antoniasse

flavicon
face
Hi
I have been using and it has been useful for me,
the 16bit binary to BCD.  AN526
http://www.microchip.com/1010/suppdoc/appnote/category/listing/index.htm

Best regads

Luis Fernando


> Tim Webb wrote:
> >
> > I have a number from 0 to 35 and I want to seperate the tens and the
ones
> > into two seperate file registers
> > How do I do it using a 16F877 ?
> >
> > Most of examples that I have found on the piclist are using instructions
the
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...