BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
BEQI r5,$LaResult_Is_Zero # Result is Zero
+ BGEId r5,$LaR5_Pos
ADD r28,r5,r0 # Get the sign of the result [ Depends only on the first arg]
- BGEI r5,$LaR5_Pos
RSUBI r5,r5,0 # Make r5 positive
$LaR5_Pos:
BGEI r6,$LaR6_Pos
# First part try to find the first '1' in the r5
$LaDIV1:
ADD r5,r5,r5 # left shift logical r5
+ BGEID r5,$LaDIV1 #
ADDIK r29,r29,-1
- BGEI r5,$LaDIV1 #
$LaDIV2:
ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
ADDC r3,r3,r3 # Move that bit into the Mod register
BRI $LaDIV2 # Div2
$LaLOOP_END:
BGEI r28,$LaRETURN_HERE
+ BRId $LaRETURN_HERE
rsubi r3,r3,0 # Negate the result
- BRI $LaRETURN_HERE
$LaDiv_By_Zero:
$LaResult_Is_Zero:
or r3,r0,r0 # set result to 0 [Both mod as well as div are 0]
lwi r29,r1,4
lwi r30,r1,8
lwi r31,r1,12
+ rtsd r15,4
addik r1,r1,16
- rts r15,4
.end __modsi3
.size __modsi3, . - __modsi3