diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libmp/Inferno-mips/mpdigdiv.s | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libmp/Inferno-mips/mpdigdiv.s')
| -rw-r--r-- | libmp/Inferno-mips/mpdigdiv.s | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libmp/Inferno-mips/mpdigdiv.s b/libmp/Inferno-mips/mpdigdiv.s new file mode 100644 index 00000000..b7fd330e --- /dev/null +++ b/libmp/Inferno-mips/mpdigdiv.s @@ -0,0 +1,41 @@ +/* + * This only works on R[45]000 chips that allow 64 bit + * integer arithmetic even when uding 32 bit addresses + * + * R1 = dividend* + * R2 = dividend[low] + * R3 = dividend[high] + * R4 = 32 bit divisor + * R5 = quotient* + */ +TEXT mpdigdiv(SB),$0 + + MOVW 0(R1),R2 + MOVW 4(R1),R3 + MOVW divisor+4(FP),R4 + MOVW quotient+8(FP),R5 + + /* divisor == 0 */ + BEQ R4,_digovfl + + /* dividend >= 2^32 * divisor */ + SGTU R4,R3,R7 + BEQ R7,_digovfl + +_digdiv1: + SLLV $32,R2 + SLLV $32,R3 + SRLV $32,R2 + ADDVU R2,R3 + SLLV $32,R4 + SRLV $32,R4 + DIVVU R4,R3 + MOVW LO,R1 + MOVW R1,0(R5) + RET + +_digovfl: + MOVW $-1,R1 + MOVW R1,0(R5) + RET + |
