1 /* CYGNUS LOCAL entire file v850/law */
2 /* libgcc1 routines for NEC V850.
3 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 In addition to the permissions in the GNU General Public License, the
13 Free Software Foundation gives you unlimited permission to link the
14 compiled version of this file with other programs, and to distribute
15 those programs without any restriction coming from the use of this
16 file. (The General Public License restrictions do apply in other
17 respects; for example, they cover modification of the file, and
18 distribution when not linked into another program.)
20 This file is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; see the file COPYING. If not, write to
27 the Free Software Foundation, 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. */
30 /* As a special exception, if you link this library with files
31 compiled with GCC to produce an executable, this does not cause
32 the resulting executable to be covered by the GNU General Public License.
33 This exception does not however invalidate any other reasons why
34 the executable file might be covered by the GNU General Public License. */
39 .type ___mulsi3,@function
42 * In order to not deal with negative numbers (mulh is a signed multiply
43 * and we want an unsigned multiply, code the multiplication as a series
44 * of 7 bit multiplies).
46 * int __mulsi3 (unsigned a, unsigned b)
51 * for (i = 0; i < 32; i += 7)
53 * short a_part = a & 0x7f;
57 * for (j = 0; (i+j) < 32; j += 7)
59 * short b_part = b_tmp & 0x7f;
60 * ret += (((int)a_part) * ((int)b_part)) << (i+j);
71 mov 0,r14 /* i = 0, index for multiply a's part */
72 movea lo(31),r0,r16 /* upper bounds for loop */
74 mov r7,r13 /* b_tmp = b */
75 andi 0x7f,r6,r15 /* a_part = (a & 127) */
76 shr 7,r6 /* a >>= 7 */
77 mov r14,r12 /* i+j = i */
79 andi 0x7f,r13,r11 /* b_part = (b_tmp & 127) */
80 mulh r15,r11 /* ((int)a_part) * ((int)b_part) */
81 shr 7,r13 /* b_tmp >>= 7 */
82 shl r12,r11 /* (((int)a_part) * ((int)b_part)) << (i+j) */
83 add r11,r10 /* ret += (((int)a_part) * ((int)b_part)) << (i+j) */
84 add 7,r12 /* i+j += 7 */
85 cmp r16,r12 /* i+j < 32 */
88 add 7,r14 /* i += 7 */
89 cmp r16,r14 /* i < 32 */
92 jmp [r31] /* return */
93 .size __mulsi3,.-__mulsi3
103 movhi hi(-2147483648),r0,r13
130 .size __udivsi3,.-__udivsi3
136 .type ___divsi3,@function
161 .size __divsi3,.-__divsi3
167 .type ___umodsi3,@function
182 .size __umodsi3,.-__umodsi3
183 #endif /* L_umodsi3 */
188 .type ___modsi3,@function
203 .size __modsi3,.-__modsi3
204 #endif /* L_modsi3 */
210 .type __save_r2_r29,@function
211 /* Allocate space and save registers 2, 20 .. 29 on the stack */
212 /* Called via: jalr __save_r2_r29,r10 */
230 .size __save_r2_r29,.-__save_r2_r29
232 /* Restore saved registers, deallocate stack and return to the user */
233 /* Called via: jr __return_r2_r29 */
235 .globl __return_r2_r29
236 .type __return_r2_r29,@function
254 .size __return_r2_r29,.-__return_r2_r29
255 #endif /* L_save_2 */
260 .globl __save_r20_r29
261 .type __save_r20_r29,@function
262 /* Allocate space and save registers 20 .. 29 on the stack */
263 /* Called via: jalr __save_r20_r29,r10 */
280 .size __save_r20_r29,.-__save_r20_r29
282 /* Restore saved registers, deallocate stack and return to the user */
283 /* Called via: jr __return_r20_r29 */
285 .globl __return_r20_r29
286 .type __return_r20_r29,@function
303 .size __return_r20_r29,.-__return_r20_r29
304 #endif /* L_save_20 */
309 .globl __save_r21_r29
310 .type __save_r21_r29,@function
311 /* Allocate space and save registers 21 .. 29 on the stack */
312 /* Called via: jalr __save_r21_r29,r10 */
328 .size __save_r21_r29,.-__save_r21_r29
330 /* Restore saved registers, deallocate stack and return to the user */
331 /* Called via: jr __return_r21_r29 */
333 .globl __return_r21_r29
334 .type __return_r21_r29,@function
350 .size __return_r21_r29,.-__return_r21_r29
351 #endif /* L_save_21 */
356 .globl __save_r22_r29
357 .type __save_r22_r29,@function
358 /* Allocate space and save registers 22 .. 29 on the stack */
359 /* Called via: jalr __save_r22_r29,r10 */
374 .size __save_r22_r29,.-__save_r22_r29
376 /* Restore saved registers, deallocate stack and return to the user */
377 /* Called via: jr __return_r22_r29 */
379 .globl __return_r22_r29
380 .type __return_r22_r29,@function
395 .size __return_r22_r29,.-__return_r22_r29
396 #endif /* L_save_22 */
401 .globl __save_r23_r29
402 .type __save_r23_r29,@function
403 /* Allocate space and save registers 23 .. 29 on the stack */
404 /* Called via: jalr __save_r23_r29,r10 */
418 .size __save_r23_r29,.-__save_r23_r29
420 /* Restore saved registers, deallocate stack and return to the user */
421 /* Called via: jr __return_r23_r29 */
423 .globl __return_r23_r29
424 .type __return_r23_r29,@function
438 .size __return_r23_r29,.-__return_r23_r29
439 #endif /* L_save_23 */
444 .globl __save_r24_r29
445 .type __save_r24_r29,@function
446 /* Allocate space and save registers 24 .. 29 on the stack */
447 /* Called via: jalr __save_r24_r29,r10 */
460 .size __save_r24_r29,.-__save_r24_r29
462 /* Restore saved registers, deallocate stack and return to the user */
463 /* Called via: jr __return_r24_r29 */
465 .globl __return_r24_r29
466 .type __return_r24_r29,@function
479 .size __return_r24_r29,.-__return_r24_r29
480 #endif /* L_save_24 */
485 .globl __save_r25_r29
486 .type __save_r25_r29,@function
487 /* Allocate space and save registers 25 .. 29 on the stack */
488 /* Called via: jalr __save_r25_r29,r10 */
500 .size __save_r25_r29,.-__save_r25_r29
502 /* Restore saved registers, deallocate stack and return to the user */
503 /* Called via: jr __return_r25_r29 */
505 .globl __return_r25_r29
506 .type __return_r25_r29,@function
518 .size __return_r25_r29,.-__return_r25_r29
519 #endif /* L_save_25 */
524 .globl __save_r26_r29
525 .type __save_r26_r29,@function
526 /* Allocate space and save registers 26 .. 29 on the stack */
527 /* Called via: jalr __save_r26_r29,r10 */
538 .size __save_r26_r29,.-__save_r26_r29
540 /* Restore saved registers, deallocate stack and return to the user */
541 /* Called via: jr __return_r26_r29 */
543 .globl __return_r26_r29
544 .type __return_r26_r29,@function
555 .size __return_r26_r29,.-__return_r26_r29
556 #endif /* L_save_26 */
561 .globl __save_r27_r29
562 .type __save_r27_r29,@function
563 /* Allocate space and save registers 27 .. 29 on the stack */
564 /* Called via: jalr __save_r27_r29,r10 */
571 .size __save_r27_r29,.-__save_r27_r29
573 /* Restore saved registers, deallocate stack and return to the user */
574 /* Called via: jr __return_r27_r29 */
576 .globl __return_r27_r29
577 .type __return_r27_r29,@function
584 .size __return_r27_r29,.-__return_r27_r29
585 #endif /* L_save_27 */
590 .globl __save_r28_r29
591 .type __save_r28_r29,@function
592 /* Allocate space and save registers 28,29 on the stack */
593 /* Called via: jalr __save_r28_r29,r10 */
599 .size __save_r28_r29,.-__save_r28_r29
601 /* Restore saved registers, deallocate stack and return to the user */
602 /* Called via: jr __return_r28_r29 */
604 .globl __return_r28_r29
605 .type __return_r28_r29,@function
611 .size __return_r28_r29,.-__return_r28_r29
612 #endif /* L_save_28 */
618 .type __save_r29,@function
619 /* Allocate space and save register 29 on the stack */
620 /* Called via: jalr __save_r29,r10 */
625 .size __save_r29,.-__save_r29
627 /* Restore saved register 29, deallocate stack and return to the user */
628 /* Called via: jr __return_r29 */
631 .type __return_r29,@function
636 .size __return_r29,.-__return_r29
637 #endif /* L_save_28 */
643 .type __save_r2_r31,@function
644 /* Allocate space and save registers 20 .. 29, 31 on the stack */
645 /* Also allocate space for the argument save area */
646 /* Called via: jalr __save_r2_r31,r10 */
665 .size __save_r2_r31,.-__save_r2_r31
667 /* Restore saved registers, deallocate stack and return to the user */
668 /* Called via: jr __return_r20_r31 */
670 .globl __return_r2_r31
671 .type __return_r2_r31,@function
690 .size __return_r2_r31,.-__return_r2_r31
691 #endif /* L_save_2c */
696 .globl __save_r20_r31
697 .type __save_r20_r31,@function
698 /* Allocate space and save registers 20 .. 29, 31 on the stack */
699 /* Also allocate space for the argument save area */
700 /* Called via: jalr __save_r20_r31,r10 */
718 .size __save_r20_r31,.-__save_r20_r31
720 /* Restore saved registers, deallocate stack and return to the user */
721 /* Called via: jr __return_r20_r31 */
723 .globl __return_r20_r31
724 .type __return_r20_r31,@function
742 .size __return_r20_r31,.-__return_r20_r31
743 #endif /* L_save_20c */
748 .globl __save_r21_r31
749 .type __save_r21_r31,@function
750 /* Allocate space and save registers 21 .. 29, 31 on the stack */
751 /* Also allocate space for the argument save area */
752 /* Called via: jalr __save_r21_r31,r10 */
769 .size __save_r21_r31,.-__save_r21_r31
771 /* Restore saved registers, deallocate stack and return to the user */
772 /* Called via: jr __return_r21_r31 */
774 .globl __return_r21_r31
775 .type __return_r21_r31,@function
792 .size __return_r21_r31,.-__return_r21_r31
793 #endif /* L_save_21c */
798 .globl __save_r22_r31
799 .type __save_r22_r31,@function
800 /* Allocate space and save registers 22 .. 29, 31 on the stack */
801 /* Also allocate space for the argument save area */
802 /* Called via: jalr __save_r22_r31,r10 */
818 .size __save_r22_r31,.-__save_r22_r31
820 /* Restore saved registers, deallocate stack and return to the user */
821 /* Called via: jr __return_r22_r31 */
823 .globl __return_r22_r31
824 .type __return_r22_r31,@function
840 .size __return_r22_r31,.-__return_r22_r31
841 #endif /* L_save_22c */
846 .globl __save_r23_r31
847 .type __save_r23_r31,@function
848 /* Allocate space and save registers 23 .. 29, 31 on the stack */
849 /* Also allocate space for the argument save area */
850 /* Called via: jalr __save_r23_r31,r10 */
865 .size __save_r23_r31,.-__save_r23_r31
867 /* Restore saved registers, deallocate stack and return to the user */
868 /* Called via: jr __return_r23_r31 */
870 .globl __return_r23_r31
871 .type __return_r23_r31,@function
886 .size __return_r23_r31,.-__return_r23_r31
887 #endif /* L_save_23c */
892 .globl __save_r24_r31
893 .type __save_r24_r31,@function
894 /* Allocate space and save registers 24 .. 29, 31 on the stack */
895 /* Also allocate space for the argument save area */
896 /* Called via: jalr __save_r24_r31,r10 */
910 .size __save_r24_r31,.-__save_r24_r31
912 /* Restore saved registers, deallocate stack and return to the user */
913 /* Called via: jr __return_r24_r31 */
915 .globl __return_r24_r31
916 .type __return_r24_r31,@function
930 .size __return_r24_r31,.-__return_r24_r31
931 #endif /* L_save_24c */
936 .globl __save_r25_r31
937 .type __save_r25_r31,@function
938 /* Allocate space and save registers 25 .. 29, 31 on the stack */
939 /* Also allocate space for the argument save area */
940 /* Called via: jalr __save_r25_r31,r10 */
953 .size __save_r25_r31,.-__save_r25_r31
955 /* Restore saved registers, deallocate stack and return to the user */
956 /* Called via: jr __return_r25_r31 */
958 .globl __return_r25_r31
959 .type __return_r25_r31,@function
972 .size __return_r25_r31,.-__return_r25_r31
973 #endif /* L_save_25c */
978 .globl __save_r26_r31
979 .type __save_r26_r31,@function
980 /* Allocate space and save registers 26 .. 29, 31 on the stack */
981 /* Also allocate space for the argument save area */
982 /* Called via: jalr __save_r26_r31,r10 */
994 .size __save_r26_r31,.-__save_r26_r31
996 /* Restore saved registers, deallocate stack and return to the user */
997 /* Called via: jr __return_r26_r31 */
999 .globl __return_r26_r31
1000 .type __return_r26_r31,@function
1012 .size __return_r26_r31,.-__return_r26_r31
1013 #endif /* L_save_26c */
1018 .globl __save_r27_r31
1019 .type __save_r27_r31,@function
1020 /* Allocate space and save registers 27 .. 29, 31 on the stack */
1021 /* Also allocate space for the argument save area */
1022 /* Called via: jalr __save_r27_r31,r10 */
1033 .size __save_r27_r31,.-__save_r27_r31
1035 /* Restore saved registers, deallocate stack and return to the user */
1036 /* Called via: jr __return_r27_r31 */
1038 .globl __return_r27_r31
1039 .type __return_r27_r31,@function
1050 .size __return_r27_r31,.-__return_r27_r31
1051 #endif /* L_save_27c */
1056 .globl __save_r28_r31
1057 .type __save_r28_r31,@function
1058 /* Allocate space and save registers 28 .. 29, 31 on the stack */
1059 /* Also allocate space for the argument save area */
1060 /* Called via: jalr __save_r28_r31,r10 */
1067 .size __save_r28_r31,.-__save_r28_r31
1069 /* Restore saved registers, deallocate stack and return to the user */
1070 /* Called via: jr __return_r28_r31 */
1072 .globl __return_r28_r31
1073 .type __return_r28_r31,@function
1080 .size __return_r28_r31,.-__return_r28_r31
1081 #endif /* L_save_28c */
1086 .globl __save_r29_r31
1087 .type __save_r29_r31,@function
1088 /* Allocate space and save registers 29 & 31 on the stack */
1089 /* Also allocate space for the argument save area */
1090 /* Called via: jalr __save_r29_r31,r10 */
1096 .size __save_r29_r31,.-__save_r29_r31
1098 /* Restore saved registers, deallocate stack and return to the user */
1099 /* Called via: jr __return_r29_r31 */
1101 .globl __return_r29_r31
1102 .type __return_r29_r31,@function
1108 .size __return_r29_r31,.-__return_r29_r31
1109 #endif /* L_save_29c */
1115 .type __save_r31,@function
1116 /* Allocate space and save register 31 on the stack */
1117 /* Also allocate space for the argument save area */
1118 /* Called via: jalr __save_r29_r31,r10 */
1123 .size __save_r31,.-__save_r31
1125 /* Restore saved registers, deallocate stack and return to the user */
1126 /* Called via: jr __return_r31 */
1129 .type __return_r31,@function
1134 .size __return_r29_r31,.-__return_r29_r31
1135 #endif /* L_save_31c */
1137 #ifdef L_save_varargs
1141 .type __save_r6_r9,@function
1142 /* Save registers 6 .. 9 on the stack for variable argument functions */
1143 /* Called via: jalr __save_r6_r9,r10 */
1153 .size __save_r6_r9,.-__save_r6_r9
1154 #endif /* L_save_varargs */
1156 #ifdef L_save_interrupt
1159 .globl __save_interrupt
1160 .type __save_interrupt,@function
1161 /* Save registers r1, r5 on stack and load up with expected values */
1162 /* Note, 12 bytes of stack have already been allocated. */
1163 /* Called via: jalr __save_interrupt,r10 */
1168 movhi hi(__ep),r0,ep
1169 movea lo(__ep),ep,ep
1170 movhi hi(__gp),r0,gp
1171 movea lo(__gp),gp,gp
1173 .size __save_interrupt,.-__save_interrupt
1175 /* Restore saved registers, deallocate stack and return from the interrupt */
1176 /* Called via: jr __return_interupt */
1178 .globl __return_interrupt
1179 .type __return_interrupt,@function
1187 .size __return_interrupt,.-__return_interrupt
1188 #endif /* L_save_interrupt */
1190 #ifdef L_save_all_interrupt
1193 .globl __save_all_interrupt
1194 .type __save_all_interrupt,@function
1195 /* Save all registers except for those saved in __save_interrupt */
1196 /* allocate enough stack for all of the registers & 16 bytes of space */
1197 /* Called via: jalr __save_all_interrupt,r10 */
1198 __save_all_interrupt:
1230 .size __save_all_interrupt,.-__save_all_interrupt
1232 .globl __restore_all_interrupt
1233 .type __restore_all_interrupt,@function
1234 /* Restore all registers saved in __save_all_interrupt */
1235 /* & deallocate the stack space */
1236 /* Called via: jalr __restore_all_interrupt,r10 */
1237 __restore_all_interrupt:
1269 .size __restore_all_interrupt,.-__restore_all_interrupt
1270 #endif /* L_save_all_interrupt */
1271 /* END CYGNUS LOCAL */