floating point math in hc08

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

floating point math in hc08

4,098 Views
steve_fae
Senior Contributor I
I am trying to perform this multiplication:
 dac_val = (float)*(Uart_ptr + 9) * 1e4;
 
When I include 1e4 instead of 10000 I get errors:
symbol _dufloat undefined
symbol _dmul_rc undefined
symbol _dstrunc undefined
 
What should I include for this to work? 
Labels (1)
0 Kudos
5 Replies

559 Views
CompilerGuru
NXP Employee
NXP Employee
Read the lib\hc08c\readme.txt.

or you can create a new project with the wizard and pick the floating support you want, then adapt your project it uses the same setup.

Basically the link time errors you get do show that you link against a library version with no floating point support.

Daniel

BTW: I actually wonder if you try to use IEEE64 or IEEE32, I guess _dmul_rc is the IEEE64 bit multiplication. If you want IEEE32, use 1e4f (or 10000.0f), or set the double type to be 32 bit too in the settings (and pick the right library to reflect that)
0 Kudos

559 Views
steve_fae
Senior Contributor I
Ok, I created a dummy project with 32/32 float added.  I copied the compiler setting from it for my project:
 
-Cs08 -Ms -Fd
 
But trying either
 
int dac_val;
byte * Uart_ptr;
 
dac_val = (float)*(Uart_ptr + 9) * 1e4;
gives
 _FUFLOAT undefined
_FMUL_RC undefined
_FSTRUNC undefined
 
 
dac_val = (float)*(Uart_ptr + 9) * 1ef4; creates illegal floating point exponent
 
 
 
 
 
0 Kudos

559 Views
CompilerGuru
NXP Employee
NXP Employee
For the number, its 1e4f, not 1ef4. Anyway, use 10000.0f, for me that's more readable than the scientific e notation.

About the linking error, the actual problem is that your project is linking against the wrong ansi???.lib file.
Change your existing project to link the correct one, for example by deleting the wrong one out of your existing project and drag and drop the one from the dummy project.

Daniel

BTW for HCS08, Small memory model, IEEE32, link against ansifs.lib.
0 Kudos

559 Views
steve_fae
Senior Contributor I
Thanks Danny,
Removing ansiis.lib and adding in ansifs.lib fixed the errors and I looked at the disassembly code to make sure that it found what it needed.  I really love to use PE but wow, it really makes you lame when you run into problems like this.
 
Oh yes, using 1e4f didn't matter.  1e4 created the same assembly code.
 
S
0 Kudos

559 Views
steve_fae
Senior Contributor I
Thanks for the initial response.  I am also exploring the answer, but if I used PE initially, is there something I can do after the project has been built to include these libraries instead of creating a new project from scratch?
0 Kudos