Hi, I wrote a small code to perform FPU division and multiplication. & I have attached the same. The output is as follows $./test 1.000000 81.000000 1.000000 nan Why the last o/p is giving NAN? Please let me the answer, why its failing to return the proper product. If any problem in my code please let me know. Thanks, Halesh
#include <stdio.h> #include <math.h> #define NRCONST 24 #define DBL_EPSILION 0.0005 #define MAX_DIFF 0.1 #define MAX_COMPUTE 99999 float assm_div(float a1, float b1) { float asm_res; __asm__ ("fld 8(%%ebp)" : :"a"(a1) ); __asm__ ("fld 12(%%ebp)" : :"b"(b1) ); __asm__ ("fdiv %st(1), %st"); __asm__ ("fst -8(%%ebp)" : :"a"(asm_res) ); return asm_res; } float assm_mul(float a1, float b1) { float asm_res; __asm__ ("fld 8(%%ebp)" : :"a"(a1) ); __asm__ ("fld 12(%%ebp)" : :"b"(b1) ); __asm__ ("fmul %st(1), %st"); __asm__ ("fst -8(%%ebp)" : :"a"(asm_res) ); return asm_res; } int main() { float std_resm, asm_res; int num, count; asm_res = assm_div(9,9); printf("%f\n", asm_res); asm_res = assm_mul(9,9); printf("%f\n", asm_res); asm_res = assm_div(9,9); printf("%f\n", asm_res); asm_res = assm_mul(9,9); printf("%f\n", asm_res); }