1/* Copyright (C) 1994, 1995, 1997, 1998 Free Software Foundation, Inc. 2 3This file is free software; you can redistribute it and/or modify it 4under the terms of the GNU General Public License as published by the 5Free Software Foundation; either version 2, or (at your option) any 6later version. 7 8In addition to the permissions in the GNU General Public License, the 9Free Software Foundation gives you unlimited permission to link the 10compiled version of this file with other programs, and to distribute 11those programs without any restriction coming from the use of this 12file. (The General Public License restrictions do apply in other 13respects; for example, they cover modification of the file, and 14distribution when not linked into another program.) 15 16This file is distributed in the hope that it will be useful, but 17WITHOUT ANY WARRANTY; without even the implied warranty of 18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19General Public License for more details. 20 21You should have received a copy of the GNU General Public License 22along with this program; see the file COPYING. If not, write to 23the Free Software Foundation, 59 Temple Place - Suite 330, 24Boston, MA 02111-1307, USA. */ 25 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. */ 32 33 34!! libgcc1 routines for the Hitachi SH cpu. 35!! Contributed by Steve Chamberlain. 36!! sac@cygnus.com 37 38!! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines 39!! recoded in assembly by Toshiyasu Morita 40!! tm@netcom.com 41 42/* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and 43 ELF local label prefixes by J"orn Rennecke 44 amylaar@cygnus.com */ 45 46#ifdef __ELF__ 47#define LOCAL(X) .L_##X 48#else 49#define LOCAL(X) L_##X 50#endif 51 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 86 87 .align 1 88___ashiftrt_r4_32: 89___ashiftrt_r4_31: 90 rotcl r4 91 rts 92 subc r4,r4 93 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 109 rts 110 exts.b r4,r4 111 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 128 rts 129 exts.w r4,r4 130 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: 160 rts 161 shar r4 162 163___ashiftrt_r4_0: 164 rts 165 nop 166#endif 167 168#ifdef L_ashiftrt_n 169 170! 171! ___ashrsi3 172! 173! Entry: 174! 175! r4: Value to shift 176! r5: Shifts 177! 178! Exit: 179! 180! r0: Result 181! 182! Destroys: 183! 184! (none) 185! 186 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 201 202 .align 2 203LOCAL(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) 236 237LOCAL(ashrsi3_31): 238 rotcl r0 239 rts 240 subc r0,r0 241 242LOCAL(ashrsi3_30): 243 shar r0 244LOCAL(ashrsi3_29): 245 shar r0 246LOCAL(ashrsi3_28): 247 shar r0 248LOCAL(ashrsi3_27): 249 shar r0 250LOCAL(ashrsi3_26): 251 shar r0 252LOCAL(ashrsi3_25): 253 shar r0 254LOCAL(ashrsi3_24): 255 shlr16 r0 256 shlr8 r0 257 rts 258 exts.b r0,r0 259 260LOCAL(ashrsi3_23): 261 shar r0 262LOCAL(ashrsi3_22): 263 shar r0 264LOCAL(ashrsi3_21): 265 shar r0 266LOCAL(ashrsi3_20): 267 shar r0 268LOCAL(ashrsi3_19): 269 shar r0 270LOCAL(ashrsi3_18): 271 shar r0 272LOCAL(ashrsi3_17): 273 shar r0 274LOCAL(ashrsi3_16): 275 shlr16 r0 276 rts 277 exts.w r0,r0 278 279LOCAL(ashrsi3_15): 280 shar r0 281LOCAL(ashrsi3_14): 282 shar r0 283LOCAL(ashrsi3_13): 284 shar r0 285LOCAL(ashrsi3_12): 286 shar r0 287LOCAL(ashrsi3_11): 288 shar r0 289LOCAL(ashrsi3_10): 290 shar r0 291LOCAL(ashrsi3_9): 292 shar r0 293LOCAL(ashrsi3_8): 294 shar r0 295LOCAL(ashrsi3_7): 296 shar r0 297LOCAL(ashrsi3_6): 298 shar r0 299LOCAL(ashrsi3_5): 300 shar r0 301LOCAL(ashrsi3_4): 302 shar r0 303LOCAL(ashrsi3_3): 304 shar r0 305LOCAL(ashrsi3_2): 306 shar r0 307LOCAL(ashrsi3_1): 308 rts 309 shar r0 310 311LOCAL(ashrsi3_0): 312 rts 313 nop 314 315#endif 316 317#ifdef L_ashiftlt 318 319! 320! ___ashlsi3 321! 322! Entry: 323! 324! r4: Value to shift 325! r5: Shifts 326! 327! Exit: 328! 329! r0: Result 330! 331! Destroys: 332! 333! (none) 334! 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 349 350 .align 2 351LOCAL(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) 384 385LOCAL(ashlsi3_6): 386 shll2 r0 387LOCAL(ashlsi3_4): 388 shll2 r0 389LOCAL(ashlsi3_2): 390 rts 391 shll2 r0 392 393LOCAL(ashlsi3_7): 394 shll2 r0 395LOCAL(ashlsi3_5): 396 shll2 r0 397LOCAL(ashlsi3_3): 398 shll2 r0 399LOCAL(ashlsi3_1): 400 rts 401 shll r0 402 403LOCAL(ashlsi3_14): 404 shll2 r0 405LOCAL(ashlsi3_12): 406 shll2 r0 407LOCAL(ashlsi3_10): 408 shll2 r0 409LOCAL(ashlsi3_8): 410 rts 411 shll8 r0 412 413LOCAL(ashlsi3_15): 414 shll2 r0 415LOCAL(ashlsi3_13): 416 shll2 r0 417LOCAL(ashlsi3_11): 418 shll2 r0 419LOCAL(ashlsi3_9): 420 shll8 r0 421 rts 422 shll r0 423 424LOCAL(ashlsi3_22): 425 shll2 r0 426LOCAL(ashlsi3_20): 427 shll2 r0 428LOCAL(ashlsi3_18): 429 shll2 r0 430LOCAL(ashlsi3_16): 431 rts 432 shll16 r0 433 434LOCAL(ashlsi3_23): 435 shll2 r0 436LOCAL(ashlsi3_21): 437 shll2 r0 438LOCAL(ashlsi3_19): 439 shll2 r0 440LOCAL(ashlsi3_17): 441 shll16 r0 442 rts 443 shll r0 444 445LOCAL(ashlsi3_30): 446 shll2 r0 447LOCAL(ashlsi3_28): 448 shll2 r0 449LOCAL(ashlsi3_26): 450 shll2 r0 451LOCAL(ashlsi3_24): 452 shll16 r0 453 rts 454 shll8 r0 455 456LOCAL(ashlsi3_31): 457 shll2 r0 458LOCAL(ashlsi3_29): 459 shll2 r0 460LOCAL(ashlsi3_27): 461 shll2 r0 462LOCAL(ashlsi3_25): 463 shll16 r0 464 shll8 r0 465 rts 466 shll r0 467 468LOCAL(ashlsi3_0): 469 rts 470 nop 471 472#endif 473 474#ifdef L_lshiftrt 475 476! 477! ___lshrsi3 478! 479! Entry: 480! 481! r4: Value to shift 482! r5: Shifts 483! 484! Exit: 485! 486! r0: Result 487! 488! Destroys: 489! 490! (none) 491! 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 506 507 .align 2 508LOCAL(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) 541 542LOCAL(lshrsi3_6): 543 shlr2 r0 544LOCAL(lshrsi3_4): 545 shlr2 r0 546LOCAL(lshrsi3_2): 547 rts 548 shlr2 r0 549 550LOCAL(lshrsi3_7): 551 shlr2 r0 552LOCAL(lshrsi3_5): 553 shlr2 r0 554LOCAL(lshrsi3_3): 555 shlr2 r0 556LOCAL(lshrsi3_1): 557 rts 558 shlr r0 559 560LOCAL(lshrsi3_14): 561 shlr2 r0 562LOCAL(lshrsi3_12): 563 shlr2 r0 564LOCAL(lshrsi3_10): 565 shlr2 r0 566LOCAL(lshrsi3_8): 567 rts 568 shlr8 r0 569 570LOCAL(lshrsi3_15): 571 shlr2 r0 572LOCAL(lshrsi3_13): 573 shlr2 r0 574LOCAL(lshrsi3_11): 575 shlr2 r0 576LOCAL(lshrsi3_9): 577 shlr8 r0 578 rts 579 shlr r0 580 581LOCAL(lshrsi3_22): 582 shlr2 r0 583LOCAL(lshrsi3_20): 584 shlr2 r0 585LOCAL(lshrsi3_18): 586 shlr2 r0 587LOCAL(lshrsi3_16): 588 rts 589 shlr16 r0 590 591LOCAL(lshrsi3_23): 592 shlr2 r0 593LOCAL(lshrsi3_21): 594 shlr2 r0 595LOCAL(lshrsi3_19): 596 shlr2 r0 597LOCAL(lshrsi3_17): 598 shlr16 r0 599 rts 600 shlr r0 601 602LOCAL(lshrsi3_30): 603 shlr2 r0 604LOCAL(lshrsi3_28): 605 shlr2 r0 606LOCAL(lshrsi3_26): 607 shlr2 r0 608LOCAL(lshrsi3_24): 609 shlr16 r0 610 rts 611 shlr8 r0 612 613LOCAL(lshrsi3_31): 614 shlr2 r0 615LOCAL(lshrsi3_29): 616 shlr2 r0 617LOCAL(lshrsi3_27): 618 shlr2 r0 619LOCAL(lshrsi3_25): 620 shlr16 r0 621 shlr8 r0 622 rts 623 shlr r0 624 625LOCAL(lshrsi3_0): 626 rts 627 nop 628 629#endif 630 631#ifdef L_movstr 632 .text 633! done all the large groups, do the remainder 634 635! jump to movstr+ 636done: 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: 709 rts 710 nop 711 712 .align 4 713 714 .global ___movstr 715___movstr: 716 mov.l @(60,r5),r0 717 mov.l r0,@(60,r4) 718 719 mov.l @(56,r5),r0 720 mov.l r0,@(56,r4) 721 722 mov.l @(52,r5),r0 723 mov.l r0,@(52,r4) 724 725 mov.l @(48,r5),r0 726 mov.l r0,@(48,r4) 727 728 mov.l @(44,r5),r0 729 mov.l r0,@(44,r4) 730 731 mov.l @(40,r5),r0 732 mov.l r0,@(40,r4) 733 734 mov.l @(36,r5),r0 735 mov.l r0,@(36,r4) 736 737 mov.l @(32,r5),r0 738 mov.l r0,@(32,r4) 739 740 mov.l @(28,r5),r0 741 mov.l r0,@(28,r4) 742 743 mov.l @(24,r5),r0 744 mov.l r0,@(24,r4) 745 746 mov.l @(20,r5),r0 747 mov.l r0,@(20,r4) 748 749 mov.l @(16,r5),r0 750 mov.l r0,@(16,r4) 751 752 mov.l @(12,r5),r0 753 mov.l r0,@(12,r4) 754 755 mov.l @(8,r5),r0 756 mov.l r0,@(8,r4) 757 758 mov.l @(4,r5),r0 759 mov.l r0,@(4,r4) 760 761 mov.l @(0,r5),r0 762 mov.l r0,@(0,r4) 763 764 add #-16,r6 765 cmp/pl r6 766 bf done 767 768 add #64,r5 769 bra ___movstr 770 add #64,r4 771#endif 772 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 779 780 .p2align 5 781L_movstr_2mod4_end: 782 mov.l r0,@(16,r4) 783 rts 784 mov.l r1,@(20,r4) 785 786 .p2align 2 787 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) 795 796L_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 803L_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) 811 rts 812 mov.l r3,@(12,r4) 813 814___movstr_i4_even: 815 mov.l @r5+,r0 816 bra L_movstr_start_even 817 mov.l @r5+,r1 818 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) 826 rts 827 mov.l r2,@(8,r4) 828#endif /* ! __SH4__ */ 829#endif 830 831#ifdef L_mulsi3 832 833 834 .global ___mulsi3 835 836! r4 = aabb 837! r5 = ccdd 838! r0 = aabb*ccdd via partial products 839! 840! if aa == 0 and cc = 0 841! r0 = bb*dd 842! 843! else 844! aa = bb*dd + (aa*dd*65536) + (cc*bb*65536) 845! 846 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 856 857hiset: 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 864 rts 865 add r2,r0 866 867 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 874 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 882 rts 883 ftrc dr0,fpul 884 885#elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__) 886!! args in r4 and r5, result in fpul, clobber r2, dr0, dr2 887 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 900 rts 901 lds.l @r15+,fpscr 902 903#endif /* ! __SH4__ */ 904#endif 905 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__) 910!! 911!! Steve Chamberlain 912!! sac@cygnus.com 913!! 914!! 915 916!! args in r4 and r5, result in r0 clobber r1,r2,r3 917 918 .global ___sdivsi3 919___sdivsi3: 920 mov r4,r1 921 mov r5,r0 922 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 996 rts 997 mov r1,r0 998 999 1000div0: rts 1001 mov #0,r0 1002 1003#endif /* ! __SH4__ */ 1004#endif 1005#ifdef L_udivsi3_i4 1006 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 1011 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 1039 rts 1040 ftrc dr0,fpul 1041 1042trivial: 1043 rts 1044 lds r4,fpul 1045 1046 .align 2 1047L1: 1048 .double 2147483648 1049 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 1052 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 1083 rts 1084 lds.l @r15+,fpscr 1085 1086trivial: 1087 rts 1088 lds r4,fpul 1089 1090 .align 2 1091L1: 1092#if defined (__LITTLE_ENDIAN__) || ! defined (FMOVD_WORKS) 1093 .long 0x80000 1094#else 1095 .long 0x180000 1096#endif 1097 .double 2147483648 1098 1099#endif /* ! __SH4__ */ 1100#endif 1101 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__) 1106!! 1107!! Steve Chamberlain 1108!! sac@cygnus.com 1109!! 1110!! 1111 1112!! args in r4 and r5, result in r0, clobbers r4, pr, and t bit 1113 .global ___udivsi3 1114 1115___udivsi3: 1116longway: 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 1122 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 1131 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 1140shortway: 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 1149 1150vshortway: 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 1160ret: rts 1161 mov r4,r0 1162 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 1190 rts 1191 mov.l r2,@r1 1192#else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */ 1193 swap.w r0,r3 1194 rts 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 */ 1207