0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "fpu_emu.h"
0022
0023
0024 .text
0025 SYM_FUNC_START(FPU_normalize)
0026 pushl %ebp
0027 movl %esp,%ebp
0028 pushl %ebx
0029
0030 movl PARAM1,%ebx
0031
0032 movl SIGH(%ebx),%edx
0033 movl SIGL(%ebx),%eax
0034
0035 orl %edx,%edx
0036 js L_done
0037 jnz L_shift_1
0038
0039 orl %eax,%eax
0040 jz L_zero
0041
0042 movl %eax,%edx
0043 xorl %eax,%eax
0044 subw $32,EXP(%ebx)
0045
0046
0047 L_shift_1:
0048 bsrl %edx,%ecx
0049 subl $31,%ecx
0050 negl %ecx
0051 shld %cl,%eax,%edx
0052 shl %cl,%eax
0053 subw %cx,EXP(%ebx)
0054
0055 movl %edx,SIGH(%ebx)
0056 movl %eax,SIGL(%ebx)
0057
0058 L_done:
0059 cmpw EXP_OVER,EXP(%ebx)
0060 jge L_overflow
0061
0062 cmpw EXP_UNDER,EXP(%ebx)
0063 jle L_underflow
0064
0065 L_exit_valid:
0066 movl TAG_Valid,%eax
0067
0068
0069 addw EXTENDED_Ebias,EXP(%ebx)
0070 andw $0x7fff,EXP(%ebx)
0071
0072 L_exit:
0073 popl %ebx
0074 leave
0075 RET
0076
0077
0078 L_zero:
0079 movw $0,EXP(%ebx)
0080 movl TAG_Zero,%eax
0081 jmp L_exit
0082
0083 L_underflow:
0084
0085 addw EXTENDED_Ebias,EXP(%ebx)
0086 push %ebx
0087 call arith_underflow
0088 pop %ebx
0089 jmp L_exit
0090
0091 L_overflow:
0092
0093 addw EXTENDED_Ebias,EXP(%ebx)
0094 push %ebx
0095 call arith_overflow
0096 pop %ebx
0097 jmp L_exit
0098 SYM_FUNC_END(FPU_normalize)
0099
0100
0101
0102
0103 SYM_FUNC_START(FPU_normalize_nuo)
0104 pushl %ebp
0105 movl %esp,%ebp
0106 pushl %ebx
0107
0108 movl PARAM1,%ebx
0109
0110 movl SIGH(%ebx),%edx
0111 movl SIGL(%ebx),%eax
0112
0113 orl %edx,%edx
0114 js L_exit_nuo_valid
0115 jnz L_nuo_shift_1
0116
0117 orl %eax,%eax
0118 jz L_exit_nuo_zero
0119
0120 movl %eax,%edx
0121 xorl %eax,%eax
0122 subw $32,EXP(%ebx)
0123
0124
0125 L_nuo_shift_1:
0126 bsrl %edx,%ecx
0127 subl $31,%ecx
0128 negl %ecx
0129 shld %cl,%eax,%edx
0130 shl %cl,%eax
0131 subw %cx,EXP(%ebx)
0132
0133 movl %edx,SIGH(%ebx)
0134 movl %eax,SIGL(%ebx)
0135
0136 L_exit_nuo_valid:
0137 movl TAG_Valid,%eax
0138
0139 popl %ebx
0140 leave
0141 RET
0142
0143 L_exit_nuo_zero:
0144 movl TAG_Zero,%eax
0145 movw EXP_UNDER,EXP(%ebx)
0146
0147 popl %ebx
0148 leave
0149 RET
0150 SYM_FUNC_END(FPU_normalize_nuo)