Exact match. Not showing close matches.
PICList
Thread
'[PIC]: Binary to Decimal conversion help'
2002\02\05@153323
by
Tim Webb
2002\02\05@154355
by
Roman Black
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
.....piclistunsubscriberequestKILLspam@spam@mitvma.mit.edu
2002\02\05@154952
by
Kevin Olalde
2002\02\05@155154
by
WEBB,TIM (ASonoma,ex1)
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

Tim Webb <.....PICLISTKILLspam.....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 builtin 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 (099) 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_OUTTakeThisOuTcypress.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
piclistunsubscriberequestspam_OUTmitvma.mit.edu
2002\02\05@155810
by
Tim Webb
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 halfpacked 8 bit to 3 digit"
What does "halfpacked" mean?
{Original Message removed}
2002\02\05@155815
by
Bob Barr
On Fri, 1 Feb 2002 17:37:53 0700, Tim Webb <@spam@tim_webbKILLspamAGILENT.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
KILLspampiclistunsubscriberequestKILLspammitvma.mit.edu
2002\02\05@160410
by
Andrew Warren

WEBB,TIM (ASonoma,ex1) <RemoveMEPICLISTTakeThisOuTmitvma.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 8BIT 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  spamBeGoneaiwspamBeGonecypress.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
TakeThisOuTpiclistunsubscriberequestEraseMEspam_OUTmitvma.mit.edu
2002\02\05@160420
by
Andrew Warren
2002\02\05@160441
by
jim

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
2002\02\05@181153
by
Bob Barr

On Tue, 5 Feb 2002 18:07:33 +0100, wouter van ooijen & floortje
hanneman <RemoveMEwfspam_OUTKILLspamXS4ALL.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 linebyline 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
RemoveMEpiclistunsubscriberequestTakeThisOuTspammitvma.mit.edu
2002\02\06@012242
by
uter van ooijen & floortje hanneman

> >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 usem' 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
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}> > 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: 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...