Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!sdd.hp.com!ucsd!ucbvax!hplabs!hpfcso!cunniff From: cunniff@hpfcso.HP.COM (Ross Cunniff) Newsgroups: comp.sys.amiga.programmer Subject: Re: SAS Bugs Message-ID: <101060005@hpfcso.HP.COM> Date: 28 Jan 91 16:10:19 GMT References: <91028.004246T32QC@CUNYVM.BITNET> Organization: Hewlett-Packard, Fort Collins, CO, USA Lines: 51 > Has anyone encountered any bugs in 5.10 with float math calculations in a >function and trying to pass the return values either with a global variable or >a typedef struct of floating point values. Then passing the values to the main >values dont truly get passed. I compile the progs same on a friends machine in >5.04 and it works fine. I am sick of writing code and seeing it is wrong on my >machine and its not my fault. I need help. Well, this weekend, I just got bitten by the following nasty bug (this is cut down from a much larger example, so no comments on programming style, please). The function: func( a, b ) float a; long *b; { *(float *)b = a; } generated the code (this is from memory, and probably the wrong syntax as well; that's what I get for using the HP assembler so much...) link.l %a6,#0000 mov.l #000C(%a6),%a0 ; Note this line; should ; be #0010(%a6) movm.l #0008(%a6),%d0-%d1 jsr.l convert_single_to_double ; don't remember the exact name mov.l %d0,(%a0) unlk %a6 rts It looks like the compiler realizes that it is actually a double on the stack (hence the convert_single_to_double (or whatever nasty mnemonic they use) call), but for the purposes of argument addressing, it thinks that the size of the argument on the stack is *4* (not 8) bytes. The workaround is to rewrite the function as: func( a, b ) double a; /* Used to be float a */ long *b; { *(float *)b = a; } Additionally, my application no longer works at all when compiled to use the FFP math routines. I haven't had time to track this down yet (I have over 35k lines to search :-(), but when I do, I'll call SAS and discuss it with them... Ross Cunniff Hewlett-Packard Colorado Language Lab cunniff@hpfcla.HP.COM