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 97*0Sstevel@tonic-gate! RTENTRY(.udiv) ! unsigned divide 98*0Sstevel@tonic-gate .global .udiv 99*0Sstevel@tonic-gate.udiv: 100*0Sstevel@tonic-gate b divide 101*0Sstevel@tonic-gate mov 0,%g1 ! result always positive 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate! RTENTRY(.div) ! SIGNED DIVIDE 104*0Sstevel@tonic-gate .global .div 105*0Sstevel@tonic-gate.div: 106*0Sstevel@tonic-gate orcc %o1,%o0,%g0 ! are either %o0 or %o1 negative 107*0Sstevel@tonic-gate bge divide ! if not, skip this junk 108*0Sstevel@tonic-gate xor %o1,%o0,%g1 ! record sign of result in sign of %g1 109*0Sstevel@tonic-gate tst %o1 110*0Sstevel@tonic-gate bge 2f 111*0Sstevel@tonic-gate tst %o0 112*0Sstevel@tonic-gate ! %o1 < 0 113*0Sstevel@tonic-gate bge divide 114*0Sstevel@tonic-gate neg %o1 115*0Sstevel@tonic-gate 2: 116*0Sstevel@tonic-gate ! %o0 < 0 117*0Sstevel@tonic-gate neg %o0 118*0Sstevel@tonic-gate ! FALL THROUGH 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gatedivide: 122*0Sstevel@tonic-gate! compute size of quotient, scale comparand 123*0Sstevel@tonic-gate orcc %o1,%g0,%o5 ! movcc %o1,%o5 124*0Sstevel@tonic-gate bnz 0f ! if %o1 != 0 125*0Sstevel@tonic-gate mov %o0,%o3 126*0Sstevel@tonic-gate ba zero_divide 127*0Sstevel@tonic-gate nop 128*0Sstevel@tonic-gate0: 129*0Sstevel@tonic-gate cmp %o3,%o5 130*0Sstevel@tonic-gate blu got_result ! if %o3<%o5 already, there's no point in continuing 131*0Sstevel@tonic-gate mov 0,%o2 132*0Sstevel@tonic-gate sethi %hi(1<<(32-4 -1)),%g2 133*0Sstevel@tonic-gate cmp %o3,%g2 134*0Sstevel@tonic-gate blu not_really_big 135*0Sstevel@tonic-gate mov 0,%o4 136*0Sstevel@tonic-gate ! 137*0Sstevel@tonic-gate ! here, the %o0 is >= 2^(31-4) or so. We must be careful here, as 138*0Sstevel@tonic-gate ! our usual 4-at-a-shot divide step will cause overflow and havoc. The 139*0Sstevel@tonic-gate ! total number of bits in the result here is 4*%o4+%g3, where %g3 <= 4. 140*0Sstevel@tonic-gate ! compute %o4, in an unorthodox manner: know we need to Shift %o5 into 141*0Sstevel@tonic-gate ! the top decade: so don't even bother to compare to %o3. 142*0Sstevel@tonic-gate 1: 143*0Sstevel@tonic-gate cmp %o5,%g2 144*0Sstevel@tonic-gate bgeu 3f 145*0Sstevel@tonic-gate mov 1,%g3 146*0Sstevel@tonic-gate sll %o5,4,%o5 147*0Sstevel@tonic-gate b 1b 148*0Sstevel@tonic-gate inc %o4 149*0Sstevel@tonic-gate ! now compute %g3 150*0Sstevel@tonic-gate 2: addcc %o5,%o5,%o5 151*0Sstevel@tonic-gate bcc not_too_big ! bcc not_too_big 152*0Sstevel@tonic-gate add %g3,1,%g3 153*0Sstevel@tonic-gate ! 154*0Sstevel@tonic-gate ! here if the %o1 overflowed when Shifting 155*0Sstevel@tonic-gate ! this means that %o3 has the high-order bit set 156*0Sstevel@tonic-gate ! restore %o5 and subtract from %o3 157*0Sstevel@tonic-gate sll %g2,4 ,%g2 ! high order bit 158*0Sstevel@tonic-gate srl %o5,1,%o5 ! rest of %o5 159*0Sstevel@tonic-gate add %o5,%g2,%o5 160*0Sstevel@tonic-gate b do_single_div 161*0Sstevel@tonic-gate sub %g3,1,%g3 162*0Sstevel@tonic-gate not_too_big: 163*0Sstevel@tonic-gate 3: cmp %o5,%o3 164*0Sstevel@tonic-gate blu 2b 165*0Sstevel@tonic-gate nop 166*0Sstevel@tonic-gate be do_single_div 167*0Sstevel@tonic-gate nop 168*0Sstevel@tonic-gate ! %o5 > %o3: went too far: back up 1 step 169*0Sstevel@tonic-gate ! srl %o5,1,%o5 170*0Sstevel@tonic-gate ! dec %g3 171*0Sstevel@tonic-gate ! do single-bit divide steps 172*0Sstevel@tonic-gate ! 173*0Sstevel@tonic-gate ! we have to be careful here. We know that %o3 >= %o5, so we can do the 174*0Sstevel@tonic-gate ! first divide step without thinking. BUT, the others are conditional, 175*0Sstevel@tonic-gate ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high- 176*0Sstevel@tonic-gate ! order bit set in the first step, just falling into the regular 177*0Sstevel@tonic-gate ! division loop will mess up the first time around. 178*0Sstevel@tonic-gate ! So we unroll slightly... 179*0Sstevel@tonic-gate do_single_div: 180*0Sstevel@tonic-gate deccc %g3 181*0Sstevel@tonic-gate bl end_regular_divide 182*0Sstevel@tonic-gate nop 183*0Sstevel@tonic-gate sub %o3,%o5,%o3 184*0Sstevel@tonic-gate mov 1,%o2 185*0Sstevel@tonic-gate b,a end_single_divloop 186*0Sstevel@tonic-gate single_divloop: 187*0Sstevel@tonic-gate sll %o2,1,%o2 188*0Sstevel@tonic-gate bl 1f 189*0Sstevel@tonic-gate srl %o5,1,%o5 190*0Sstevel@tonic-gate ! %o3 >= 0 191*0Sstevel@tonic-gate sub %o3,%o5,%o3 192*0Sstevel@tonic-gate b 2f 193*0Sstevel@tonic-gate inc %o2 194*0Sstevel@tonic-gate 1: ! %o3 < 0 195*0Sstevel@tonic-gate add %o3,%o5,%o3 196*0Sstevel@tonic-gate dec %o2 197*0Sstevel@tonic-gate 2: 198*0Sstevel@tonic-gate end_single_divloop: 199*0Sstevel@tonic-gate deccc %g3 200*0Sstevel@tonic-gate bge single_divloop 201*0Sstevel@tonic-gate tst %o3 202*0Sstevel@tonic-gate b,a end_regular_divide 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gatenot_really_big: 205*0Sstevel@tonic-gate1: 206*0Sstevel@tonic-gate sll %o5,4,%o5 207*0Sstevel@tonic-gate cmp %o5,%o3 208*0Sstevel@tonic-gate bleu 1b 209*0Sstevel@tonic-gate inccc %o4 210*0Sstevel@tonic-gate be got_result 211*0Sstevel@tonic-gate dec %o4 212*0Sstevel@tonic-gatedo_regular_divide: 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate! do the main division iteration 215*0Sstevel@tonic-gate tst %o3 216*0Sstevel@tonic-gate! fall through into divide loop 217*0Sstevel@tonic-gatedivloop: 218*0Sstevel@tonic-gate sll %o2,4,%o2 219*0Sstevel@tonic-gate !depth 1, accumulated bits 0 220*0Sstevel@tonic-gate bl L.1.16 221*0Sstevel@tonic-gate srl %o5,1,%o5 222*0Sstevel@tonic-gate ! remainder is positive 223*0Sstevel@tonic-gate subcc %o3,%o5,%o3 224*0Sstevel@tonic-gate !depth 2, accumulated bits 1 225*0Sstevel@tonic-gate bl L.2.17 226*0Sstevel@tonic-gate srl %o5,1,%o5 227*0Sstevel@tonic-gate ! remainder is positive 228*0Sstevel@tonic-gate subcc %o3,%o5,%o3 229*0Sstevel@tonic-gate !depth 3, accumulated bits 3 230*0Sstevel@tonic-gate bl L.3.19 231*0Sstevel@tonic-gate srl %o5,1,%o5 232*0Sstevel@tonic-gate ! remainder is positive 233*0Sstevel@tonic-gate subcc %o3,%o5,%o3 234*0Sstevel@tonic-gate !depth 4, accumulated bits 7 235*0Sstevel@tonic-gate bl L.4.23 236*0Sstevel@tonic-gate srl %o5,1,%o5 237*0Sstevel@tonic-gate ! remainder is positive 238*0Sstevel@tonic-gate subcc %o3,%o5,%o3 239*0Sstevel@tonic-gate b 9f 240*0Sstevel@tonic-gate add %o2, (7*2+1), %o2 241*0Sstevel@tonic-gate 242*0Sstevel@tonic-gateL.4.23: ! remainder is negative 243*0Sstevel@tonic-gate addcc %o3,%o5,%o3 244*0Sstevel@tonic-gate b 9f 245*0Sstevel@tonic-gate add %o2, (7*2-1), %o2 246*0Sstevel@tonic-gate 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gateL.3.19: ! remainder is negative 251*0Sstevel@tonic-gate addcc %o3,%o5,%o3 252*0Sstevel@tonic-gate !depth 4, accumulated bits 5 253*0Sstevel@tonic-gate bl L.4.21 254*0Sstevel@tonic-gate srl %o5,1,%o5 255*0Sstevel@tonic-gate ! remainder is positive 256*0Sstevel@tonic-gate subcc %o3,%o5,%o3 257*0Sstevel@tonic-gate b 9f 258*0Sstevel@tonic-gate add %o2, (5*2+1), %o2 259*0Sstevel@tonic-gate 260*0Sstevel@tonic-gateL.4.21: ! remainder is negative 261*0Sstevel@tonic-gate addcc %o3,%o5,%o3 262*0Sstevel@tonic-gate b 9f 263*0Sstevel@tonic-gate add %o2, (5*2-1), %o2 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-gate 271*0Sstevel@tonic-gateL.2.17: ! remainder is negative 272*0Sstevel@tonic-gate addcc %o3,%o5,%o3 273*0Sstevel@tonic-gate !depth 3, accumulated bits 1 274*0Sstevel@tonic-gate bl L.3.17 275*0Sstevel@tonic-gate srl %o5,1,%o5 276*0Sstevel@tonic-gate ! remainder is positive 277*0Sstevel@tonic-gate subcc %o3,%o5,%o3 278*0Sstevel@tonic-gate !depth 4, accumulated bits 3 279*0Sstevel@tonic-gate bl L.4.19 280*0Sstevel@tonic-gate srl %o5,1,%o5 281*0Sstevel@tonic-gate ! remainder is positive 282*0Sstevel@tonic-gate subcc %o3,%o5,%o3 283*0Sstevel@tonic-gate b 9f 284*0Sstevel@tonic-gate add %o2, (3*2+1), %o2 285*0Sstevel@tonic-gate 286*0Sstevel@tonic-gateL.4.19: ! remainder is negative 287*0Sstevel@tonic-gate addcc %o3,%o5,%o3 288*0Sstevel@tonic-gate b 9f 289*0Sstevel@tonic-gate add %o2, (3*2-1), %o2 290*0Sstevel@tonic-gate 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gateL.3.17: ! remainder is negative 295*0Sstevel@tonic-gate addcc %o3,%o5,%o3 296*0Sstevel@tonic-gate !depth 4, accumulated bits 1 297*0Sstevel@tonic-gate bl L.4.17 298*0Sstevel@tonic-gate srl %o5,1,%o5 299*0Sstevel@tonic-gate ! remainder is positive 300*0Sstevel@tonic-gate subcc %o3,%o5,%o3 301*0Sstevel@tonic-gate b 9f 302*0Sstevel@tonic-gate add %o2, (1*2+1), %o2 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gateL.4.17: ! remainder is negative 305*0Sstevel@tonic-gate addcc %o3,%o5,%o3 306*0Sstevel@tonic-gate b 9f 307*0Sstevel@tonic-gate add %o2, (1*2-1), %o2 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-gate 318*0Sstevel@tonic-gateL.1.16: ! remainder is negative 319*0Sstevel@tonic-gate addcc %o3,%o5,%o3 320*0Sstevel@tonic-gate !depth 2, accumulated bits -1 321*0Sstevel@tonic-gate bl L.2.15 322*0Sstevel@tonic-gate srl %o5,1,%o5 323*0Sstevel@tonic-gate ! remainder is positive 324*0Sstevel@tonic-gate subcc %o3,%o5,%o3 325*0Sstevel@tonic-gate !depth 3, accumulated bits -1 326*0Sstevel@tonic-gate bl L.3.15 327*0Sstevel@tonic-gate srl %o5,1,%o5 328*0Sstevel@tonic-gate ! remainder is positive 329*0Sstevel@tonic-gate subcc %o3,%o5,%o3 330*0Sstevel@tonic-gate !depth 4, accumulated bits -1 331*0Sstevel@tonic-gate bl L.4.15 332*0Sstevel@tonic-gate srl %o5,1,%o5 333*0Sstevel@tonic-gate ! remainder is positive 334*0Sstevel@tonic-gate subcc %o3,%o5,%o3 335*0Sstevel@tonic-gate b 9f 336*0Sstevel@tonic-gate add %o2, (-1*2+1), %o2 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gateL.4.15: ! remainder is negative 339*0Sstevel@tonic-gate addcc %o3,%o5,%o3 340*0Sstevel@tonic-gate b 9f 341*0Sstevel@tonic-gate add %o2, (-1*2-1), %o2 342*0Sstevel@tonic-gate 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gateL.3.15: ! remainder is negative 347*0Sstevel@tonic-gate addcc %o3,%o5,%o3 348*0Sstevel@tonic-gate !depth 4, accumulated bits -3 349*0Sstevel@tonic-gate bl L.4.13 350*0Sstevel@tonic-gate srl %o5,1,%o5 351*0Sstevel@tonic-gate ! remainder is positive 352*0Sstevel@tonic-gate subcc %o3,%o5,%o3 353*0Sstevel@tonic-gate b 9f 354*0Sstevel@tonic-gate add %o2, (-3*2+1), %o2 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gateL.4.13: ! remainder is negative 357*0Sstevel@tonic-gate addcc %o3,%o5,%o3 358*0Sstevel@tonic-gate b 9f 359*0Sstevel@tonic-gate add %o2, (-3*2-1), %o2 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-gate 367*0Sstevel@tonic-gateL.2.15: ! remainder is negative 368*0Sstevel@tonic-gate addcc %o3,%o5,%o3 369*0Sstevel@tonic-gate !depth 3, accumulated bits -3 370*0Sstevel@tonic-gate bl L.3.13 371*0Sstevel@tonic-gate srl %o5,1,%o5 372*0Sstevel@tonic-gate ! remainder is positive 373*0Sstevel@tonic-gate subcc %o3,%o5,%o3 374*0Sstevel@tonic-gate !depth 4, accumulated bits -5 375*0Sstevel@tonic-gate bl L.4.11 376*0Sstevel@tonic-gate srl %o5,1,%o5 377*0Sstevel@tonic-gate ! remainder is positive 378*0Sstevel@tonic-gate subcc %o3,%o5,%o3 379*0Sstevel@tonic-gate b 9f 380*0Sstevel@tonic-gate add %o2, (-5*2+1), %o2 381*0Sstevel@tonic-gate 382*0Sstevel@tonic-gateL.4.11: ! remainder is negative 383*0Sstevel@tonic-gate addcc %o3,%o5,%o3 384*0Sstevel@tonic-gate b 9f 385*0Sstevel@tonic-gate add %o2, (-5*2-1), %o2 386*0Sstevel@tonic-gate 387*0Sstevel@tonic-gate 388*0Sstevel@tonic-gate 389*0Sstevel@tonic-gate 390*0Sstevel@tonic-gateL.3.13: ! remainder is negative 391*0Sstevel@tonic-gate addcc %o3,%o5,%o3 392*0Sstevel@tonic-gate !depth 4, accumulated bits -7 393*0Sstevel@tonic-gate bl L.4.9 394*0Sstevel@tonic-gate srl %o5,1,%o5 395*0Sstevel@tonic-gate ! remainder is positive 396*0Sstevel@tonic-gate subcc %o3,%o5,%o3 397*0Sstevel@tonic-gate b 9f 398*0Sstevel@tonic-gate add %o2, (-7*2+1), %o2 399*0Sstevel@tonic-gate 400*0Sstevel@tonic-gateL.4.9: ! remainder is negative 401*0Sstevel@tonic-gate addcc %o3,%o5,%o3 402*0Sstevel@tonic-gate b 9f 403*0Sstevel@tonic-gate add %o2, (-7*2-1), %o2 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 414*0Sstevel@tonic-gate 9: 415*0Sstevel@tonic-gate 416*0Sstevel@tonic-gateend_regular_divide: 417*0Sstevel@tonic-gate deccc %o4 418*0Sstevel@tonic-gate bge divloop 419*0Sstevel@tonic-gate tst %o3 420*0Sstevel@tonic-gate bl,a got_result 421*0Sstevel@tonic-gate dec %o2 422*0Sstevel@tonic-gate 423*0Sstevel@tonic-gate 424*0Sstevel@tonic-gategot_result: 425*0Sstevel@tonic-gate tst %g1 426*0Sstevel@tonic-gate bl,a 1f 427*0Sstevel@tonic-gate neg %o2 ! quotient <- -%o2 428*0Sstevel@tonic-gate 429*0Sstevel@tonic-gate1: 430*0Sstevel@tonic-gate retl 431*0Sstevel@tonic-gate mov %o2,%o0 ! quotient <- %o2 432*0Sstevel@tonic-gate 433*0Sstevel@tonic-gate 434*0Sstevel@tonic-gatezero_divide: 435*0Sstevel@tonic-gate ta ST_DIV0 ! divide by zero trap 436*0Sstevel@tonic-gate retl ! if handled, ignored, return 437*0Sstevel@tonic-gate mov 0, %o0 438