I'm having a little trouble with some floating point math in an embedded system project I'm working on. This little bit of code from a listing file relating to a motion control algorithm.
; LSPEED = (int)(K_w*K_s*K_e*((float)LCOUNTS));
0DFB EC12 ldd -14,x
0DFD 49 lsrd
0DFE 1614F6 jsr __d2lreg ß
0E01 160F50 jsr __long2fp
0E04 161232 jsr __fpmov
0E07 CD0F10 ldy #L16
The C variables: K_w, K_s, K_e, are floats, LCOUNTS is an unsigned integer, and LSPEED is a regular int.
First, is my type casting correct?
Second, Something very odd is happening, either I don't have the complete floating-point libraries <float.h> or they are not linking correctly. If you notice the line pointed out with the arrow, jump to subroutine __d2lreg. The problem is, there is no subroutine __d2lreg. In fact none of those subroutine exist. __d2lreg is something created by the compiler and I assume it has something to do with handling floating point numbers. I would expect it to be in one of the libraries included with the compiler. It is not, or I can't find it.
I was hoping that someone would have some insight into this problem.
I have a Motorola 68hc12-development board and I'm using the ImageCraft C compilers.
A little info about me: I am a Mechanical engineering senior a CalPoly, SLO. I'm working on my senior project, a small autonomous robot.
geoff
; LSPEED = (int)(K_w*K_s*K_e*((float)LCOUNTS));
0DFB EC12 ldd -14,x
0DFD 49 lsrd
0DFE 1614F6 jsr __d2lreg ß
0E01 160F50 jsr __long2fp
0E04 161232 jsr __fpmov
0E07 CD0F10 ldy #L16
The C variables: K_w, K_s, K_e, are floats, LCOUNTS is an unsigned integer, and LSPEED is a regular int.
First, is my type casting correct?
Second, Something very odd is happening, either I don't have the complete floating-point libraries <float.h> or they are not linking correctly. If you notice the line pointed out with the arrow, jump to subroutine __d2lreg. The problem is, there is no subroutine __d2lreg. In fact none of those subroutine exist. __d2lreg is something created by the compiler and I assume it has something to do with handling floating point numbers. I would expect it to be in one of the libraries included with the compiler. It is not, or I can't find it.
I was hoping that someone would have some insight into this problem.
I have a Motorola 68hc12-development board and I'm using the ImageCraft C compilers.
A little info about me: I am a Mechanical engineering senior a CalPoly, SLO. I'm working on my senior project, a small autonomous robot.
geoff