#include <linux/linkage.h>12/*3* Divide operation for 32 bit integers.4* Input : Dividend in Reg r55* Divisor in Reg r66* Output: Result in Reg r37*/8.text9.globl __divsi310.type __divsi3, @function11.ent __divsi312__divsi3:13.frame r1, 0, r151415addik r1, r1, -1616swi r28, r1, 017swi r29, r1, 418swi r30, r1, 819swi r31, r1, 122021beqi r6, div_by_zero /* div_by_zero - division error */22beqi r5, result_is_zero /* result is zero */23bgeid r5, r5_pos24xor r28, r5, r6 /* get the sign of the result */25rsubi r5, r5, 0 /* make r5 positive */26r5_pos:27bgei r6, r6_pos28rsubi r6, r6, 0 /* make r6 positive */29r6_pos:30addik r30, r0, 0 /* clear mod */31addik r3, r0, 0 /* clear div */32addik r29, r0, 32 /* initialize the loop count */3334/* first part try to find the first '1' in the r5 */35div0:36blti r5, div2 /* this traps r5 == 0x80000000 */37div1:38add r5, r5, r5 /* left shift logical r5 */39bgtid r5, div140addik r29, r29, -141div2:42/* left shift logical r5 get the '1' into the carry */43add r5, r5, r544addc r30, r30, r30 /* move that bit into the mod register */45rsub r31, r6, r30 /* try to subtract (r30 a r6) */46blti r31, mod_too_small47/* move the r31 to mod since the result was positive */48or r30, r0, r3149addik r3, r3, 150mod_too_small:51addik r29, r29, -152beqi r29, loop_end53add r3, r3, r3 /* shift in the '1' into div */54bri div2 /* div2 */55loop_end:56bgei r28, return_here57brid return_here58rsubi r3, r3, 0 /* negate the result */59div_by_zero:60result_is_zero:61or r3, r0, r0 /* set result to 0 */62return_here:63/* restore values of csrs and that of r3 and the divisor and the dividend */64lwi r28, r1, 065lwi r29, r1, 466lwi r30, r1, 867lwi r31, r1, 1268rtsd r15, 869addik r1, r1, 167071.size __divsi3, . - __divsi372.end __divsi3737475