Society of Robots - Robot Forum

Software => Software => Topic started by: z.s.tar.gz on October 17, 2009, 10:46:58 AM

Title: Floating Point in Assembly
Post by: z.s.tar.gz on October 17, 2009, 10:46:58 AM
Can it be done? I really just need to work with decimals, but floating point would be pretty awesome.
Title: Re: Floating Point in Assembly
Post by: chelmi on October 17, 2009, 11:36:16 AM
We need more details...
Which micro-controller are you using?

ATmegas does not have a floating point unit, but there is an emulation library (slow and takes a lot of memory space).
I don't know of any micro-controller with a FPU, even the big ARM-based (STM32, AT91SAM*).
If you really need floating point, you can still get an external FPU co-processor like this one http://www.sparkfun.com/commerce/product_info.php?products_id=8129 (http://www.sparkfun.com/commerce/product_info.php?products_id=8129)

Chelmi.
Title: Re: Floating Point in Assembly
Post by: z.s.tar.gz on October 17, 2009, 03:23:19 PM
I'm probably going to have to go with a coprocessor as I'm using an atmega 644. How can you have a decimal in binary anyways?
Title: Re: Floating Point in Assembly
Post by: waltr on October 17, 2009, 07:56:50 PM
Yes, it can be done without a float point unit. I had a fixed point and a floating point library written in assembler for a Z80 processor back in the early '80s. And NASA certainly used floating point back back in the '60's that was written in assembler.  MicroChip has a floating point library for their mid-range PICs.  
It can be written in assembler as the on for the PICs, which may be a good place to start, port the PIC code to the processor you're using. Here is a link to the PIC libraries:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1469 (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1469)

Fixed point is easier to write and may be enough for your application. Worth looking into.
Title: Re: Floating Point in Assembly
Post by: z.s.tar.gz on October 19, 2009, 03:57:19 PM
Thanks. If push comes to shove I can just make a big lookup table.

Edit: That's what I think I'm going to do, as it seems to be the best for my application.