This can make better code because GCC knows exactly which
of the call-used registers (not all of them) are clobbered. */
- .section .text.libgcc, "ax", @progbits
+/* FIXME: At present, there is no SORT directive in the linker
+ script so that we must not assume that different modules
+ in the same input section like .libgcc.text.mul will be
+ located close together. Therefore, we cannot use
+ RCALL/RJMP to call a function like __udivmodhi4 from
+ __divmodhi4 and have to use lengthy XCALL/XJMP even
+ though they are in the same input section and all same
+ input sections together are small enough to reach every
+ location with a RCALL/RJMP instruction. */
.macro mov_l r_dest, r_src
#if defined (__AVR_HAVE_MOVW__)
.endm
\f
+.section .text.libgcc.mul, "ax", @progbits
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/* Note: mulqi3, mulhi3 are open-coded on the enhanced core. */
#if !defined (__AVR_HAVE_MUL__)
clr r23
sbrc r22, 7
dec r22
- rjmp __mulhi3
+ XJMP __mulhi3
ENDF __mulqihi3:
#endif /* defined (L_mulqihi3) */
DEFUN __umulqihi3
clr r25
clr r23
- rjmp __mulhi3
+ XJMP __mulhi3
ENDF __umulqihi3
#endif /* defined (L_umulqihi3) */
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\f
+.section .text.libgcc.div, "ax", @progbits
+
/*******************************************************
Division 8 / 8 => (result + remainder)
*******************************************************/
#define r_cnt r23 /* loop count */
#if defined (L_udivmodqi4)
- .global __udivmodqi4
- .func __udivmodqi4
-__udivmodqi4:
+DEFUN __udivmodqi4
sub r_rem,r_rem ; clear remainder and carry
ldi r_cnt,9 ; init loop counter
rjmp __udivmodqi4_ep ; jump to entry point
com r_arg1 ; complement result
; because C flag was complemented in loop
ret
- .endfunc
+ENDF __udivmodqi4
#endif /* defined (L_udivmodqi4) */
#if defined (L_divmodqi4)
- .global __divmodqi4
- .func __divmodqi4
-__divmodqi4:
+DEFUN __divmodqi4
bst r_arg1,7 ; store sign of dividend
mov __tmp_reg__,r_arg1
eor __tmp_reg__,r_arg2; r0.7 is sign of result
neg r_arg1 ; dividend negative : negate
sbrc r_arg2,7
neg r_arg2 ; divisor negative : negate
- rcall __udivmodqi4 ; do the unsigned div/mod
+ XCALL __udivmodqi4 ; do the unsigned div/mod
brtc __divmodqi4_1
neg r_rem ; correct remainder sign
__divmodqi4_1:
neg r_arg1 ; correct result sign
__divmodqi4_exit:
ret
- .endfunc
+ENDF __divmodqi4
#endif /* defined (L_divmodqi4) */
#undef r_rem
#define r_cnt r21 /* loop count */
#if defined (L_udivmodhi4)
- .global __udivmodhi4
- .func __udivmodhi4
-__udivmodhi4:
+DEFUN __udivmodhi4
sub r_remL,r_remL
sub r_remH,r_remH ; clear remainder and carry
ldi r_cnt,17 ; init loop counter
mov_l r_arg1L, r_remL ; remainder
mov_h r_arg1H, r_remH
ret
- .endfunc
+ENDF __udivmodhi4
#endif /* defined (L_udivmodhi4) */
#if defined (L_divmodhi4)
- .global __divmodhi4
- .func __divmodhi4
-__divmodhi4:
+DEFUN __divmodhi4
.global _div
_div:
bst r_arg1H,7 ; store sign of dividend
rcall __divmodhi4_neg1 ; dividend negative : negate
sbrc r_arg2H,7
rcall __divmodhi4_neg2 ; divisor negative : negate
- rcall __udivmodhi4 ; do the unsigned div/mod
+ XCALL __udivmodhi4 ; do the unsigned div/mod
rcall __divmodhi4_neg1 ; correct remainder sign
tst __tmp_reg__
brpl __divmodhi4_exit
neg r_arg1L ; correct dividend/remainder sign
sbci r_arg1H,0xff
ret
- .endfunc
+ENDF __divmodhi4
#endif /* defined (L_divmodhi4) */
#undef r_remH
#define r_cnt __zero_reg__ /* loop count (0 after the loop!) */
#if defined (L_udivmodsi4)
- .global __udivmodsi4
- .func __udivmodsi4
-__udivmodsi4:
+DEFUN __udivmodsi4
ldi r_remL, 33 ; init loop counter
mov r_cnt, r_remL
sub r_remL,r_remL
mov_l r_arg1HL, r_remHL
mov_h r_arg1HH, r_remHH
ret
- .endfunc
+ENDF __udivmodsi4
#endif /* defined (L_udivmodsi4) */
#if defined (L_divmodsi4)
- .global __divmodsi4
- .func __divmodsi4
-__divmodsi4:
+DEFUN __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
+ XCALL __udivmodsi4 ; do the unsigned div/mod
rcall __divmodsi4_neg1 ; correct remainder sign
rol __tmp_reg__
brcc __divmodsi4_exit
sbci r_arg1HL,0xff
sbci r_arg1HH,0xff
ret
- .endfunc
+ENDF __divmodsi4
#endif /* defined (L_divmodsi4) */
+\f
+.section .text.libgcc.prologue, "ax", @progbits
+
/**********************************
* This is a prologue subroutine
**********************************/
#if defined (L_prologue)
- .global __prologue_saves__
- .func __prologue_saves__
-__prologue_saves__:
+DEFUN __prologue_saves__
push r2
push r3
push r4
ijmp
#endif
-.endfunc
+ENDF __prologue_saves__
#endif /* defined (L_prologue) */
/*
*/
#if defined (L_epilogue)
- .global __epilogue_restores__
- .func __epilogue_restores__
-__epilogue_restores__:
+DEFUN __epilogue_restores__
ldd r2,Y+18
ldd r3,Y+17
ldd r4,Y+16
mov_l r28, r26
mov_h r29, r27
ret
-.endfunc
+ENDF __epilogue_restores__
#endif /* defined (L_epilogue) */
#ifdef L_exit
.section .fini9,"ax",@progbits
- .global _exit
- .func _exit
-_exit:
+DEFUN _exit
.weak exit
exit:
- .endfunc
+ENDF _exit
/* Code from .fini8 ... .fini1 sections inserted by ld script. */
.endfunc
#endif /* defined (L_cleanup) */
+\f
+.section .text.libgcc, "ax", @progbits
+
#ifdef L_tablejump
- .global __tablejump2__
- .func __tablejump2__
-__tablejump2__:
+DEFUN __tablejump2__
lsl r30
rol r31
- .global __tablejump__
-__tablejump__:
+ ;; FALLTHRU
+ENDF __tablejump2__
+
+DEFUN __tablejump__
#if defined (__AVR_HAVE_LPMX__)
lpm __tmp_reg__, Z+
lpm r31, Z
#endif
ret
#endif
- .endfunc
+ENDF __tablejump__
#endif /* defined (L_tablejump) */
#ifdef L_copy_data
.section .init4,"ax",@progbits
- .global __do_copy_data
-__do_copy_data:
+DEFUN __do_copy_data
#if defined(__AVR_HAVE_ELPMX__)
ldi r17, hi8(__data_end)
ldi r26, lo8(__data_start)
cpc r27, r17
brne .L__do_copy_data_loop
#endif /* !defined(__AVR_HAVE_ELPMX__) && !defined(__AVR_HAVE_ELPM__) */
+ENDF __do_copy_data
#endif /* L_copy_data */
/* __do_clear_bss is only necessary if there is anything in .bss section. */
#ifdef L_clear_bss
.section .init4,"ax",@progbits
- .global __do_clear_bss
-__do_clear_bss:
+DEFUN __do_clear_bss
ldi r17, hi8(__bss_end)
ldi r26, lo8(__bss_start)
ldi r27, hi8(__bss_start)
cpi r26, lo8(__bss_end)
cpc r27, r17
brne .do_clear_bss_loop
+ENDF __do_clear_bss
#endif /* L_clear_bss */
/* __do_global_ctors and __do_global_dtors are only necessary
#ifdef L_ctors
.section .init6,"ax",@progbits
- .global __do_global_ctors
+DEFUN __do_global_ctors
#if defined(__AVR_HAVE_RAMPZ__)
-__do_global_ctors:
ldi r17, hi8(__ctors_start)
ldi r28, lo8(__ctors_end)
ldi r29, hi8(__ctors_end)
cpc r16, r24
brne .L__do_global_ctors_loop
#else
-__do_global_ctors:
ldi r17, hi8(__ctors_start)
ldi r28, lo8(__ctors_end)
ldi r29, hi8(__ctors_end)
cpc r29, r17
brne .L__do_global_ctors_loop
#endif /* defined(__AVR_HAVE_RAMPZ__) */
+ENDF __do_global_ctors
#endif /* L_ctors */
#ifdef L_dtors
.section .fini6,"ax",@progbits
- .global __do_global_dtors
+DEFUN __do_global_dtors
#if defined(__AVR_HAVE_RAMPZ__)
-__do_global_dtors:
ldi r17, hi8(__dtors_end)
ldi r28, lo8(__dtors_start)
ldi r29, hi8(__dtors_start)
cpc r16, r24
brne .L__do_global_dtors_loop
#else
-__do_global_dtors:
ldi r17, hi8(__dtors_end)
ldi r28, lo8(__dtors_start)
ldi r29, hi8(__dtors_start)
cpc r29, r17
brne .L__do_global_dtors_loop
#endif /* defined(__AVR_HAVE_RAMPZ__) */
+ENDF __do_global_dtors
#endif /* L_dtors */
+.section .text.libgcc, "ax", @progbits
+
#ifdef L_tablejump_elpm
- .global __tablejump_elpm__
- .func __tablejump_elpm__
-__tablejump_elpm__:
+DEFUN __tablejump_elpm__
#if defined (__AVR_HAVE_ELPM__)
#if defined (__AVR_HAVE_LPMX__)
elpm __tmp_reg__, Z+
ret
#endif
#endif /* defined (__AVR_HAVE_ELPM__) */
- .endfunc
+ENDF __tablejump_elpm__
#endif /* defined (L_tablejump_elpm) */
\f
+.section .text.libgcc.builtins, "ax", @progbits
+
/**********************************
* Find first set Bit (ffs)
**********************************/
ENDF __ashldi3
#endif /* defined (L_ashldi3) */
+\f
+.section .text.libgcc.fmul, "ax", @progbits
/***********************************************************/
;;; Softmul versions of FMUL, FMULS and FMULSU to implement