Mac Intel

Joel Reymont <>
Mon Aug 14 02:10:36 CEST 2006


I thought I would throw together a small program that makes me  
scratch my head. According to everything I read, FPU state should  
contain the address of the last floating-point instruction among  
other things.

The instruction pointer (IP) is consistently 0 in the code below,  
though.

Anyone with a Linux box willing to try this?

#include <stdio.h>

typedef struct {
     unsigned short __control;
     unsigned short __reserved1;
     unsigned short __status;
     unsigned short __reserved2;
     unsigned int __private3;
     unsigned int __ip;
		unsigned short __cs;
     unsigned short __private5;
     unsigned int __opaddr;
     unsigned int __private7;
} __fpustate_t;

static double x = 0.0;

int main(int argc, const char **argv)
{
	__fpustate_t fpu;
	x = 353.345 * 23423.34;
	printf("result = %G\n", x);
	__asm__ __volatile__("fnstenv %0" : "=m"(fpu));
	printf("status = %x\n", fpu.__status);
	printf("control = %x\n", fpu.__control);
	printf("ip = %x\n", fpu.__ip);
	printf("cs = %x\n", fpu.__cs);
	printf("op = %x\n", fpu.__opaddr);
}

--
http://wagerlabs.com/








More information about the erlang-questions mailing list