fpu.c

来自「《汇编源代码大全》」· C语言 代码 · 共 82 行

C
82
字号
/*****************************************************************************
 * FILE: fpu.c								     *
 *									     *
 * DESC:								     *
 *	- FPU saving, FPU-EMU install					     *
 *									     *
 * Copyright (C) 1993,1994						     *
 *	Rainer Schnitker, Heeper Str. 283, 33607 Bielefeld		     *
 *	email: rainer@mathematik.uni-bielefeld.de			     *
 *									     *
 *****************************************************************************/

#include "DPMI.H"
#include "DPMI10.H"
#include "PROCESS.H"
#include "START32.H"
#include "FPU.H"

extern int used_math;
extern int debugged;
extern union i387_union *process_npx;

DWORD emu_init(void)
{
    int _ret;
    __asm__(
	"pushl  %%ebx \n\t"
	"pushl  %%edi \n\t"
	"pushl  %%esi \n\t"
	"pushl  _data16sel \n\t"
	"popl   %%gs \n\t"
	"pushl  %%cs \n\t"
	"call   _fpu_entry \n\t"
	"popl   %%esi \n\t"
	"popl   %%edi \n\t"
	"popl   %%ebx \n\t"
	: "=a"(_ret)
	: "d"(stackp16), "0"(0x12345678)
	: "ax", "dx"
    );
    return _ret;
}

void emu_switch(int x, int y)
{
    used_math = x;
    debugged = y;
    process_npx = &(npz->npx);
}

void do_fnsave(union i387_union * fpu_struct)
{
    __asm__(
	"fnsave %0"
	:"=m"( *fpu_struct)
    );
}

void do_frstor(union i387_union * fpu_struct)
{
    __asm__(
	"frstor %0"
	::"m"( *fpu_struct)
    );
}

void do_fninit(void)
{
    __asm__("fninit");
}

extern char * getenv(char *);

int npx_installed(void)
{
    char *s = getenv("RSX_x87");
    if (!s)
	return 0;
    else
	return (int) (*s - '0');
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?