Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #503471

Re: OT: PIC16 divide and/or multiply routines

Newsgroups sci.electronics.design
Date 2018-04-25 11:15 -0700
References <xvYYx.43198$Iw3.9957@fx30.iad> <4a9c4182-fe21-4b20-a35e-9c24e7b56d6a@googlegroups.com> <8o9uddpn7t5jjqo749c50pooks0ikepj0s@4ax.com> <tvvuddps670cg2ub8v9thlmdp3qrt5tsq7@4ax.com>
Message-ID <43187de1-d07e-487e-aecd-e2835d2710fb@googlegroups.com> (permalink)
Subject Re: OT: PIC16 divide and/or multiply routines
From gnuarm.deletethisbit@gmail.com

Show all headers | View raw


On Tuesday, April 24, 2018 at 3:38:19 PM UTC-4, upsid...@downunder.com wrote:
> On Tue, 24 Apr 2018 08:51:07 -0400, Spehro Pefhany
> <speffSNIP@interlogDOTyou.knowwhat> wrote:
> 
> >On Mon, 23 Apr 2018 08:48:05 -0700 (PDT), ramiserhan77@gmail.com
> >wrote:
> >
> >>hey guys just i want to ask you, how is floating point represented in assembly for pic16, for example if i wanna save a value of 1.623 in memory, how can i save it using the 36 assembly instructions in pic16?
> >
> >You can find floating point libraries for the PIC16 family. Some use
> >the IEEE 754 representation. 
> >
> >It might be less painful to write the application in C if you really
> >need floating point. You can download a free XC8 compiler that has 
> >deliberately poor optimization.
> >
> >Fractional integers (integers with a radix point somewhere
> >appropriate) are often better speed-wise, but there is little
> >percentage in such optimizations in 2018. 
> >
> In addition to the good advices given above, on should also consider,
> if true binary floating point representation is justified.
> 
> Especially with 4 or 8 bit data word length and primitive instruction
> sets and/or primitive addressing modes and only a few floating point
> operations required, one should consider, if a full decimal to
> floating point and vice versa conversion is justified.
> 
> In many 1950's and 60's "commercial" (i.e. accounting) computers  used
> "decimal" (BCD) representation internally. The same conventions is
> still used in calculators. 
> 
> For example 1.623 can be represented as 0.16230000E+01 which could be
> represented in 8 bit bytes in BCD as
> 
> 0x16 0x23 0x00 0x00 (0x01)
> 
> Multiplication: Integer multiply mantissas, add exponents
> Division: Integer divide mantissas, subtract exponents
> 
> In fact floating point addition/subtraction is harder, since you have
> to deal with normalization or demoralization.
> 
> If an 8 bit processor is so primitive that it doesn't have any DAA
> (Decimal Adjust Accumulator) instruction. it might be easier to use
> base 100 (0..99) to store two decimal digits in a byte, in this case 
> 0x10 0x17 0x00 0x00 0x01

I recall the 8080 had a "decimal add adjust" instruction (or some similar name) that would correct the result of an addition for adding BCD numbers in a byte.  All in all, if the inputs and outputs are going to be decimal, then in this case using BCD arithmetic might be a useful way to go.  Certainly it will be easier to debug.  

I don't understand why anyone would want to write their own arithmetic routines for a processor.  There have to be a number of sources for such code, mostly free I expect.  Doesn't Microchip have floating point libraries? 

Rick C.

Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: OT: PIC16 divide and/or multiply routines ramiserhan77@gmail.com - 2018-04-23 08:48 -0700
  Re: OT: PIC16 divide and/or multiply routines bill.sloman@ieee.org - 2018-04-23 19:33 -0700
  Re: OT: PIC16 divide and/or multiply routines Terry Newton <nbill@bellsouth.net> - 2018-04-24 05:12 +0000
  Re: OT: PIC16 divide and/or multiply routines Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-04-24 09:26 +0100
    Re: OT: PIC16 divide and/or multiply routines John S <Sophi.2@invalid.org> - 2018-04-24 18:39 -0500
      Re: OT: PIC16 divide and/or multiply routines Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-04-25 08:37 +0100
        Re: OT: PIC16 divide and/or multiply routines "Tim Williams" <tiwill@seventransistorlabs.com> - 2018-04-25 03:25 -0500
          Re: OT: PIC16 divide and/or multiply routines Clifford Heath <no.spam@please.net> - 2018-04-25 19:57 +1000
        Re: OT: PIC16 divide and/or multiply routines Jasen Betts <jasen@xnet.co.nz> - 2018-04-26 07:24 +0000
          Re: OT: PIC16 divide and/or multiply routines David Brown <david.brown@hesbynett.no> - 2018-05-04 15:40 +0200
  Re: OT: PIC16 divide and/or multiply routines Spehro Pefhany <speffSNIP@interlogDOTyou.knowwhat> - 2018-04-24 08:51 -0400
    Re: OT: PIC16 divide and/or multiply routines upsidedown@downunder.com - 2018-04-24 22:38 +0300
      Re: OT: PIC16 divide and/or multiply routines gnuarm.deletethisbit@gmail.com - 2018-04-25 11:15 -0700
        Re: OT: PIC16 divide and/or multiply routines Clifford Heath <no.spam@please.net> - 2018-04-26 09:35 +1000
    Re: OT: PIC16 divide and/or multiply routines Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-04-25 08:38 +0100
      Re: OT: PIC16 divide and/or multiply routines gnuarm.deletethisbit@gmail.com - 2018-04-25 11:18 -0700
        Re: OT: PIC16 divide and/or multiply routines Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-04-26 08:56 +0100
    Re: OT: PIC16 divide and/or multiply routines bitrex <user@example.net> - 2018-04-25 11:56 -0400

csiph-web