update copyrights in config dir.
[official-gcc.git] / gcc / config / sh / lib1funcs.asm
blob4db8ddc6c43e5372c49a07a01018af21cf9f7a67
1 /* Copyright (C) 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
3 This file is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
8 In addition to the permissions in the GNU General Public License, the
9 Free Software Foundation gives you unlimited permission to link the
10 compiled version of this file with other programs, and to distribute
11 those programs without any restriction coming from the use of this
12 file. (The General Public License restrictions do apply in other
13 respects; for example, they cover modification of the file, and
14 distribution when not linked into another program.)
16 This file is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; see the file COPYING. If not, write to
23 the Free Software Foundation, 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. */
26 /* As a special exception, if you link this library with other files,
27 some of which are compiled with GCC, to produce an executable,
28 this library does not by itself cause the resulting executable
29 to be covered by the GNU General Public License.
30 This exception does not however invalidate any other reasons why
31 the executable file might be covered by the GNU General Public License. */
34 !! libgcc1 routines for the Hitachi SH cpu.
35 !! Contributed by Steve Chamberlain.
36 !! sac@cygnus.com
38 !! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
39 !! recoded in assembly by Toshiyasu Morita
40 !! tm@netcom.com
42 /* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
43 ELF local label prefixes by J"orn Rennecke
44 amylaar@cygnus.com */
46 #ifdef __ELF__
47 #define LOCAL(X) .L_##X
48 #else
49 #define LOCAL(X) L_##X
50 #endif
52 #ifdef L_ashiftrt
53 .global ___ashiftrt_r4_0
54 .global ___ashiftrt_r4_1
55 .global ___ashiftrt_r4_2
56 .global ___ashiftrt_r4_3
57 .global ___ashiftrt_r4_4
58 .global ___ashiftrt_r4_5
59 .global ___ashiftrt_r4_6
60 .global ___ashiftrt_r4_7
61 .global ___ashiftrt_r4_8
62 .global ___ashiftrt_r4_9
63 .global ___ashiftrt_r4_10
64 .global ___ashiftrt_r4_11
65 .global ___ashiftrt_r4_12
66 .global ___ashiftrt_r4_13
67 .global ___ashiftrt_r4_14
68 .global ___ashiftrt_r4_15
69 .global ___ashiftrt_r4_16
70 .global ___ashiftrt_r4_17
71 .global ___ashiftrt_r4_18
72 .global ___ashiftrt_r4_19
73 .global ___ashiftrt_r4_20
74 .global ___ashiftrt_r4_21
75 .global ___ashiftrt_r4_22
76 .global ___ashiftrt_r4_23
77 .global ___ashiftrt_r4_24
78 .global ___ashiftrt_r4_25
79 .global ___ashiftrt_r4_26
80 .global ___ashiftrt_r4_27
81 .global ___ashiftrt_r4_28
82 .global ___ashiftrt_r4_29
83 .global ___ashiftrt_r4_30
84 .global ___ashiftrt_r4_31
85 .global ___ashiftrt_r4_32
87 .align 1
88 ___ashiftrt_r4_32:
89 ___ashiftrt_r4_31:
90 rotcl r4
91 rts
92 subc r4,r4
94 ___ashiftrt_r4_30:
95 shar r4
96 ___ashiftrt_r4_29:
97 shar r4
98 ___ashiftrt_r4_28:
99 shar r4
100 ___ashiftrt_r4_27:
101 shar r4
102 ___ashiftrt_r4_26:
103 shar r4
104 ___ashiftrt_r4_25:
105 shar r4
106 ___ashiftrt_r4_24:
107 shlr16 r4
108 shlr8 r4
110 exts.b r4,r4
112 ___ashiftrt_r4_23:
113 shar r4
114 ___ashiftrt_r4_22:
115 shar r4
116 ___ashiftrt_r4_21:
117 shar r4
118 ___ashiftrt_r4_20:
119 shar r4
120 ___ashiftrt_r4_19:
121 shar r4
122 ___ashiftrt_r4_18:
123 shar r4
124 ___ashiftrt_r4_17:
125 shar r4
126 ___ashiftrt_r4_16:
127 shlr16 r4
129 exts.w r4,r4
131 ___ashiftrt_r4_15:
132 shar r4
133 ___ashiftrt_r4_14:
134 shar r4
135 ___ashiftrt_r4_13:
136 shar r4
137 ___ashiftrt_r4_12:
138 shar r4
139 ___ashiftrt_r4_11:
140 shar r4
141 ___ashiftrt_r4_10:
142 shar r4
143 ___ashiftrt_r4_9:
144 shar r4
145 ___ashiftrt_r4_8:
146 shar r4
147 ___ashiftrt_r4_7:
148 shar r4
149 ___ashiftrt_r4_6:
150 shar r4
151 ___ashiftrt_r4_5:
152 shar r4
153 ___ashiftrt_r4_4:
154 shar r4
155 ___ashiftrt_r4_3:
156 shar r4
157 ___ashiftrt_r4_2:
158 shar r4
159 ___ashiftrt_r4_1:
161 shar r4
163 ___ashiftrt_r4_0:
166 #endif
168 #ifdef L_ashiftrt_n
171 ! ___ashrsi3
173 ! Entry:
175 ! r4: Value to shift
176 ! r5: Shifts
178 ! Exit:
180 ! r0: Result
182 ! Destroys:
184 ! (none)
187 .global ___ashrsi3
188 .align 2
189 ___ashrsi3:
190 mov #31,r0
191 and r0,r5
192 mova LOCAL(ashrsi3_table),r0
193 mov.b @(r0,r5),r5
194 #ifdef __sh1__
195 add r5,r0
196 jmp @r0
197 #else
198 braf r5
199 #endif
200 mov r4,r0
202 .align 2
203 LOCAL(ashrsi3_table):
204 .byte LOCAL(ashrsi3_0)-LOCAL(ashrsi3_table)
205 .byte LOCAL(ashrsi3_1)-LOCAL(ashrsi3_table)
206 .byte LOCAL(ashrsi3_2)-LOCAL(ashrsi3_table)
207 .byte LOCAL(ashrsi3_3)-LOCAL(ashrsi3_table)
208 .byte LOCAL(ashrsi3_4)-LOCAL(ashrsi3_table)
209 .byte LOCAL(ashrsi3_5)-LOCAL(ashrsi3_table)
210 .byte LOCAL(ashrsi3_6)-LOCAL(ashrsi3_table)
211 .byte LOCAL(ashrsi3_7)-LOCAL(ashrsi3_table)
212 .byte LOCAL(ashrsi3_8)-LOCAL(ashrsi3_table)
213 .byte LOCAL(ashrsi3_9)-LOCAL(ashrsi3_table)
214 .byte LOCAL(ashrsi3_10)-LOCAL(ashrsi3_table)
215 .byte LOCAL(ashrsi3_11)-LOCAL(ashrsi3_table)
216 .byte LOCAL(ashrsi3_12)-LOCAL(ashrsi3_table)
217 .byte LOCAL(ashrsi3_13)-LOCAL(ashrsi3_table)
218 .byte LOCAL(ashrsi3_14)-LOCAL(ashrsi3_table)
219 .byte LOCAL(ashrsi3_15)-LOCAL(ashrsi3_table)
220 .byte LOCAL(ashrsi3_16)-LOCAL(ashrsi3_table)
221 .byte LOCAL(ashrsi3_17)-LOCAL(ashrsi3_table)
222 .byte LOCAL(ashrsi3_18)-LOCAL(ashrsi3_table)
223 .byte LOCAL(ashrsi3_19)-LOCAL(ashrsi3_table)
224 .byte LOCAL(ashrsi3_20)-LOCAL(ashrsi3_table)
225 .byte LOCAL(ashrsi3_21)-LOCAL(ashrsi3_table)
226 .byte LOCAL(ashrsi3_22)-LOCAL(ashrsi3_table)
227 .byte LOCAL(ashrsi3_23)-LOCAL(ashrsi3_table)
228 .byte LOCAL(ashrsi3_24)-LOCAL(ashrsi3_table)
229 .byte LOCAL(ashrsi3_25)-LOCAL(ashrsi3_table)
230 .byte LOCAL(ashrsi3_26)-LOCAL(ashrsi3_table)
231 .byte LOCAL(ashrsi3_27)-LOCAL(ashrsi3_table)
232 .byte LOCAL(ashrsi3_28)-LOCAL(ashrsi3_table)
233 .byte LOCAL(ashrsi3_29)-LOCAL(ashrsi3_table)
234 .byte LOCAL(ashrsi3_30)-LOCAL(ashrsi3_table)
235 .byte LOCAL(ashrsi3_31)-LOCAL(ashrsi3_table)
237 LOCAL(ashrsi3_31):
238 rotcl r0
240 subc r0,r0
242 LOCAL(ashrsi3_30):
243 shar r0
244 LOCAL(ashrsi3_29):
245 shar r0
246 LOCAL(ashrsi3_28):
247 shar r0
248 LOCAL(ashrsi3_27):
249 shar r0
250 LOCAL(ashrsi3_26):
251 shar r0
252 LOCAL(ashrsi3_25):
253 shar r0
254 LOCAL(ashrsi3_24):
255 shlr16 r0
256 shlr8 r0
258 exts.b r0,r0
260 LOCAL(ashrsi3_23):
261 shar r0
262 LOCAL(ashrsi3_22):
263 shar r0
264 LOCAL(ashrsi3_21):
265 shar r0
266 LOCAL(ashrsi3_20):
267 shar r0
268 LOCAL(ashrsi3_19):
269 shar r0
270 LOCAL(ashrsi3_18):
271 shar r0
272 LOCAL(ashrsi3_17):
273 shar r0
274 LOCAL(ashrsi3_16):
275 shlr16 r0
277 exts.w r0,r0
279 LOCAL(ashrsi3_15):
280 shar r0
281 LOCAL(ashrsi3_14):
282 shar r0
283 LOCAL(ashrsi3_13):
284 shar r0
285 LOCAL(ashrsi3_12):
286 shar r0
287 LOCAL(ashrsi3_11):
288 shar r0
289 LOCAL(ashrsi3_10):
290 shar r0
291 LOCAL(ashrsi3_9):
292 shar r0
293 LOCAL(ashrsi3_8):
294 shar r0
295 LOCAL(ashrsi3_7):
296 shar r0
297 LOCAL(ashrsi3_6):
298 shar r0
299 LOCAL(ashrsi3_5):
300 shar r0
301 LOCAL(ashrsi3_4):
302 shar r0
303 LOCAL(ashrsi3_3):
304 shar r0
305 LOCAL(ashrsi3_2):
306 shar r0
307 LOCAL(ashrsi3_1):
309 shar r0
311 LOCAL(ashrsi3_0):
315 #endif
317 #ifdef L_ashiftlt
320 ! ___ashlsi3
322 ! Entry:
324 ! r4: Value to shift
325 ! r5: Shifts
327 ! Exit:
329 ! r0: Result
331 ! Destroys:
333 ! (none)
335 .global ___ashlsi3
336 .align 2
337 ___ashlsi3:
338 mov #31,r0
339 and r0,r5
340 mova LOCAL(ashlsi3_table),r0
341 mov.b @(r0,r5),r5
342 #ifdef __sh1__
343 add r5,r0
344 jmp @r0
345 #else
346 braf r5
347 #endif
348 mov r4,r0
350 .align 2
351 LOCAL(ashlsi3_table):
352 .byte LOCAL(ashlsi3_0)-LOCAL(ashlsi3_table)
353 .byte LOCAL(ashlsi3_1)-LOCAL(ashlsi3_table)
354 .byte LOCAL(ashlsi3_2)-LOCAL(ashlsi3_table)
355 .byte LOCAL(ashlsi3_3)-LOCAL(ashlsi3_table)
356 .byte LOCAL(ashlsi3_4)-LOCAL(ashlsi3_table)
357 .byte LOCAL(ashlsi3_5)-LOCAL(ashlsi3_table)
358 .byte LOCAL(ashlsi3_6)-LOCAL(ashlsi3_table)
359 .byte LOCAL(ashlsi3_7)-LOCAL(ashlsi3_table)
360 .byte LOCAL(ashlsi3_8)-LOCAL(ashlsi3_table)
361 .byte LOCAL(ashlsi3_9)-LOCAL(ashlsi3_table)
362 .byte LOCAL(ashlsi3_10)-LOCAL(ashlsi3_table)
363 .byte LOCAL(ashlsi3_11)-LOCAL(ashlsi3_table)
364 .byte LOCAL(ashlsi3_12)-LOCAL(ashlsi3_table)
365 .byte LOCAL(ashlsi3_13)-LOCAL(ashlsi3_table)
366 .byte LOCAL(ashlsi3_14)-LOCAL(ashlsi3_table)
367 .byte LOCAL(ashlsi3_15)-LOCAL(ashlsi3_table)
368 .byte LOCAL(ashlsi3_16)-LOCAL(ashlsi3_table)
369 .byte LOCAL(ashlsi3_17)-LOCAL(ashlsi3_table)
370 .byte LOCAL(ashlsi3_18)-LOCAL(ashlsi3_table)
371 .byte LOCAL(ashlsi3_19)-LOCAL(ashlsi3_table)
372 .byte LOCAL(ashlsi3_20)-LOCAL(ashlsi3_table)
373 .byte LOCAL(ashlsi3_21)-LOCAL(ashlsi3_table)
374 .byte LOCAL(ashlsi3_22)-LOCAL(ashlsi3_table)
375 .byte LOCAL(ashlsi3_23)-LOCAL(ashlsi3_table)
376 .byte LOCAL(ashlsi3_24)-LOCAL(ashlsi3_table)
377 .byte LOCAL(ashlsi3_25)-LOCAL(ashlsi3_table)
378 .byte LOCAL(ashlsi3_26)-LOCAL(ashlsi3_table)
379 .byte LOCAL(ashlsi3_27)-LOCAL(ashlsi3_table)
380 .byte LOCAL(ashlsi3_28)-LOCAL(ashlsi3_table)
381 .byte LOCAL(ashlsi3_29)-LOCAL(ashlsi3_table)
382 .byte LOCAL(ashlsi3_30)-LOCAL(ashlsi3_table)
383 .byte LOCAL(ashlsi3_31)-LOCAL(ashlsi3_table)
385 LOCAL(ashlsi3_6):
386 shll2 r0
387 LOCAL(ashlsi3_4):
388 shll2 r0
389 LOCAL(ashlsi3_2):
391 shll2 r0
393 LOCAL(ashlsi3_7):
394 shll2 r0
395 LOCAL(ashlsi3_5):
396 shll2 r0
397 LOCAL(ashlsi3_3):
398 shll2 r0
399 LOCAL(ashlsi3_1):
401 shll r0
403 LOCAL(ashlsi3_14):
404 shll2 r0
405 LOCAL(ashlsi3_12):
406 shll2 r0
407 LOCAL(ashlsi3_10):
408 shll2 r0
409 LOCAL(ashlsi3_8):
411 shll8 r0
413 LOCAL(ashlsi3_15):
414 shll2 r0
415 LOCAL(ashlsi3_13):
416 shll2 r0
417 LOCAL(ashlsi3_11):
418 shll2 r0
419 LOCAL(ashlsi3_9):
420 shll8 r0
422 shll r0
424 LOCAL(ashlsi3_22):
425 shll2 r0
426 LOCAL(ashlsi3_20):
427 shll2 r0
428 LOCAL(ashlsi3_18):
429 shll2 r0
430 LOCAL(ashlsi3_16):
432 shll16 r0
434 LOCAL(ashlsi3_23):
435 shll2 r0
436 LOCAL(ashlsi3_21):
437 shll2 r0
438 LOCAL(ashlsi3_19):
439 shll2 r0
440 LOCAL(ashlsi3_17):
441 shll16 r0
443 shll r0
445 LOCAL(ashlsi3_30):
446 shll2 r0
447 LOCAL(ashlsi3_28):
448 shll2 r0
449 LOCAL(ashlsi3_26):
450 shll2 r0
451 LOCAL(ashlsi3_24):
452 shll16 r0
454 shll8 r0
456 LOCAL(ashlsi3_31):
457 shll2 r0
458 LOCAL(ashlsi3_29):
459 shll2 r0
460 LOCAL(ashlsi3_27):
461 shll2 r0
462 LOCAL(ashlsi3_25):
463 shll16 r0
464 shll8 r0
466 shll r0
468 LOCAL(ashlsi3_0):
472 #endif
474 #ifdef L_lshiftrt
477 ! ___lshrsi3
479 ! Entry:
481 ! r4: Value to shift
482 ! r5: Shifts
484 ! Exit:
486 ! r0: Result
488 ! Destroys:
490 ! (none)
492 .global ___lshrsi3
493 .align 2
494 ___lshrsi3:
495 mov #31,r0
496 and r0,r5
497 mova LOCAL(lshrsi3_table),r0
498 mov.b @(r0,r5),r5
499 #ifdef __sh1__
500 add r5,r0
501 jmp @r0
502 #else
503 braf r5
504 #endif
505 mov r4,r0
507 .align 2
508 LOCAL(lshrsi3_table):
509 .byte LOCAL(lshrsi3_0)-LOCAL(lshrsi3_table)
510 .byte LOCAL(lshrsi3_1)-LOCAL(lshrsi3_table)
511 .byte LOCAL(lshrsi3_2)-LOCAL(lshrsi3_table)
512 .byte LOCAL(lshrsi3_3)-LOCAL(lshrsi3_table)
513 .byte LOCAL(lshrsi3_4)-LOCAL(lshrsi3_table)
514 .byte LOCAL(lshrsi3_5)-LOCAL(lshrsi3_table)
515 .byte LOCAL(lshrsi3_6)-LOCAL(lshrsi3_table)
516 .byte LOCAL(lshrsi3_7)-LOCAL(lshrsi3_table)
517 .byte LOCAL(lshrsi3_8)-LOCAL(lshrsi3_table)
518 .byte LOCAL(lshrsi3_9)-LOCAL(lshrsi3_table)
519 .byte LOCAL(lshrsi3_10)-LOCAL(lshrsi3_table)
520 .byte LOCAL(lshrsi3_11)-LOCAL(lshrsi3_table)
521 .byte LOCAL(lshrsi3_12)-LOCAL(lshrsi3_table)
522 .byte LOCAL(lshrsi3_13)-LOCAL(lshrsi3_table)
523 .byte LOCAL(lshrsi3_14)-LOCAL(lshrsi3_table)
524 .byte LOCAL(lshrsi3_15)-LOCAL(lshrsi3_table)
525 .byte LOCAL(lshrsi3_16)-LOCAL(lshrsi3_table)
526 .byte LOCAL(lshrsi3_17)-LOCAL(lshrsi3_table)
527 .byte LOCAL(lshrsi3_18)-LOCAL(lshrsi3_table)
528 .byte LOCAL(lshrsi3_19)-LOCAL(lshrsi3_table)
529 .byte LOCAL(lshrsi3_20)-LOCAL(lshrsi3_table)
530 .byte LOCAL(lshrsi3_21)-LOCAL(lshrsi3_table)
531 .byte LOCAL(lshrsi3_22)-LOCAL(lshrsi3_table)
532 .byte LOCAL(lshrsi3_23)-LOCAL(lshrsi3_table)
533 .byte LOCAL(lshrsi3_24)-LOCAL(lshrsi3_table)
534 .byte LOCAL(lshrsi3_25)-LOCAL(lshrsi3_table)
535 .byte LOCAL(lshrsi3_26)-LOCAL(lshrsi3_table)
536 .byte LOCAL(lshrsi3_27)-LOCAL(lshrsi3_table)
537 .byte LOCAL(lshrsi3_28)-LOCAL(lshrsi3_table)
538 .byte LOCAL(lshrsi3_29)-LOCAL(lshrsi3_table)
539 .byte LOCAL(lshrsi3_30)-LOCAL(lshrsi3_table)
540 .byte LOCAL(lshrsi3_31)-LOCAL(lshrsi3_table)
542 LOCAL(lshrsi3_6):
543 shlr2 r0
544 LOCAL(lshrsi3_4):
545 shlr2 r0
546 LOCAL(lshrsi3_2):
548 shlr2 r0
550 LOCAL(lshrsi3_7):
551 shlr2 r0
552 LOCAL(lshrsi3_5):
553 shlr2 r0
554 LOCAL(lshrsi3_3):
555 shlr2 r0
556 LOCAL(lshrsi3_1):
558 shlr r0
560 LOCAL(lshrsi3_14):
561 shlr2 r0
562 LOCAL(lshrsi3_12):
563 shlr2 r0
564 LOCAL(lshrsi3_10):
565 shlr2 r0
566 LOCAL(lshrsi3_8):
568 shlr8 r0
570 LOCAL(lshrsi3_15):
571 shlr2 r0
572 LOCAL(lshrsi3_13):
573 shlr2 r0
574 LOCAL(lshrsi3_11):
575 shlr2 r0
576 LOCAL(lshrsi3_9):
577 shlr8 r0
579 shlr r0
581 LOCAL(lshrsi3_22):
582 shlr2 r0
583 LOCAL(lshrsi3_20):
584 shlr2 r0
585 LOCAL(lshrsi3_18):
586 shlr2 r0
587 LOCAL(lshrsi3_16):
589 shlr16 r0
591 LOCAL(lshrsi3_23):
592 shlr2 r0
593 LOCAL(lshrsi3_21):
594 shlr2 r0
595 LOCAL(lshrsi3_19):
596 shlr2 r0
597 LOCAL(lshrsi3_17):
598 shlr16 r0
600 shlr r0
602 LOCAL(lshrsi3_30):
603 shlr2 r0
604 LOCAL(lshrsi3_28):
605 shlr2 r0
606 LOCAL(lshrsi3_26):
607 shlr2 r0
608 LOCAL(lshrsi3_24):
609 shlr16 r0
611 shlr8 r0
613 LOCAL(lshrsi3_31):
614 shlr2 r0
615 LOCAL(lshrsi3_29):
616 shlr2 r0
617 LOCAL(lshrsi3_27):
618 shlr2 r0
619 LOCAL(lshrsi3_25):
620 shlr16 r0
621 shlr8 r0
623 shlr r0
625 LOCAL(lshrsi3_0):
629 #endif
631 #ifdef L_movstr
632 .text
633 ! done all the large groups, do the remainder
635 ! jump to movstr+
636 done:
637 add #64,r5
638 mova ___movstrSI0,r0
639 shll2 r6
640 add r6,r0
641 jmp @r0
642 add #64,r4
643 .align 4
644 .global ___movstrSI64
645 ___movstrSI64:
646 mov.l @(60,r5),r0
647 mov.l r0,@(60,r4)
648 .global ___movstrSI60
649 ___movstrSI60:
650 mov.l @(56,r5),r0
651 mov.l r0,@(56,r4)
652 .global ___movstrSI56
653 ___movstrSI56:
654 mov.l @(52,r5),r0
655 mov.l r0,@(52,r4)
656 .global ___movstrSI52
657 ___movstrSI52:
658 mov.l @(48,r5),r0
659 mov.l r0,@(48,r4)
660 .global ___movstrSI48
661 ___movstrSI48:
662 mov.l @(44,r5),r0
663 mov.l r0,@(44,r4)
664 .global ___movstrSI44
665 ___movstrSI44:
666 mov.l @(40,r5),r0
667 mov.l r0,@(40,r4)
668 .global ___movstrSI40
669 ___movstrSI40:
670 mov.l @(36,r5),r0
671 mov.l r0,@(36,r4)
672 .global ___movstrSI36
673 ___movstrSI36:
674 mov.l @(32,r5),r0
675 mov.l r0,@(32,r4)
676 .global ___movstrSI32
677 ___movstrSI32:
678 mov.l @(28,r5),r0
679 mov.l r0,@(28,r4)
680 .global ___movstrSI28
681 ___movstrSI28:
682 mov.l @(24,r5),r0
683 mov.l r0,@(24,r4)
684 .global ___movstrSI24
685 ___movstrSI24:
686 mov.l @(20,r5),r0
687 mov.l r0,@(20,r4)
688 .global ___movstrSI20
689 ___movstrSI20:
690 mov.l @(16,r5),r0
691 mov.l r0,@(16,r4)
692 .global ___movstrSI16
693 ___movstrSI16:
694 mov.l @(12,r5),r0
695 mov.l r0,@(12,r4)
696 .global ___movstrSI12
697 ___movstrSI12:
698 mov.l @(8,r5),r0
699 mov.l r0,@(8,r4)
700 .global ___movstrSI8
701 ___movstrSI8:
702 mov.l @(4,r5),r0
703 mov.l r0,@(4,r4)
704 .global ___movstrSI4
705 ___movstrSI4:
706 mov.l @(0,r5),r0
707 mov.l r0,@(0,r4)
708 ___movstrSI0:
712 .align 4
714 .global ___movstr
715 ___movstr:
716 mov.l @(60,r5),r0
717 mov.l r0,@(60,r4)
719 mov.l @(56,r5),r0
720 mov.l r0,@(56,r4)
722 mov.l @(52,r5),r0
723 mov.l r0,@(52,r4)
725 mov.l @(48,r5),r0
726 mov.l r0,@(48,r4)
728 mov.l @(44,r5),r0
729 mov.l r0,@(44,r4)
731 mov.l @(40,r5),r0
732 mov.l r0,@(40,r4)
734 mov.l @(36,r5),r0
735 mov.l r0,@(36,r4)
737 mov.l @(32,r5),r0
738 mov.l r0,@(32,r4)
740 mov.l @(28,r5),r0
741 mov.l r0,@(28,r4)
743 mov.l @(24,r5),r0
744 mov.l r0,@(24,r4)
746 mov.l @(20,r5),r0
747 mov.l r0,@(20,r4)
749 mov.l @(16,r5),r0
750 mov.l r0,@(16,r4)
752 mov.l @(12,r5),r0
753 mov.l r0,@(12,r4)
755 mov.l @(8,r5),r0
756 mov.l r0,@(8,r4)
758 mov.l @(4,r5),r0
759 mov.l r0,@(4,r4)
761 mov.l @(0,r5),r0
762 mov.l r0,@(0,r4)
764 add #-16,r6
765 cmp/pl r6
766 bf done
768 add #64,r5
769 bra ___movstr
770 add #64,r4
771 #endif
773 #ifdef L_movstr_i4
774 #if defined(__SH4__) || defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
775 .text
776 .global ___movstr_i4_even
777 .global ___movstr_i4_odd
778 .global ___movstrSI12_i4
780 .p2align 5
781 L_movstr_2mod4_end:
782 mov.l r0,@(16,r4)
784 mov.l r1,@(20,r4)
786 .p2align 2
788 ___movstr_i4_odd:
789 mov.l @r5+,r1
790 add #-4,r4
791 mov.l @r5+,r2
792 mov.l @r5+,r3
793 mov.l r1,@(4,r4)
794 mov.l r2,@(8,r4)
796 L_movstr_loop:
797 mov.l r3,@(12,r4)
798 dt r6
799 mov.l @r5+,r0
800 bt/s L_movstr_2mod4_end
801 mov.l @r5+,r1
802 add #16,r4
803 L_movstr_start_even:
804 mov.l @r5+,r2
805 mov.l @r5+,r3
806 mov.l r0,@r4
807 dt r6
808 mov.l r1,@(4,r4)
809 bf/s L_movstr_loop
810 mov.l r2,@(8,r4)
812 mov.l r3,@(12,r4)
814 ___movstr_i4_even:
815 mov.l @r5+,r0
816 bra L_movstr_start_even
817 mov.l @r5+,r1
819 .p2align 4
820 ___movstrSI12_i4:
821 mov.l @r5,r0
822 mov.l @(4,r5),r1
823 mov.l @(8,r5),r2
824 mov.l r0,@r4
825 mov.l r1,@(4,r4)
827 mov.l r2,@(8,r4)
828 #endif /* ! __SH4__ */
829 #endif
831 #ifdef L_mulsi3
834 .global ___mulsi3
836 ! r4 = aabb
837 ! r5 = ccdd
838 ! r0 = aabb*ccdd via partial products
840 ! if aa == 0 and cc = 0
841 ! r0 = bb*dd
843 ! else
844 ! aa = bb*dd + (aa*dd*65536) + (cc*bb*65536)
847 ___mulsi3:
848 mulu r4,r5 ! multiply the lsws macl=bb*dd
849 mov r5,r3 ! r3 = ccdd
850 swap.w r4,r2 ! r2 = bbaa
851 xtrct r2,r3 ! r3 = aacc
852 tst r3,r3 ! msws zero ?
853 bf hiset
854 rts ! yes - then we have the answer
855 sts macl,r0
857 hiset: sts macl,r0 ! r0 = bb*dd
858 mulu r2,r5 ! brewing macl = aa*dd
859 sts macl,r1
860 mulu r3,r4 ! brewing macl = cc*bb
861 sts macl,r2
862 add r1,r2
863 shll16 r2
865 add r2,r0
868 #endif
869 #ifdef L_sdivsi3_i4
870 .title "SH DIVIDE"
871 !! 4 byte integer Divide code for the Hitachi SH
872 #ifdef __SH4__
873 !! args in r4 and r5, result in fpul, clobber dr0, dr2
875 .global ___sdivsi3_i4
876 ___sdivsi3_i4:
877 lds r4,fpul
878 float fpul,dr0
879 lds r5,fpul
880 float fpul,dr2
881 fdiv dr2,dr0
883 ftrc dr0,fpul
885 #elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
886 !! args in r4 and r5, result in fpul, clobber r2, dr0, dr2
888 .global ___sdivsi3_i4
889 ___sdivsi3_i4:
890 sts.l fpscr,@-r15
891 mov #8,r2
892 swap.w r2,r2
893 lds r2,fpscr
894 lds r4,fpul
895 float fpul,dr0
896 lds r5,fpul
897 float fpul,dr2
898 fdiv dr2,dr0
899 ftrc dr0,fpul
901 lds.l @r15+,fpscr
903 #endif /* ! __SH4__ */
904 #endif
906 #ifdef L_sdivsi3
907 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
908 sh3e code. */
909 #if ! defined(__SH4__) && ! defined (__SH4_SINGLE__)
911 !! Steve Chamberlain
912 !! sac@cygnus.com
916 !! args in r4 and r5, result in r0 clobber r1,r2,r3
918 .global ___sdivsi3
919 ___sdivsi3:
920 mov r4,r1
921 mov r5,r0
923 tst r0,r0
924 bt div0
925 mov #0,r2
926 div0s r2,r1
927 subc r3,r3
928 subc r2,r1
929 div0s r0,r3
930 rotcl r1
931 div1 r0,r3
932 rotcl r1
933 div1 r0,r3
934 rotcl r1
935 div1 r0,r3
936 rotcl r1
937 div1 r0,r3
938 rotcl r1
939 div1 r0,r3
940 rotcl r1
941 div1 r0,r3
942 rotcl r1
943 div1 r0,r3
944 rotcl r1
945 div1 r0,r3
946 rotcl r1
947 div1 r0,r3
948 rotcl r1
949 div1 r0,r3
950 rotcl r1
951 div1 r0,r3
952 rotcl r1
953 div1 r0,r3
954 rotcl r1
955 div1 r0,r3
956 rotcl r1
957 div1 r0,r3
958 rotcl r1
959 div1 r0,r3
960 rotcl r1
961 div1 r0,r3
962 rotcl r1
963 div1 r0,r3
964 rotcl r1
965 div1 r0,r3
966 rotcl r1
967 div1 r0,r3
968 rotcl r1
969 div1 r0,r3
970 rotcl r1
971 div1 r0,r3
972 rotcl r1
973 div1 r0,r3
974 rotcl r1
975 div1 r0,r3
976 rotcl r1
977 div1 r0,r3
978 rotcl r1
979 div1 r0,r3
980 rotcl r1
981 div1 r0,r3
982 rotcl r1
983 div1 r0,r3
984 rotcl r1
985 div1 r0,r3
986 rotcl r1
987 div1 r0,r3
988 rotcl r1
989 div1 r0,r3
990 rotcl r1
991 div1 r0,r3
992 rotcl r1
993 div1 r0,r3
994 rotcl r1
995 addc r2,r1
997 mov r1,r0
1000 div0: rts
1001 mov #0,r0
1003 #endif /* ! __SH4__ */
1004 #endif
1005 #ifdef L_udivsi3_i4
1007 .title "SH DIVIDE"
1008 !! 4 byte integer Divide code for the Hitachi SH
1009 #ifdef __SH4__
1010 !! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4
1012 .global ___udivsi3_i4
1013 ___udivsi3_i4:
1014 mov #1,r1
1015 cmp/hi r1,r5
1016 bf trivial
1017 rotr r1
1018 xor r1,r4
1019 lds r4,fpul
1020 mova L1,r0
1021 #ifdef FMOVD_WORKS
1022 fmov.d @r0+,dr4
1023 #else
1024 #ifdef __LITTLE_ENDIAN__
1025 fmov.s @r0+,fr5
1026 fmov.s @r0,fr4
1027 #else
1028 fmov.s @r0+,fr4
1029 fmov.s @r0,fr5
1030 #endif
1031 #endif
1032 float fpul,dr0
1033 xor r1,r5
1034 lds r5,fpul
1035 float fpul,dr2
1036 fadd dr4,dr0
1037 fadd dr4,dr2
1038 fdiv dr2,dr0
1040 ftrc dr0,fpul
1042 trivial:
1044 lds r4,fpul
1046 .align 2
1048 .double 2147483648
1050 #elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
1051 !! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4
1053 .global ___udivsi3_i4
1054 ___udivsi3_i4:
1055 mov #1,r1
1056 cmp/hi r1,r5
1057 bf trivial
1058 sts.l fpscr,@-r15
1059 mova L1,r0
1060 lds.l @r0+,fpscr
1061 rotr r1
1062 xor r1,r4
1063 lds r4,fpul
1064 #ifdef FMOVD_WORKS
1065 fmov.d @r0+,dr4
1066 #else
1067 #ifdef __LITTLE_ENDIAN__
1068 fmov.s @r0+,fr5
1069 fmov.s @r0,fr4
1070 #else
1071 fmov.s @r0+,fr4
1072 fmov.s @r0,fr5
1073 #endif
1074 #endif
1075 float fpul,dr0
1076 xor r1,r5
1077 lds r5,fpul
1078 float fpul,dr2
1079 fadd dr4,dr0
1080 fadd dr4,dr2
1081 fdiv dr2,dr0
1082 ftrc dr0,fpul
1084 lds.l @r15+,fpscr
1086 trivial:
1088 lds r4,fpul
1090 .align 2
1092 #if defined (__LITTLE_ENDIAN__) || ! defined (FMOVD_WORKS)
1093 .long 0x80000
1094 #else
1095 .long 0x180000
1096 #endif
1097 .double 2147483648
1099 #endif /* ! __SH4__ */
1100 #endif
1102 #ifdef L_udivsi3
1103 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
1104 sh3e code. */
1105 #if ! defined(__SH4__) && ! defined (__SH4_SINGLE__)
1107 !! Steve Chamberlain
1108 !! sac@cygnus.com
1112 !! args in r4 and r5, result in r0, clobbers r4, pr, and t bit
1113 .global ___udivsi3
1115 ___udivsi3:
1116 longway:
1117 mov #0,r0
1118 div0u
1119 ! get one bit from the msb of the numerator into the T
1120 ! bit and divide it by whats in r5. Put the answer bit
1121 ! into the T bit so it can come out again at the bottom
1123 rotcl r4 ; div1 r5,r0
1124 rotcl r4 ; div1 r5,r0
1125 rotcl r4 ; div1 r5,r0
1126 rotcl r4 ; div1 r5,r0
1127 rotcl r4 ; div1 r5,r0
1128 rotcl r4 ; div1 r5,r0
1129 rotcl r4 ; div1 r5,r0
1130 rotcl r4 ; div1 r5,r0
1132 rotcl r4 ; div1 r5,r0
1133 rotcl r4 ; div1 r5,r0
1134 rotcl r4 ; div1 r5,r0
1135 rotcl r4 ; div1 r5,r0
1136 rotcl r4 ; div1 r5,r0
1137 rotcl r4 ; div1 r5,r0
1138 rotcl r4 ; div1 r5,r0
1139 rotcl r4 ; div1 r5,r0
1140 shortway:
1141 rotcl r4 ; div1 r5,r0
1142 rotcl r4 ; div1 r5,r0
1143 rotcl r4 ; div1 r5,r0
1144 rotcl r4 ; div1 r5,r0
1145 rotcl r4 ; div1 r5,r0
1146 rotcl r4 ; div1 r5,r0
1147 rotcl r4 ; div1 r5,r0
1148 rotcl r4 ; div1 r5,r0
1150 vshortway:
1151 rotcl r4 ; div1 r5,r0
1152 rotcl r4 ; div1 r5,r0
1153 rotcl r4 ; div1 r5,r0
1154 rotcl r4 ; div1 r5,r0
1155 rotcl r4 ; div1 r5,r0
1156 rotcl r4 ; div1 r5,r0
1157 rotcl r4 ; div1 r5,r0
1158 rotcl r4 ; div1 r5,r0
1159 rotcl r4
1160 ret: rts
1161 mov r4,r0
1163 #endif /* __SH4__ */
1164 #endif
1165 #ifdef L_set_fpscr
1166 #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
1167 .global ___set_fpscr
1168 ___set_fpscr:
1169 lds r4,fpscr
1170 mov.l ___set_fpscr_L1,r1
1171 swap.w r4,r0
1172 or #24,r0
1173 #ifndef FMOVD_WORKS
1174 xor #16,r0
1175 #endif
1176 #if defined(__SH4__)
1177 swap.w r0,r3
1178 mov.l r3,@(4,r1)
1179 #else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */
1180 swap.w r0,r2
1181 mov.l r2,@r1
1182 #endif
1183 #ifndef FMOVD_WORKS
1184 xor #8,r0
1185 #else
1186 xor #24,r0
1187 #endif
1188 #if defined(__SH4__)
1189 swap.w r0,r2
1191 mov.l r2,@r1
1192 #else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */
1193 swap.w r0,r3
1195 mov.l r3,@(4,r1)
1196 #endif
1197 .align 2
1198 ___set_fpscr_L1:
1199 .long ___fpscr_values
1200 #ifdef __ELF__
1201 .comm ___fpscr_values,8,4
1202 #else
1203 .comm ___fpscr_values,8
1204 #endif /* ELF */
1205 #endif /* SH3E / SH4 */
1206 #endif /* L_set_fpscr */