123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- .file "div_Xsig.S"
- #include "exception.h"
- #include "fpu_emu.h"
- #define XsigLL(x) (x)
- #define XsigL(x) 4(x)
- #define XsigH(x) 8(x)
- #ifndef NON_REENTRANT_FPU
- #define FPU_accum_3 -4(%ebp)
- #define FPU_accum_2 -8(%ebp)
- #define FPU_accum_1 -12(%ebp)
- #define FPU_accum_0 -16(%ebp)
- #define FPU_result_3 -20(%ebp)
- #define FPU_result_2 -24(%ebp)
- #define FPU_result_1 -28(%ebp)
- #else
- .data
- .align 4,0
- FPU_accum_3:
- .long 0
- FPU_accum_2:
- .long 0
- FPU_accum_1:
- .long 0
- FPU_accum_0:
- .long 0
- FPU_result_3:
- .long 0
- FPU_result_2:
- .long 0
- FPU_result_1:
- .long 0
- #endif
- .text
- ENTRY(div_Xsig)
- pushl %ebp
- movl %esp,%ebp
- #ifndef NON_REENTRANT_FPU
- subl $28,%esp
- #endif
- pushl %esi
- pushl %edi
- pushl %ebx
- movl PARAM1,%esi
- movl PARAM2,%ebx
- #ifdef PARANOID
- testl $0x80000000, XsigH(%ebx)
- je L_bugged
- #endif
-
-
- clc
- movl XsigH(%esi),%eax
- rcrl %eax
- movl %eax,FPU_accum_3
- movl XsigL(%esi),%eax
- rcrl %eax
- movl %eax,FPU_accum_2
- movl XsigLL(%esi),%eax
- rcrl %eax
- movl %eax,FPU_accum_1
- movl $0,%eax
- rcrl %eax
- movl %eax,FPU_accum_0
- movl FPU_accum_2,%eax
- movl FPU_accum_3,%edx
-
- movl XsigH(%ebx),%ecx
- addl $1,%ecx
- jnc LFirst_div_not_1
-
- mov %edx,%eax
- jmp LFirst_div_done
- LFirst_div_not_1:
- divl %ecx
- LFirst_div_done:
- movl %eax,FPU_result_3
- mull XsigH(%ebx)
- subl %eax,FPU_accum_2
- sbbl %edx,FPU_accum_3
- movl FPU_result_3,%eax
- mull XsigL(%ebx)
- subl %eax,FPU_accum_1
- sbbl %edx,FPU_accum_2
- sbbl $0,FPU_accum_3
- je LDo_2nd_32_bits
- #ifdef PARANOID
- jb L_bugged_1
- #endif
-
- incl FPU_result_3
- movl XsigL(%ebx),%eax
- movl XsigH(%ebx),%edx
- subl %eax,FPU_accum_1
- sbbl %edx,FPU_accum_2
- #ifdef PARANOID
- sbbl $0,FPU_accum_3
- jne L_bugged_1
- #endif
- LDo_2nd_32_bits:
- movl FPU_accum_2,%edx
- movl FPU_accum_1,%eax
-
- cmpl XsigH(%ebx),%edx
- jb LDo_2nd_div
- ja LPrevent_2nd_overflow
- cmpl XsigL(%ebx),%eax
- jb LDo_2nd_div
- LPrevent_2nd_overflow:
-
- subl XsigL(%ebx),%eax
- sbbl XsigH(%ebx),%edx
- movl %edx,FPU_accum_2
- movl %eax,FPU_accum_1
- incl FPU_result_3
- #ifdef PARANOID
- je L_bugged_2
- #endif
- LDo_2nd_div:
- cmpl $0,%ecx
- jnz LSecond_div_not_1
-
- mov %edx,%eax
- jmp LSecond_div_done
- LSecond_div_not_1:
- divl %ecx
- LSecond_div_done:
- movl %eax,FPU_result_2
- mull XsigH(%ebx)
- subl %eax,FPU_accum_1
- sbbl %edx,FPU_accum_2
- #ifdef PARANOID
- jc L_bugged_2
- #endif
- movl FPU_result_2,%eax
- mull XsigL(%ebx)
- subl %eax,FPU_accum_0
- sbbl %edx,FPU_accum_1
- sbbl $0,FPU_accum_2
- #ifdef PARANOID
- jc L_bugged_2
- #endif
- jz LDo_3rd_32_bits
- #ifdef PARANOID
- cmpl $1,FPU_accum_2
- jne L_bugged_2
- #endif
-
- movl XsigL(%ebx),%eax
- movl XsigH(%ebx),%edx
- subl %eax,FPU_accum_0
- sbbl %edx,FPU_accum_1
- sbbl $0,FPU_accum_2
- #ifdef PARANOID
- jc L_bugged_2
- jne L_bugged_2
- #endif
- addl $1,FPU_result_2
- adcl $0,FPU_result_3
- #ifdef PARANOID
- jc L_bugged_2
- #endif
- LDo_3rd_32_bits:
-
- movl FPU_result_3,%eax
- mull XsigLL(%ebx)
- subl %edx,FPU_accum_1
-
- jnb LTest_over
- movl XsigH(%ebx),%edx
- addl %edx,FPU_accum_1
- subl $1,FPU_result_2
- sbbl $0,FPU_result_3
-
- movl FPU_accum_1,%edx
- cmpl XsigH(%ebx),%edx
- jb LDo_3rd_div
- movl XsigH(%ebx),%edx
- addl %edx,FPU_accum_1
- subl $1,FPU_result_2
- sbbl $0,FPU_result_3
- jmp LDo_3rd_div
- LTest_over:
- movl FPU_accum_1,%edx
-
- cmpl XsigH(%ebx),%edx
- jb LDo_3rd_div
-
- subl XsigH(%ebx),%edx
- movl %edx,FPU_accum_1
- addl $1,FPU_result_2
- adcl $0,FPU_result_3
- LDo_3rd_div:
- movl FPU_accum_0,%eax
- movl FPU_accum_1,%edx
- divl XsigH(%ebx)
- movl %eax,FPU_result_1
- movl PARAM3,%esi
- movl FPU_result_1,%eax
- movl %eax,XsigLL(%esi)
- movl FPU_result_2,%eax
- movl %eax,XsigL(%esi)
- movl FPU_result_3,%eax
- movl %eax,XsigH(%esi)
- L_exit:
- popl %ebx
- popl %edi
- popl %esi
- leave
- ret
- #ifdef PARANOID
- L_bugged:
- pushl EX_INTERNAL|0x240
- call EXCEPTION
- pop %ebx
- jmp L_exit
- L_bugged_1:
- pushl EX_INTERNAL|0x241
- call EXCEPTION
- pop %ebx
- jmp L_exit
- L_bugged_2:
- pushl EX_INTERNAL|0x242
- call EXCEPTION
- pop %ebx
- jmp L_exit
- #endif
|