1*0Sstevel@tonic-gate/* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate! .seg "data" 24*0Sstevel@tonic-gate! .asciz "Copyr 1986 Sun Micro" 25*0Sstevel@tonic-gate .seg "text" 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate/* 30*0Sstevel@tonic-gate * Copyright 1986 Sun Microsystems, Inc. All rights reserved. 31*0Sstevel@tonic-gate * Use is subject to license terms. 32*0Sstevel@tonic-gate */ 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate/* 35*0Sstevel@tonic-gate * divison/remainder 36*0Sstevel@tonic-gate * 37*0Sstevel@tonic-gate * Input is: 38*0Sstevel@tonic-gate * dividend -- the thing being divided 39*0Sstevel@tonic-gate * divisor -- how many ways to divide 40*0Sstevel@tonic-gate * Important parameters: 41*0Sstevel@tonic-gate * N -- how many bits per iteration we try to get 42*0Sstevel@tonic-gate * as our current guess: 43*0Sstevel@tonic-gate * WORDSIZE -- how many bits altogether we're talking about: 44*0Sstevel@tonic-gate * obviously: 45*0Sstevel@tonic-gate * A derived constant: 46*0Sstevel@tonic-gate * TOPBITS -- how many bits are in the top "decade" of a number: 47*0Sstevel@tonic-gate * 48*0Sstevel@tonic-gate * Important variables are: 49*0Sstevel@tonic-gate * Q -- the partial quotient under development -- initally 0 50*0Sstevel@tonic-gate * R -- the remainder so far -- initially == the dividend 51*0Sstevel@tonic-gate * ITER -- number of iterations of the main division loop will 52*0Sstevel@tonic-gate * be required. Equal to CEIL( lg2(quotient)/4 ) 53*0Sstevel@tonic-gate * Note that this is log_base_(2^4) of the quotient. 54*0Sstevel@tonic-gate * V -- the current comparand -- initially divisor*2^(ITER*4-1) 55*0Sstevel@tonic-gate * Cost: 56*0Sstevel@tonic-gate * current estimate for non-large dividend is 57*0Sstevel@tonic-gate * CEIL( lg2(quotient) / 4 ) x ( 10 + 74/2 ) + C 58*0Sstevel@tonic-gate * a large dividend is one greater than 2^(31-4 ) and takes a 59*0Sstevel@tonic-gate * different path, as the upper bits of the quotient must be developed 60*0Sstevel@tonic-gate * one bit at a time. 61*0Sstevel@tonic-gate */ 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate#include <sys/trap.h> 64*0Sstevel@tonic-gate#include <sys/asm_linkage.h> 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate ! working variable 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate/* 77*0Sstevel@tonic-gate * this is the recursive definition of how we develop quotient digits. 78*0Sstevel@tonic-gate * it takes three important parameters: 79*0Sstevel@tonic-gate * $1 -- the current depth, 1<=$1<=4 80*0Sstevel@tonic-gate * $2 -- the current accumulation of quotient bits 81*0Sstevel@tonic-gate * 4 -- max depth 82*0Sstevel@tonic-gate * We add a new bit to $2 and either recurse or 83*0Sstevel@tonic-gate * insert the bits in the quotient. 84*0Sstevel@tonic-gate * Dynamic input: 85*0Sstevel@tonic-gate * %o3 -- current remainder 86*0Sstevel@tonic-gate * %o2 -- current quotient 87*0Sstevel@tonic-gate * %o5 -- current comparand 88*0Sstevel@tonic-gate * cc -- set on current value of %o3 89*0Sstevel@tonic-gate * Dynamic output: 90*0Sstevel@tonic-gate * %o3', %o2', %o5', cc' 91*0Sstevel@tonic-gate */ 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate! RTENTRY(.urem) ! UNSIGNED REMAINDER 97*0Sstevel@tonic-gate .global .urem 98*0Sstevel@tonic-gate.urem: 99*0Sstevel@tonic-gate b divide 100*0Sstevel@tonic-gate mov 0,%g1 ! result always positive 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate! RTENTRY(.rem) ! SIGNED REMAINDER 103*0Sstevel@tonic-gate .global .rem 104*0Sstevel@tonic-gate.rem: 105*0Sstevel@tonic-gate orcc %o1,%o0,%g0 ! are either %o0 or %o1 negative 106*0Sstevel@tonic-gate bge divide ! if not, skip this junk 107*0Sstevel@tonic-gate mov %o0,%g1 ! record sign of result in sign of %g1 108*0Sstevel@tonic-gate tst %o1 109*0Sstevel@tonic-gate bge 2f 110*0Sstevel@tonic-gate tst %o0 111*0Sstevel@tonic-gate ! %o1 < 0 112*0Sstevel@tonic-gate bge divide 113*0Sstevel@tonic-gate neg %o1 114*0Sstevel@tonic-gate 2: 115*0Sstevel@tonic-gate ! %o0 < 0 116*0Sstevel@tonic-gate neg %o0 117*0Sstevel@tonic-gate ! FALL THROUGH 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gatedivide: 121*0Sstevel@tonic-gate! compute size of quotient, scale comparand 122*0Sstevel@tonic-gate orcc %o1,%g0,%o5 ! movcc %o1,%o5 123*0Sstevel@tonic-gate bnz 0f ! if %o1 != 0 124*0Sstevel@tonic-gate mov %o0,%o3 125*0Sstevel@tonic-gate ba zero_divide 126*0Sstevel@tonic-gate nop 127*0Sstevel@tonic-gate0: 128*0Sstevel@tonic-gate cmp %o3,%o5 129*0Sstevel@tonic-gate blu got_result ! if %o3<%o5 already, there's no point in continuing 130*0Sstevel@tonic-gate mov 0,%o2 131*0Sstevel@tonic-gate sethi %hi(1<<(32-4 -1)),%g2 132*0Sstevel@tonic-gate cmp %o3,%g2 133*0Sstevel@tonic-gate blu not_really_big 134*0Sstevel@tonic-gate mov 0,%o4 135*0Sstevel@tonic-gate ! 136*0Sstevel@tonic-gate ! here, the %o0 is >= 2^(31-4) or so. We must be careful here, as 137*0Sstevel@tonic-gate ! our usual 4-at-a-shot divide step will cause overflow and havoc. The 138*0Sstevel@tonic-gate ! total number of bits in the result here is 4*%o4+%g3, where %g3 <= 4. 139*0Sstevel@tonic-gate ! compute %o4, in an unorthodox manner: know we need to Shift %o5 into 140*0Sstevel@tonic-gate ! the top decade: so don't even bother to compare to %o3. 141*0Sstevel@tonic-gate 1: 142*0Sstevel@tonic-gate cmp %o5,%g2 143*0Sstevel@tonic-gate bgeu 3f 144*0Sstevel@tonic-gate mov 1,%g3 145*0Sstevel@tonic-gate sll %o5,4,%o5 146*0Sstevel@tonic-gate b 1b 147*0Sstevel@tonic-gate inc %o4 148*0Sstevel@tonic-gate ! now compute %g3 149*0Sstevel@tonic-gate 2: addcc %o5,%o5,%o5 150*0Sstevel@tonic-gate bcc not_too_big ! bcc not_too_big 151*0Sstevel@tonic-gate add %g3,1,%g3 152*0Sstevel@tonic-gate ! 153*0Sstevel@tonic-gate ! here if the %o1 overflowed when Shifting 154*0Sstevel@tonic-gate ! this means that %o3 has the high-order bit set 155*0Sstevel@tonic-gate ! restore %o5 and subtract from %o3 156*0Sstevel@tonic-gate sll %g2,4 ,%g2 ! high order bit 157*0Sstevel@tonic-gate srl %o5,1,%o5 ! rest of %o5 158*0Sstevel@tonic-gate add %o5,%g2,%o5 159*0Sstevel@tonic-gate b do_single_div 160*0Sstevel@tonic-gate sub %g3,1,%g3 161*0Sstevel@tonic-gate not_too_big: 162*0Sstevel@tonic-gate 3: cmp %o5,%o3 163*0Sstevel@tonic-gate blu 2b 164*0Sstevel@tonic-gate nop 165*0Sstevel@tonic-gate be do_single_div 166*0Sstevel@tonic-gate nop 167*0Sstevel@tonic-gate ! %o5 > %o3: went too far: back up 1 step 168*0Sstevel@tonic-gate ! srl %o5,1,%o5 169*0Sstevel@tonic-gate ! dec %g3 170*0Sstevel@tonic-gate ! do single-bit divide steps 171*0Sstevel@tonic-gate ! 172*0Sstevel@tonic-gate ! we have to be careful here. We know that %o3 >= %o5, so we can do the 173*0Sstevel@tonic-gate ! first divide step without thinking. BUT, the others are conditional, 174*0Sstevel@tonic-gate ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high- 175*0Sstevel@tonic-gate ! order bit set in the first step, just falling into the regular 176*0Sstevel@tonic-gate ! division loop will mess up the first time around. 177*0Sstevel@tonic-gate ! So we unroll slightly... 178*0Sstevel@tonic-gate do_single_div: 179*0Sstevel@tonic-gate deccc %g3 180*0Sstevel@tonic-gate bl end_regular_divide 181*0Sstevel@tonic-gate nop 182*0Sstevel@tonic-gate sub %o3,%o5,%o3 183*0Sstevel@tonic-gate mov 1,%o2 184*0Sstevel@tonic-gate b,a end_single_divloop 185*0Sstevel@tonic-gate single_divloop: 186*0Sstevel@tonic-gate sll %o2,1,%o2 187*0Sstevel@tonic-gate bl 1f 188*0Sstevel@tonic-gate srl %o5,1,%o5 189*0Sstevel@tonic-gate ! %o3 >= 0 190*0Sstevel@tonic-gate sub %o3,%o5,%o3 191*0Sstevel@tonic-gate b 2f 192*0Sstevel@tonic-gate inc %o2 193*0Sstevel@tonic-gate 1: ! %o3 < 0 194*0Sstevel@tonic-gate add %o3,%o5,%o3 195*0Sstevel@tonic-gate dec %o2 196*0Sstevel@tonic-gate 2: 197*0Sstevel@tonic-gate end_single_divloop: 198*0Sstevel@tonic-gate deccc %g3 199*0Sstevel@tonic-gate bge single_divloop 200*0Sstevel@tonic-gate tst %o3 201*0Sstevel@tonic-gate b,a end_regular_divide 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gatenot_really_big: 204*0Sstevel@tonic-gate1: 205*0Sstevel@tonic-gate sll %o5,4,%o5 206*0Sstevel@tonic-gate cmp %o5,%o3 207*0Sstevel@tonic-gate bleu 1b 208*0Sstevel@tonic-gate inccc %o4 209*0Sstevel@tonic-gate be got_result 210*0Sstevel@tonic-gate dec %o4 211*0Sstevel@tonic-gatedo_regular_divide: 212*0Sstevel@tonic-gate 213*0Sstevel@tonic-gate! do the main division iteration 214*0Sstevel@tonic-gate tst %o3 215*0Sstevel@tonic-gate! fall through into divide loop 216*0Sstevel@tonic-gatedivloop: 217*0Sstevel@tonic-gate sll %o2,4,%o2 218*0Sstevel@tonic-gate !depth 1, accumulated bits 0 219*0Sstevel@tonic-gate bl L.1.16 220*0Sstevel@tonic-gate srl %o5,1,%o5 221*0Sstevel@tonic-gate ! remainder is positive 222*0Sstevel@tonic-gate subcc %o3,%o5,%o3 223*0Sstevel@tonic-gate !depth 2, accumulated bits 1 224*0Sstevel@tonic-gate bl L.2.17 225*0Sstevel@tonic-gate srl %o5,1,%o5 226*0Sstevel@tonic-gate ! remainder is positive 227*0Sstevel@tonic-gate subcc %o3,%o5,%o3 228*0Sstevel@tonic-gate !depth 3, accumulated bits 3 229*0Sstevel@tonic-gate bl L.3.19 230*0Sstevel@tonic-gate srl %o5,1,%o5 231*0Sstevel@tonic-gate ! remainder is positive 232*0Sstevel@tonic-gate subcc %o3,%o5,%o3 233*0Sstevel@tonic-gate !depth 4, accumulated bits 7 234*0Sstevel@tonic-gate bl L.4.23 235*0Sstevel@tonic-gate srl %o5,1,%o5 236*0Sstevel@tonic-gate ! remainder is positive 237*0Sstevel@tonic-gate subcc %o3,%o5,%o3 238*0Sstevel@tonic-gate b 9f 239*0Sstevel@tonic-gate add %o2, (7*2+1), %o2 240*0Sstevel@tonic-gate 241*0Sstevel@tonic-gateL.4.23: ! remainder is negative 242*0Sstevel@tonic-gate addcc %o3,%o5,%o3 243*0Sstevel@tonic-gate b 9f 244*0Sstevel@tonic-gate add %o2, (7*2-1), %o2 245*0Sstevel@tonic-gate 246*0Sstevel@tonic-gate 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gateL.3.19: ! remainder is negative 250*0Sstevel@tonic-gate addcc %o3,%o5,%o3 251*0Sstevel@tonic-gate !depth 4, accumulated bits 5 252*0Sstevel@tonic-gate bl L.4.21 253*0Sstevel@tonic-gate srl %o5,1,%o5 254*0Sstevel@tonic-gate ! remainder is positive 255*0Sstevel@tonic-gate subcc %o3,%o5,%o3 256*0Sstevel@tonic-gate b 9f 257*0Sstevel@tonic-gate add %o2, (5*2+1), %o2 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gateL.4.21: ! remainder is negative 260*0Sstevel@tonic-gate addcc %o3,%o5,%o3 261*0Sstevel@tonic-gate b 9f 262*0Sstevel@tonic-gate add %o2, (5*2-1), %o2 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gate 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gate 269*0Sstevel@tonic-gate 270*0Sstevel@tonic-gateL.2.17: ! remainder is negative 271*0Sstevel@tonic-gate addcc %o3,%o5,%o3 272*0Sstevel@tonic-gate !depth 3, accumulated bits 1 273*0Sstevel@tonic-gate bl L.3.17 274*0Sstevel@tonic-gate srl %o5,1,%o5 275*0Sstevel@tonic-gate ! remainder is positive 276*0Sstevel@tonic-gate subcc %o3,%o5,%o3 277*0Sstevel@tonic-gate !depth 4, accumulated bits 3 278*0Sstevel@tonic-gate bl L.4.19 279*0Sstevel@tonic-gate srl %o5,1,%o5 280*0Sstevel@tonic-gate ! remainder is positive 281*0Sstevel@tonic-gate subcc %o3,%o5,%o3 282*0Sstevel@tonic-gate b 9f 283*0Sstevel@tonic-gate add %o2, (3*2+1), %o2 284*0Sstevel@tonic-gate 285*0Sstevel@tonic-gateL.4.19: ! remainder is negative 286*0Sstevel@tonic-gate addcc %o3,%o5,%o3 287*0Sstevel@tonic-gate b 9f 288*0Sstevel@tonic-gate add %o2, (3*2-1), %o2 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gateL.3.17: ! remainder is negative 294*0Sstevel@tonic-gate addcc %o3,%o5,%o3 295*0Sstevel@tonic-gate !depth 4, accumulated bits 1 296*0Sstevel@tonic-gate bl L.4.17 297*0Sstevel@tonic-gate srl %o5,1,%o5 298*0Sstevel@tonic-gate ! remainder is positive 299*0Sstevel@tonic-gate subcc %o3,%o5,%o3 300*0Sstevel@tonic-gate b 9f 301*0Sstevel@tonic-gate add %o2, (1*2+1), %o2 302*0Sstevel@tonic-gate 303*0Sstevel@tonic-gateL.4.17: ! remainder is negative 304*0Sstevel@tonic-gate addcc %o3,%o5,%o3 305*0Sstevel@tonic-gate b 9f 306*0Sstevel@tonic-gate add %o2, (1*2-1), %o2 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gate 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate 311*0Sstevel@tonic-gate 312*0Sstevel@tonic-gate 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate 315*0Sstevel@tonic-gate 316*0Sstevel@tonic-gate 317*0Sstevel@tonic-gateL.1.16: ! remainder is negative 318*0Sstevel@tonic-gate addcc %o3,%o5,%o3 319*0Sstevel@tonic-gate !depth 2, accumulated bits -1 320*0Sstevel@tonic-gate bl L.2.15 321*0Sstevel@tonic-gate srl %o5,1,%o5 322*0Sstevel@tonic-gate ! remainder is positive 323*0Sstevel@tonic-gate subcc %o3,%o5,%o3 324*0Sstevel@tonic-gate !depth 3, accumulated bits -1 325*0Sstevel@tonic-gate bl L.3.15 326*0Sstevel@tonic-gate srl %o5,1,%o5 327*0Sstevel@tonic-gate ! remainder is positive 328*0Sstevel@tonic-gate subcc %o3,%o5,%o3 329*0Sstevel@tonic-gate !depth 4, accumulated bits -1 330*0Sstevel@tonic-gate bl L.4.15 331*0Sstevel@tonic-gate srl %o5,1,%o5 332*0Sstevel@tonic-gate ! remainder is positive 333*0Sstevel@tonic-gate subcc %o3,%o5,%o3 334*0Sstevel@tonic-gate b 9f 335*0Sstevel@tonic-gate add %o2, (-1*2+1), %o2 336*0Sstevel@tonic-gate 337*0Sstevel@tonic-gateL.4.15: ! remainder is negative 338*0Sstevel@tonic-gate addcc %o3,%o5,%o3 339*0Sstevel@tonic-gate b 9f 340*0Sstevel@tonic-gate add %o2, (-1*2-1), %o2 341*0Sstevel@tonic-gate 342*0Sstevel@tonic-gate 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate 345*0Sstevel@tonic-gateL.3.15: ! remainder is negative 346*0Sstevel@tonic-gate addcc %o3,%o5,%o3 347*0Sstevel@tonic-gate !depth 4, accumulated bits -3 348*0Sstevel@tonic-gate bl L.4.13 349*0Sstevel@tonic-gate srl %o5,1,%o5 350*0Sstevel@tonic-gate ! remainder is positive 351*0Sstevel@tonic-gate subcc %o3,%o5,%o3 352*0Sstevel@tonic-gate b 9f 353*0Sstevel@tonic-gate add %o2, (-3*2+1), %o2 354*0Sstevel@tonic-gate 355*0Sstevel@tonic-gateL.4.13: ! remainder is negative 356*0Sstevel@tonic-gate addcc %o3,%o5,%o3 357*0Sstevel@tonic-gate b 9f 358*0Sstevel@tonic-gate add %o2, (-3*2-1), %o2 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gate 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate 364*0Sstevel@tonic-gate 365*0Sstevel@tonic-gate 366*0Sstevel@tonic-gateL.2.15: ! remainder is negative 367*0Sstevel@tonic-gate addcc %o3,%o5,%o3 368*0Sstevel@tonic-gate !depth 3, accumulated bits -3 369*0Sstevel@tonic-gate bl L.3.13 370*0Sstevel@tonic-gate srl %o5,1,%o5 371*0Sstevel@tonic-gate ! remainder is positive 372*0Sstevel@tonic-gate subcc %o3,%o5,%o3 373*0Sstevel@tonic-gate !depth 4, accumulated bits -5 374*0Sstevel@tonic-gate bl L.4.11 375*0Sstevel@tonic-gate srl %o5,1,%o5 376*0Sstevel@tonic-gate ! remainder is positive 377*0Sstevel@tonic-gate subcc %o3,%o5,%o3 378*0Sstevel@tonic-gate b 9f 379*0Sstevel@tonic-gate add %o2, (-5*2+1), %o2 380*0Sstevel@tonic-gate 381*0Sstevel@tonic-gateL.4.11: ! remainder is negative 382*0Sstevel@tonic-gate addcc %o3,%o5,%o3 383*0Sstevel@tonic-gate b 9f 384*0Sstevel@tonic-gate add %o2, (-5*2-1), %o2 385*0Sstevel@tonic-gate 386*0Sstevel@tonic-gate 387*0Sstevel@tonic-gate 388*0Sstevel@tonic-gate 389*0Sstevel@tonic-gateL.3.13: ! remainder is negative 390*0Sstevel@tonic-gate addcc %o3,%o5,%o3 391*0Sstevel@tonic-gate !depth 4, accumulated bits -7 392*0Sstevel@tonic-gate bl L.4.9 393*0Sstevel@tonic-gate srl %o5,1,%o5 394*0Sstevel@tonic-gate ! remainder is positive 395*0Sstevel@tonic-gate subcc %o3,%o5,%o3 396*0Sstevel@tonic-gate b 9f 397*0Sstevel@tonic-gate add %o2, (-7*2+1), %o2 398*0Sstevel@tonic-gate 399*0Sstevel@tonic-gateL.4.9: ! remainder is negative 400*0Sstevel@tonic-gate addcc %o3,%o5,%o3 401*0Sstevel@tonic-gate b 9f 402*0Sstevel@tonic-gate add %o2, (-7*2-1), %o2 403*0Sstevel@tonic-gate 404*0Sstevel@tonic-gate 405*0Sstevel@tonic-gate 406*0Sstevel@tonic-gate 407*0Sstevel@tonic-gate 408*0Sstevel@tonic-gate 409*0Sstevel@tonic-gate 410*0Sstevel@tonic-gate 411*0Sstevel@tonic-gate 412*0Sstevel@tonic-gate 413*0Sstevel@tonic-gate 9: 414*0Sstevel@tonic-gate 415*0Sstevel@tonic-gateend_regular_divide: 416*0Sstevel@tonic-gate deccc %o4 417*0Sstevel@tonic-gate bge divloop 418*0Sstevel@tonic-gate tst %o3 419*0Sstevel@tonic-gate bl,a got_result 420*0Sstevel@tonic-gate add %o3,%o1,%o3 421*0Sstevel@tonic-gate 422*0Sstevel@tonic-gate 423*0Sstevel@tonic-gategot_result: 424*0Sstevel@tonic-gate tst %g1 425*0Sstevel@tonic-gate bl,a 1f 426*0Sstevel@tonic-gate neg %o3 ! remainder <- -%o3 427*0Sstevel@tonic-gate 428*0Sstevel@tonic-gate1: 429*0Sstevel@tonic-gate retl 430*0Sstevel@tonic-gate mov %o3,%o0 ! remainder <- %o3 431*0Sstevel@tonic-gate 432*0Sstevel@tonic-gate 433*0Sstevel@tonic-gatezero_divide: 434*0Sstevel@tonic-gate ta ST_DIV0 ! divide by zero trap 435*0Sstevel@tonic-gate retl ! if handled, ignored, return 436*0Sstevel@tonic-gate mov 0, %o0 437