Bochs/bochs/fpu/reg_norm.c

47 lines
1.5 KiB
C
Raw Normal View History

/*---------------------------------------------------------------------------+
| reg_norm.c |
2003-08-01 13:32:33 +04:00
| $Id: reg_norm.c,v 1.4 2003-08-01 09:32:33 sshwarts Exp $
| |
| Copyright (C) 1992,1993,1994,1995,1997,1999 |
| W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
| Australia. E-mail billm@melbpc.org.au |
| |
| Normalize the value in a FPU_REG. |
| |
| |
| Return value is the tag of the answer. |
| |
+---------------------------------------------------------------------------*/
#include "fpu_emu.h"
int FPU_normalize_nuo(FPU_REG *x, int bias)
{
2003-08-01 13:32:33 +04:00
if (! (x->sigh & 0x80000000))
{
2003-08-01 13:32:33 +04:00
if (x->sigh == 0)
{
2003-08-01 13:32:33 +04:00
if (x->sigl == 0)
{
x->exp = 0;
return TAG_Zero;
}
x->sigh = x->sigl;
x->sigl = 0;
x->exp -= 32;
}
2003-08-01 13:32:33 +04:00
while (!(x->sigh & 0x80000000))
{
x->sigh <<= 1;
2003-08-01 13:32:33 +04:00
if (x->sigl & 0x80000000)
x->sigh |= 1;
x->sigl <<= 1;
x->exp --;
}
}
x->exp += bias;
return TAG_Valid;
}