#include <linux/linkage.h>12/*3* Unsigned 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 __umodsi311.type __umodsi3, @function12.ent __umodsi31314__umodsi3:15.frame r1, 0, r151617addik r1, r1, -1218swi r29, r1, 019swi r30, r1, 420swi r31, r1, 82122beqi r6, div_by_zero /* div_by_zero - division error */23beqid r5, result_is_zero /* result is zero */24addik r3, r0, 0 /* clear div */25addik r30, r0, 0 /* clear mod */26addik r29, r0, 32 /* initialize the loop count */2728/* check if r6 and r5 are equal /* if yes, return 0 */29rsub r18, r5, r630beqi r18, return_here3132/* check if (uns)r6 is greater than (uns)r5. in that case, just return r5 */33xor r18, r5, r634bgeid r18, 1635addik r3, r5, 036blti r6, return_here37bri $lcheckr638rsub r18, r5, r6 /* microblazecmp */39bgti r18, return_here4041/* if r6 [bit 31] is set, then return result as r5-r6 */42$lcheckr6:43bgtid r6, div044addik r3, r0, 045addik r18, r0, 0x7fffffff46and r5, r5, r1847and r6, r6, r1848brid return_here49rsub r3, r6, r550/* first part: try to find the first '1' in the r5 */51div0:52blti r5, div253div1:54add r5, r5, r5 /* left shift logical r5 */55bgeid r5, div156addik r29, r29, -157div2:58/* left shift logical r5 get the '1' into the carry */59add r5, r5, r560addc r3, r3, r3 /* move that bit into the mod register */61rsub r31, r6, r3 /* try to subtract (r3 a r6) */62blti r31, mod_too_small63/* move the r31 to mod since the result was positive */64or r3, r0, r3165addik r30, r30, 166mod_too_small:67addik r29, r29, -168beqi r29, loop_end69add r30, r30, r30 /* shift in the '1' into div */70bri div2 /* div2 */71loop_end:72bri return_here73div_by_zero:74result_is_zero:75or r3, r0, r0 /* set result to 0 */76return_here:77/* restore values of csrs and that of r3 and the divisor and the dividend */78lwi r29, r1, 079lwi r30, r1, 480lwi r31, r1, 881rtsd r15, 882addik r1, r1, 128384.size __umodsi3, . - __umodsi385.end __umodsi3868788