/* Support file for -mfix-vr4120.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free softwarethe Free Software Foundation
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTYGNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCCBoston, MA 02111-1307, USA. */
/* This file contains functions which implement divsi3 and modsi3 for
-mfix-vr4120. div and ddiv do not give the correct result when one
of the operands is negative. */
.set nomips16
#define DIV \
xor $3,$4,$5 /* t = x ^ y */ .set noreorder and $3,$3,$2 /* t = (x ^ y) & 0x80000000 in delay slot */ subu $4,$0,$4 /* x = -x */ .set noreorder nop; \
subu $5,$0,$5 /* y = -y */ 2: .set noreorder nop; \
break 7 /* division on zero y */ .set reorder .set noreorder nop; \
subu $2,$0,$2 /* r = -r */ 4:
.globl __vr4120_divsi3
.ent __vr4120_divsi3
__vr4120_divsi3:
DIV
j $31
.end __vr4120_divsi3
.globl __vr4120_modsi3
.ent __vr4120_modsi3
__vr4120_modsi3:
move $6,$4 # x1 = x
move $7,$5 # y1 = y
DIV
mult $2,$7 # r = r * y1
mflo $2
.set noreorder
j $31
subu $2,$6,$2 # r = x1 - r in delay slot
.end __vr4120_modsi3