#include <linux/linkage.h>12/*3* modulo operation for 32 bit integers.4* Input : op1 in Reg r55* op2 in Reg r66* Output: op1 mod op2 in Reg r37*/89.text10.globl __modsi311.type __modsi3, @function12.ent __modsi31314__modsi3:15.frame r1, 0, r151617addik r1, r1, -1618swi r28, r1, 019swi r29, r1, 420swi r30, r1, 821swi r31, r1, 122223beqi r6, div_by_zero /* div_by_zero division error */24beqi r5, result_is_zero /* result is zero */25bgeid r5, r5_pos26/* get the sign of the result [ depends only on the first arg] */27add r28, r5, r028rsubi r5, r5, 0 /* make r5 positive */29r5_pos:30bgei r6, r6_pos31rsubi r6, r6, 0 /* make r6 positive */32r6_pos:33addik r3, r0, 0 /* clear mod */34addik r30, r0, 0 /* clear div */35addik r29, r0, 32 /* initialize the loop count */36/* first part try to find the first '1' in the r5 */37div1:38add r5, r5, r5 /* left shift logical r5 */39bgeid r5, div140addik r29, r29, -141div2:42/* left shift logical r5 get the '1' into the carry */43add r5, r5, r544addc r3, r3, r3 /* move that bit into the mod register */45rsub r31, r6, r3 /* try to subtract (r30 a r6) */46blti r31, mod_too_small47/* move the r31 to mod since the result was positive */48or r3, r0, r3149addik r30, r30, 150mod_too_small:51addik r29, r29, -152beqi r29, loop_end53add r30, r30, r30 /* 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 [both mod as well as div are 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 __modsi3, . - __modsi372.end __modsi3737475