Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #503294 > unrolled thread
| Started by | ramiserhan77@gmail.com |
|---|---|
| First post | 2018-04-23 08:48 -0700 |
| Last post | 2018-04-25 11:56 -0400 |
| Articles | 18 — 13 participants |
Back to article view | Back to sci.electronics.design
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | ramiserhan77@gmail.com |
|---|---|
| Date | 2018-04-23 08:48 -0700 |
| Subject | Re: OT: PIC16 divide and/or multiply routines |
| Message-ID | <4a9c4182-fe21-4b20-a35e-9c24e7b56d6a@googlegroups.com> |
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?
[toc] | [next] | [standalone]
| From | bill.sloman@ieee.org |
|---|---|
| Date | 2018-04-23 19:33 -0700 |
| Message-ID | <d129e509-fd9c-4094-a5bc-b65c919b3807@googlegroups.com> |
| In reply to | #503294 |
On Tuesday, April 24, 2018 at 1:48:10 AM UTC+10, ramise...@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? Any way you want to represent it. You have to store the numbers spread over several words of memory, and manipulate them carefully. Double and triple precision arithmetic and floating point arithmetic are all perfectly practical (if tedious and bulky). For extra credit, try arbitrary precision arithmetic, where the numbers can get as long as they need to. Turing machines can do almost everything, though they may take a very long time, and a great deal of memory, to do it. -- Bill Sloman, Sydney
[toc] | [prev] | [next] | [standalone]
| From | Terry Newton <nbill@bellsouth.net> |
|---|---|
| Date | 2018-04-24 05:12 +0000 |
| Message-ID | <pbmec9$14pv$1@gioia.aioe.org> |
| In reply to | #503294 |
On Mon, 23 Apr 2018 08:48:05 -0700, ramiserhan77 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 don't, PIC16 chips do 8-bit addition subtraction and logic and not much else, multiplication division etc have to be implemented as subroutines. 16-bit math sub libraries are common but never needed floating point on such a small processor, if I did I'd make up my own fixed-point format (or just store as an integer multiple). When I need true floats I use a PIC18F part like the PIC18F2525 and program it in C, the free SDCC compiler works for me. Terry
[toc] | [prev] | [next] | [standalone]
| From | Martin Brown <'''newspam'''@nezumi.demon.co.uk> |
|---|---|
| Date | 2018-04-24 09:26 +0100 |
| Message-ID | <pbmpn0$1v82$1@gioia.aioe.org> |
| In reply to | #503294 |
On 23/04/2018 16:48, 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? Scaled integer fixed point is the least painful way. Even so you will need to write your own multiply and divide routines. You will have to write your own floating point library otherwise. If you can live with approximate values then 13/8 = 1.625 -- Regards, Martin Brown
[toc] | [prev] | [next] | [standalone]
| From | John S <Sophi.2@invalid.org> |
|---|---|
| Date | 2018-04-24 18:39 -0500 |
| Message-ID | <pbof7b$l2o$1@dont-email.me> |
| In reply to | #503356 |
On 4/24/2018 3:26 AM, Martin Brown wrote: > On 23/04/2018 16:48, 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? > > Scaled integer fixed point is the least painful way. Even so you will > need to write your own multiply and divide routines. > > You will have to write your own floating point library otherwise. > > If you can live with approximate values then 13/8 = 1.625 > 99/61 is only -.003% off.
[toc] | [prev] | [next] | [standalone]
| From | Martin Brown <'''newspam'''@nezumi.demon.co.uk> |
|---|---|
| Date | 2018-04-25 08:37 +0100 |
| Message-ID | <pbpb7n$3nq$2@gioia.aioe.org> |
| In reply to | #503402 |
On 25/04/2018 00:39, John S wrote: > On 4/24/2018 3:26 AM, Martin Brown wrote: >> On 23/04/2018 16:48, 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? >> >> Scaled integer fixed point is the least painful way. Even so you will >> need to write your own multiply and divide routines. >> >> You will have to write your own floating point library otherwise. >> >> If you can live with approximate values then 13/8 = 1.625 >> > > 99/61 is only -.003% off. Try dividing by 61 with just shifts and adds! Scaling by 2^n is one way to handle modest precision floats. (easier if you know the range of input/output values) -- Regards, Martin Brown
[toc] | [prev] | [next] | [standalone]
| From | "Tim Williams" <tiwill@seventransistorlabs.com> |
|---|---|
| Date | 2018-04-25 03:25 -0500 |
| Message-ID | <pbpdvr$eei$1@dont-email.me> |
| In reply to | #503432 |
"Martin Brown" <'''newspam'''@nezumi.demon.co.uk> wrote in message news:pbpb7n$3nq$2@gioia.aioe.org... >> 99/61 is only -.003% off. > > Try dividing by 61 with just shifts and adds! Easy, multiply by 1074. :-) (I once wrote a one of these for AVR, for decimal conversion. The divide-by-10 operation takes only ~30 cycles, thanks to the fast hardware (8x8) multiply, and using this trick instead of long division. Yes, quotient and remainder are produced as usual. Downside: the operation had to be a full 24 bits, to maintain exact results for all inputs. That is, for a 16 bit input, it's multiplied not by 6553, but a bit more, and shifted.) Tim -- Seven Transistor Labs, LLC Electrical Engineering Consultation and Contract Design Website: https://www.seventransistorlabs.com/
[toc] | [prev] | [next] | [standalone]
| From | Clifford Heath <no.spam@please.net> |
|---|---|
| Date | 2018-04-25 19:57 +1000 |
| Message-ID | <EiYDC.27673$o43.15322@fx33.iad> |
| In reply to | #503435 |
On 25/04/18 18:25, Tim Williams wrote: > "Martin Brown" <'''newspam'''@nezumi.demon.co.uk> wrote in message > news:pbpb7n$3nq$2@gioia.aioe.org... >>> 99/61 is only -.003% off. >> >> Try dividing by 61 with just shifts and adds! > > Easy, multiply by 1074. :-) > > (I once wrote a one of these for AVR, for decimal conversion. The > divide-by-10 operation takes only ~30 cycles, thanks to the fast > hardware (8x8) multiply, and using this trick instead of long division. > Yes, quotient and remainder are produced as usual. Downside: the > operation had to be a full 24 bits, to maintain exact results for all > inputs. That is, for a 16 bit input, it's multiplied not by 6553, but a > bit more, and shifted.) It's a good technique. <https://github.com/cjheath/AD9959/blob/master/AD9959.h#L224-L255>
[toc] | [prev] | [next] | [standalone]
| From | Jasen Betts <jasen@xnet.co.nz> |
|---|---|
| Date | 2018-04-26 07:24 +0000 |
| Message-ID | <pbruqm$rq5$2@gonzo.alcatraz> |
| In reply to | #503432 |
On 2018-04-25, Martin Brown <'''newspam'''@nezumi.demon.co.uk> wrote:
> On 25/04/2018 00:39, John S wrote:
>> On 4/24/2018 3:26 AM, Martin Brown wrote:
>>> On 23/04/2018 16:48, 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?
>>>
>>> Scaled integer fixed point is the least painful way. Even so you will
>>> need to write your own multiply and divide routines.
>>>
>>> You will have to write your own floating point library otherwise.
>>>
>>> If you can live with approximate values then 13/8 = 1.625
>>>
>>
>> 99/61 is only -.003% off.
>
> Try dividing by 61 with just shifts and adds!
mukltiply by the reciprocal.
X >> 6 + X >> 11 + X>> 12 + X >> 15
--
ت
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2018-05-04 15:40 +0200 |
| Message-ID | <pchnso$4qc$1@dont-email.me> |
| In reply to | #503531 |
On 26/04/18 09:24, Jasen Betts wrote: > On 2018-04-25, Martin Brown <'''newspam'''@nezumi.demon.co.uk> wrote: >> On 25/04/2018 00:39, John S wrote: >>> On 4/24/2018 3:26 AM, Martin Brown wrote: >>>> On 23/04/2018 16:48, 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? >>>> >>>> Scaled integer fixed point is the least painful way. Even so you will >>>> need to write your own multiply and divide routines. >>>> >>>> You will have to write your own floating point library otherwise. >>>> >>>> If you can live with approximate values then 13/8 = 1.625 >>>> >>> >>> 99/61 is only -.003% off. >> >> Try dividing by 61 with just shifts and adds! > > mukltiply by the reciprocal. > > X >> 6 + X >> 11 + X>> 12 + X >> 15 > > For the original multiply by 1.623, I'd do: ((x << 15) + (x << 13) - (x << 7) - (x << 1) - x) >> 16 + x Or use a good C compiler and let it figure out these shift-add-sub sequences for you.
[toc] | [prev] | [next] | [standalone]
| From | Spehro Pefhany <speffSNIP@interlogDOTyou.knowwhat> |
|---|---|
| Date | 2018-04-24 08:51 -0400 |
| Message-ID | <8o9uddpn7t5jjqo749c50pooks0ikepj0s@4ax.com> |
| In reply to | #503294 |
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. --sp
[toc] | [prev] | [next] | [standalone]
| From | upsidedown@downunder.com |
|---|---|
| Date | 2018-04-24 22:38 +0300 |
| Message-ID | <tvvuddps670cg2ub8v9thlmdp3qrt5tsq7@4ax.com> |
| In reply to | #503362 |
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
[toc] | [prev] | [next] | [standalone]
| From | gnuarm.deletethisbit@gmail.com |
|---|---|
| Date | 2018-04-25 11:15 -0700 |
| Message-ID | <43187de1-d07e-487e-aecd-e2835d2710fb@googlegroups.com> |
| In reply to | #503387 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Clifford Heath <no.spam@please.net> |
|---|---|
| Date | 2018-04-26 09:35 +1000 |
| Message-ID | <fh8EC.50832$br4.23523@fx34.iad> |
| In reply to | #503471 |
On 26/04/18 04:15, gnuarm.deletethisbit@gmail.com wrote: > 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. That was only possible/sensible because the status register saved the nybble carry-out. Clifford Heath. 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. >
[toc] | [prev] | [next] | [standalone]
| From | Martin Brown <'''newspam'''@nezumi.demon.co.uk> |
|---|---|
| Date | 2018-04-25 08:38 +0100 |
| Message-ID | <pbpb9t$3nq$3@gioia.aioe.org> |
| In reply to | #503362 |
On 24/04/2018 13:51, Spehro Pefhany 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. Although you *can* do this - today it would make much more sense to use an ARM core that has native floating point support! PICs are better suited to ultra low power minor control functions. > Fractional integers (integers with a radix point somewhere > appropriate) are often better speed-wise, but there is little > percentage in such optimizations in 2018. > > --sp It depends how much you know about the inputs and outputs that the system has to handle. Floating point is often used as a crutch by people who don't really know what they are doing to disguise the fact. -- Regards, Martin Brown
[toc] | [prev] | [next] | [standalone]
| From | gnuarm.deletethisbit@gmail.com |
|---|---|
| Date | 2018-04-25 11:18 -0700 |
| Message-ID | <0c250308-3c8a-4138-b0bd-82f973188f11@googlegroups.com> |
| In reply to | #503433 |
On Wednesday, April 25, 2018 at 3:38:42 AM UTC-4, Martin Brown wrote: > On 24/04/2018 13:51, Spehro Pefhany 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. > > Although you *can* do this - today it would make much more sense to use > an ARM core that has native floating point support! That strongly depends on the requirements for the floating point. Most of the smaller ARM devices only support single precision floats in hardware which have less precision than integer arithmetic. If you need double precision floating point, you are back to using libraries or you need to use a much larger and power hungry device. Rick C.
[toc] | [prev] | [next] | [standalone]
| From | Martin Brown <'''newspam'''@nezumi.demon.co.uk> |
|---|---|
| Date | 2018-04-26 08:56 +0100 |
| Message-ID | <pbs0o9$65u$1@gioia.aioe.org> |
| In reply to | #503472 |
On 25/04/2018 19:18, gnuarm.deletethisbit@gmail.com wrote: > On Wednesday, April 25, 2018 at 3:38:42 AM UTC-4, Martin Brown > wrote: >> On 24/04/2018 13:51, Spehro Pefhany 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. >> >> Although you *can* do this - today it would make much more sense to >> use an ARM core that has native floating point support! > > That strongly depends on the requirements for the floating point. Although true relying on double precision reals to make a bad algorithm work is not good engineering practice. Most signal processing can be done in scaled integers or fixed point if you know what you are doing. > Most of the smaller ARM devices only support single precision floats > in hardware which have less precision than integer arithmetic. If > you need double precision floating point, you are back to using > libraries or you need to use a much larger and power hungry device. But a PIC16's memory isn't going to hold very many double precision reals anyway so I think it is a mute point. -- Regards, Martin Brown
[toc] | [prev] | [next] | [standalone]
| From | bitrex <user@example.net> |
|---|---|
| Date | 2018-04-25 11:56 -0400 |
| Message-ID | <Ey1EC.20905$Qa1.15941@fx21.iad> |
| In reply to | #503362 |
On 04/24/2018 08:51 AM, Spehro Pefhany 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. > > --sp > On a 20MHz 8 bit AVR with a hardware multiplier a 32 bit by 32 bit IEEE 754 "float" datatype multiply IIRC takes about 6 microseconds, it's not that bad.
[toc] | [prev] | [standalone]
Back to top | Article view | sci.electronics.design
csiph-web