OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [i386/] [math-emu/] [reg_norm.S] - Diff between revs 1765 and 1782

Only display areas with differences | Details | Blame | View Log

Rev 1765 Rev 1782
/*---------------------------------------------------------------------------+
/*---------------------------------------------------------------------------+
 |  reg_norm.S                                                               |
 |  reg_norm.S                                                               |
 |                                                                           |
 |                                                                           |
 | Copyright (C) 1992,1993,1994,1995                                         |
 | Copyright (C) 1992,1993,1994,1995                                         |
 |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
 |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
 |                       Australia.  E-mail billm@jacobi.maths.monash.edu.au |
 |                       Australia.  E-mail billm@jacobi.maths.monash.edu.au |
 |                                                                           |
 |                                                                           |
 | Normalize the value in a FPU_REG.                                         |
 | Normalize the value in a FPU_REG.                                         |
 |                                                                           |
 |                                                                           |
 | Call from C as:                                                           |
 | Call from C as:                                                           |
 |   void normalize(FPU_REG *n)                                              |
 |   void normalize(FPU_REG *n)                                              |
 |                                                                           |
 |                                                                           |
 |   void normalize_nuo(FPU_REG *n)                                          |
 |   void normalize_nuo(FPU_REG *n)                                          |
 |                                                                           |
 |                                                                           |
 +---------------------------------------------------------------------------*/
 +---------------------------------------------------------------------------*/
#include "fpu_emu.h"
#include "fpu_emu.h"
.text
.text
ENTRY(normalize)
ENTRY(normalize)
        pushl   %ebp
        pushl   %ebp
        movl    %esp,%ebp
        movl    %esp,%ebp
        pushl   %ebx
        pushl   %ebx
        movl    PARAM1,%ebx
        movl    PARAM1,%ebx
#ifdef PARANOID
#ifdef PARANOID
        cmpb    TW_Valid,TAG(%ebx)
        cmpb    TW_Valid,TAG(%ebx)
        je      L_ok
        je      L_ok
        pushl   $0x220
        pushl   $0x220
        call    SYMBOL_NAME(exception)
        call    SYMBOL_NAME(exception)
        addl    $4,%esp
        addl    $4,%esp
L_ok:
L_ok:
#endif PARANOID
#endif PARANOID
        movl    SIGH(%ebx),%edx
        movl    SIGH(%ebx),%edx
        movl    SIGL(%ebx),%eax
        movl    SIGL(%ebx),%eax
        orl     %edx,%edx       /* ms bits */
        orl     %edx,%edx       /* ms bits */
        js      L_done          /* Already normalized */
        js      L_done          /* Already normalized */
        jnz     L_shift_1       /* Shift left 1 - 31 bits */
        jnz     L_shift_1       /* Shift left 1 - 31 bits */
        orl     %eax,%eax
        orl     %eax,%eax
        jz      L_zero          /* The contents are zero */
        jz      L_zero          /* The contents are zero */
        movl    %eax,%edx
        movl    %eax,%edx
        xorl    %eax,%eax
        xorl    %eax,%eax
        subl    $32,EXP(%ebx)   /* This can cause an underflow */
        subl    $32,EXP(%ebx)   /* This can cause an underflow */
/* We need to shift left by 1 - 31 bits */
/* We need to shift left by 1 - 31 bits */
L_shift_1:
L_shift_1:
        bsrl    %edx,%ecx       /* get the required shift in %ecx */
        bsrl    %edx,%ecx       /* get the required shift in %ecx */
        subl    $31,%ecx
        subl    $31,%ecx
        negl    %ecx
        negl    %ecx
        shld    %cl,%eax,%edx
        shld    %cl,%eax,%edx
        shl     %cl,%eax
        shl     %cl,%eax
        subl    %ecx,EXP(%ebx)  /* This can cause an underflow */
        subl    %ecx,EXP(%ebx)  /* This can cause an underflow */
        movl    %edx,SIGH(%ebx)
        movl    %edx,SIGH(%ebx)
        movl    %eax,SIGL(%ebx)
        movl    %eax,SIGL(%ebx)
L_done:
L_done:
        cmpl    EXP_OVER,EXP(%ebx)
        cmpl    EXP_OVER,EXP(%ebx)
        jge     L_overflow
        jge     L_overflow
        cmpl    EXP_UNDER,EXP(%ebx)
        cmpl    EXP_UNDER,EXP(%ebx)
        jle     L_underflow
        jle     L_underflow
L_exit:
L_exit:
        popl    %ebx
        popl    %ebx
        leave
        leave
        ret
        ret
L_zero:
L_zero:
        movl    EXP_UNDER,EXP(%ebx)
        movl    EXP_UNDER,EXP(%ebx)
        movb    TW_Zero,TAG(%ebx)
        movb    TW_Zero,TAG(%ebx)
        jmp     L_exit
        jmp     L_exit
L_underflow:
L_underflow:
        push    %ebx
        push    %ebx
        call    SYMBOL_NAME(arith_underflow)
        call    SYMBOL_NAME(arith_underflow)
        pop     %ebx
        pop     %ebx
        jmp     L_exit
        jmp     L_exit
L_overflow:
L_overflow:
        push    %ebx
        push    %ebx
        call    SYMBOL_NAME(arith_overflow)
        call    SYMBOL_NAME(arith_overflow)
        pop     %ebx
        pop     %ebx
        jmp     L_exit
        jmp     L_exit
/* Normalise without reporting underflow or overflow */
/* Normalise without reporting underflow or overflow */
ENTRY(normalize_nuo)
ENTRY(normalize_nuo)
        pushl   %ebp
        pushl   %ebp
        movl    %esp,%ebp
        movl    %esp,%ebp
        pushl   %ebx
        pushl   %ebx
        movl    PARAM1,%ebx
        movl    PARAM1,%ebx
#ifdef PARANOID
#ifdef PARANOID
        cmpb    TW_Valid,TAG(%ebx)
        cmpb    TW_Valid,TAG(%ebx)
        je      L_ok_nuo
        je      L_ok_nuo
        pushl   $0x221
        pushl   $0x221
        call    SYMBOL_NAME(exception)
        call    SYMBOL_NAME(exception)
        addl    $4,%esp
        addl    $4,%esp
L_ok_nuo:
L_ok_nuo:
#endif PARANOID
#endif PARANOID
        movl    SIGH(%ebx),%edx
        movl    SIGH(%ebx),%edx
        movl    SIGL(%ebx),%eax
        movl    SIGL(%ebx),%eax
        orl     %edx,%edx       /* ms bits */
        orl     %edx,%edx       /* ms bits */
        js      L_exit          /* Already normalized */
        js      L_exit          /* Already normalized */
        jnz     L_nuo_shift_1   /* Shift left 1 - 31 bits */
        jnz     L_nuo_shift_1   /* Shift left 1 - 31 bits */
        orl     %eax,%eax
        orl     %eax,%eax
        jz      L_zero          /* The contents are zero */
        jz      L_zero          /* The contents are zero */
        movl    %eax,%edx
        movl    %eax,%edx
        xorl    %eax,%eax
        xorl    %eax,%eax
        subl    $32,EXP(%ebx)   /* This can cause an underflow */
        subl    $32,EXP(%ebx)   /* This can cause an underflow */
/* We need to shift left by 1 - 31 bits */
/* We need to shift left by 1 - 31 bits */
L_nuo_shift_1:
L_nuo_shift_1:
        bsrl    %edx,%ecx       /* get the required shift in %ecx */
        bsrl    %edx,%ecx       /* get the required shift in %ecx */
        subl    $31,%ecx
        subl    $31,%ecx
        negl    %ecx
        negl    %ecx
        shld    %cl,%eax,%edx
        shld    %cl,%eax,%edx
        shl     %cl,%eax
        shl     %cl,%eax
        subl    %ecx,EXP(%ebx)  /* This can cause an underflow */
        subl    %ecx,EXP(%ebx)  /* This can cause an underflow */
        movl    %edx,SIGH(%ebx)
        movl    %edx,SIGH(%ebx)
        movl    %eax,SIGL(%ebx)
        movl    %eax,SIGL(%ebx)
        jmp     L_exit
        jmp     L_exit
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.