libgcc.s
来自「gcc3.2.1源代码」· S 代码 · 共 677 行 · 第 1/2 页
S
677 行
eor __tmp_reg__,r_arg2; r0.7 is sign of result sbrc r_arg1,7 neg r_arg1 ; dividend negative : negate sbrc r_arg2,7 neg r_arg2 ; divisor negative : negate rcall __udivmodqi4 ; do the unsigned div/mod brtc __divmodqi4_1 neg r_rem ; correct remainder sign__divmodqi4_1: sbrc __tmp_reg__,7 neg r_arg1 ; correct result sign__divmodqi4_exit: ret .endfunc#endif /* defined (L_divmodqi4) */#undef r_rem#undef r_arg1#undef r_arg2#undef r_cnt /******************************************************* Division 16 / 16 => (result + remainder)*******************************************************/#define r_remL r26 /* remainder Low */#define r_remH r27 /* remainder High *//* return: remainder */#define r_arg1L r24 /* dividend Low */#define r_arg1H r25 /* dividend High *//* return: quotient */#define r_arg2L r22 /* divisor Low */#define r_arg2H r23 /* divisor High */ #define r_cnt r21 /* loop count */#if defined (L_udivmodhi4) .global __udivmodhi4 .func __udivmodhi4__udivmodhi4: sub r_remL,r_remL sub r_remH,r_remH ; clear remainder and carry ldi r_cnt,17 ; init loop counter rjmp __udivmodhi4_ep ; jump to entry point__udivmodhi4_loop: rol r_remL ; shift dividend into remainder rol r_remH cp r_remL,r_arg2L ; compare remainder & divisor cpc r_remH,r_arg2H brcs __udivmodhi4_ep ; remainder < divisor sub r_remL,r_arg2L ; restore remainder sbc r_remH,r_arg2H__udivmodhi4_ep: rol r_arg1L ; shift dividend (with CARRY) rol r_arg1H dec r_cnt ; decrement loop counter brne __udivmodhi4_loop com r_arg1L com r_arg1H; div/mod results to return registers, as for the div() function mov_l r_arg2L, r_arg1L ; quotient mov_h r_arg2H, r_arg1H mov_l r_arg1L, r_remL ; remainder mov_h r_arg1H, r_remH ret .endfunc#endif /* defined (L_udivmodhi4) */#if defined (L_divmodhi4) .global __divmodhi4 .func __divmodhi4__divmodhi4: .global _div_div: bst r_arg1H,7 ; store sign of dividend mov __tmp_reg__,r_arg1H eor __tmp_reg__,r_arg2H ; r0.7 is sign of result rcall __divmodhi4_neg1 ; dividend negative : negate sbrc r_arg2H,7 rcall __divmodhi4_neg2 ; divisor negative : negate rcall __udivmodhi4 ; do the unsigned div/mod rcall __divmodhi4_neg1 ; correct remainder sign tst __tmp_reg__ brpl __divmodhi4_exit__divmodhi4_neg2: com r_arg2H neg r_arg2L ; correct divisor/result sign sbci r_arg2H,0xff__divmodhi4_exit: ret__divmodhi4_neg1: brtc __divmodhi4_exit com r_arg1H neg r_arg1L ; correct dividend/remainder sign sbci r_arg1H,0xff ret .endfunc#endif /* defined (L_divmodhi4) */#undef r_remH #undef r_remL #undef r_arg1H #undef r_arg1L #undef r_arg2H #undef r_arg2L #undef r_cnt /******************************************************* Division 32 / 32 => (result + remainder)*******************************************************/#define r_remHH r31 /* remainder High */#define r_remHL r30#define r_remH r27#define r_remL r26 /* remainder Low *//* return: remainder */#define r_arg1HH r25 /* dividend High */#define r_arg1HL r24#define r_arg1H r23#define r_arg1L r22 /* dividend Low *//* return: quotient */#define r_arg2HH r21 /* divisor High */#define r_arg2HL r20#define r_arg2H r19#define r_arg2L r18 /* divisor Low */ #define r_cnt __zero_reg__ /* loop count (0 after the loop!) */#if defined (L_udivmodsi4) .global __udivmodsi4 .func __udivmodsi4__udivmodsi4: ldi r_remL, 33 ; init loop counter mov r_cnt, r_remL sub r_remL,r_remL sub r_remH,r_remH ; clear remainder and carry mov_l r_remHL, r_remL mov_h r_remHH, r_remH rjmp __udivmodsi4_ep ; jump to entry point__udivmodsi4_loop: rol r_remL ; shift dividend into remainder rol r_remH rol r_remHL rol r_remHH cp r_remL,r_arg2L ; compare remainder & divisor cpc r_remH,r_arg2H cpc r_remHL,r_arg2HL cpc r_remHH,r_arg2HH brcs __udivmodsi4_ep ; remainder <= divisor sub r_remL,r_arg2L ; restore remainder sbc r_remH,r_arg2H sbc r_remHL,r_arg2HL sbc r_remHH,r_arg2HH__udivmodsi4_ep: rol r_arg1L ; shift dividend (with CARRY) rol r_arg1H rol r_arg1HL rol r_arg1HH dec r_cnt ; decrement loop counter brne __udivmodsi4_loop ; __zero_reg__ now restored (r_cnt == 0) com r_arg1L com r_arg1H com r_arg1HL com r_arg1HH; div/mod results to return registers, as for the ldiv() function mov_l r_arg2L, r_arg1L ; quotient mov_h r_arg2H, r_arg1H mov_l r_arg2HL, r_arg1HL mov_h r_arg2HH, r_arg1HH mov_l r_arg1L, r_remL ; remainder mov_h r_arg1H, r_remH mov_l r_arg1HL, r_remHL mov_h r_arg1HH, r_remHH ret .endfunc#endif /* defined (L_udivmodsi4) */#if defined (L_divmodsi4) .global __divmodsi4 .func __divmodsi4__divmodsi4: bst r_arg1HH,7 ; store sign of dividend mov __tmp_reg__,r_arg1HH eor __tmp_reg__,r_arg2HH ; r0.7 is sign of result rcall __divmodsi4_neg1 ; dividend negative : negate sbrc r_arg2HH,7 rcall __divmodsi4_neg2 ; divisor negative : negate rcall __udivmodsi4 ; do the unsigned div/mod rcall __divmodsi4_neg1 ; correct remainder sign rol __tmp_reg__ brcc __divmodsi4_exit__divmodsi4_neg2: com r_arg2HH com r_arg2HL com r_arg2H neg r_arg2L ; correct divisor/quotient sign sbci r_arg2H,0xff sbci r_arg2HL,0xff sbci r_arg2HH,0xff__divmodsi4_exit: ret__divmodsi4_neg1: brtc __divmodsi4_exit com r_arg1HH com r_arg1HL com r_arg1H neg r_arg1L ; correct dividend/remainder sign sbci r_arg1H, 0xff sbci r_arg1HL,0xff sbci r_arg1HH,0xff ret .endfunc#endif /* defined (L_divmodsi4) *//********************************** * This is a prologue subroutine **********************************/#if defined (L_prologue) .global __prologue_saves__ .func __prologue_saves____prologue_saves__: push r2 push r3 push r4 push r5 push r6 push r7 push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 push r16 push r17 push r28 push r29 in r28,__SP_L__ in r29,__SP_H__ sub r28,r26 sbc r29,r27 in __tmp_reg__,__SREG__ cli out __SP_H__,r29 out __SREG__,__tmp_reg__ out __SP_L__,r28 ijmp.endfunc#endif /* defined (L_prologue) *//* * This is an epilogue subroutine */#if defined (L_epilogue) .global __epilogue_restores__ .func __epilogue_restores____epilogue_restores__: ldd r2,Y+18 ldd r3,Y+17 ldd r4,Y+16 ldd r5,Y+15 ldd r6,Y+14 ldd r7,Y+13 ldd r8,Y+12 ldd r9,Y+11 ldd r10,Y+10 ldd r11,Y+9 ldd r12,Y+8 ldd r13,Y+7 ldd r14,Y+6 ldd r15,Y+5 ldd r16,Y+4 ldd r17,Y+3 ldd r26,Y+2 ldd r27,Y+1 add r28,r30 adc r29,__zero_reg__ in __tmp_reg__,__SREG__ cli out __SP_H__,r29 out __SREG__,__tmp_reg__ out __SP_L__,r28 mov_l r28, r26 mov_h r29, r27 ret.endfunc#endif /* defined (L_epilogue) */#ifdef L_exit .weak _exit .func _exit_exit: rjmp _exit.endfunc#endif /* defined (L_exit) */#ifdef L_cleanup .weak _cleanup .func _cleanup_cleanup: ret.endfunc#endif /* defined (L_cleanup) */#ifdef L_tablejump .global __tablejump2__ .func __tablejump2____tablejump2__: lsl r30 rol r31#if defined (__AVR_ENHANCED__) lpm __tmp_reg__, Z+ lpm r31, Z mov r30, __tmp_reg__ ijmp#else lpm push r0 inc r30 ; table is word aligned, no carry to high byte lpm push r0 ret#endif.endfunc#endif /* defined (L_tablejump) */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?