op.c 41.8 KB
Newer Older
B
bellard 已提交
1 2 3 4
/*
 *  MIPS emulation micro-operations for qemu.
 * 
 *  Copyright (c) 2004-2005 Jocelyn Mayer
B
bellard 已提交
5
 *  Copyright (c) 2006 Marius Groeger (FPU operations)
B
bellard 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "config.h"
#include "exec.h"

B
bellard 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#ifndef CALL_FROM_TB0
#define CALL_FROM_TB0(func) func();
#endif
#ifndef CALL_FROM_TB1
#define CALL_FROM_TB1(func, arg0) func(arg0);
#endif
#ifndef CALL_FROM_TB1_CONST16
#define CALL_FROM_TB1_CONST16(func, arg0) CALL_FROM_TB1(func, arg0);
#endif
#ifndef CALL_FROM_TB2
#define CALL_FROM_TB2(func, arg0, arg1) func(arg0, arg1);
#endif
#ifndef CALL_FROM_TB2_CONST16
#define CALL_FROM_TB2_CONST16(func, arg0, arg1)     \
CALL_FROM_TB2(func, arg0, arg1);
#endif
#ifndef CALL_FROM_TB3
#define CALL_FROM_TB3(func, arg0, arg1, arg2) func(arg0, arg1, arg2);
#endif
#ifndef CALL_FROM_TB4
#define CALL_FROM_TB4(func, arg0, arg1, arg2, arg3) \
        func(arg0, arg1, arg2, arg3);
#endif

B
bellard 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
#define REG 1
#include "op_template.c"
#undef REG
#define REG 2
#include "op_template.c"
#undef REG
#define REG 3
#include "op_template.c"
#undef REG
#define REG 4
#include "op_template.c"
#undef REG
#define REG 5
#include "op_template.c"
#undef REG
#define REG 6
#include "op_template.c"
#undef REG
#define REG 7
#include "op_template.c"
#undef REG
#define REG 8
#include "op_template.c"
#undef REG
#define REG 9
#include "op_template.c"
#undef REG
#define REG 10
#include "op_template.c"
#undef REG
#define REG 11
#include "op_template.c"
#undef REG
#define REG 12
#include "op_template.c"
#undef REG
#define REG 13
#include "op_template.c"
#undef REG
#define REG 14
#include "op_template.c"
#undef REG
#define REG 15
#include "op_template.c"
#undef REG
#define REG 16
#include "op_template.c"
#undef REG
#define REG 17
#include "op_template.c"
#undef REG
#define REG 18
#include "op_template.c"
#undef REG
#define REG 19
#include "op_template.c"
#undef REG
#define REG 20
#include "op_template.c"
#undef REG
#define REG 21
#include "op_template.c"
#undef REG
#define REG 22
#include "op_template.c"
#undef REG
#define REG 23
#include "op_template.c"
#undef REG
#define REG 24
#include "op_template.c"
#undef REG
#define REG 25
#include "op_template.c"
#undef REG
#define REG 26
#include "op_template.c"
#undef REG
#define REG 27
#include "op_template.c"
#undef REG
#define REG 28
#include "op_template.c"
#undef REG
#define REG 29
#include "op_template.c"
#undef REG
#define REG 30
#include "op_template.c"
#undef REG
#define REG 31
#include "op_template.c"
#undef REG

143
#define TN
B
bellard 已提交
144 145 146
#include "op_template.c"
#undef TN

B
bellard 已提交
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
#define SFREG 0
#define DFREG 0
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 1
#include "fop_template.c"
#undef SFREG
#define SFREG 2
#define DFREG 2
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 3
#include "fop_template.c"
#undef SFREG
#define SFREG 4
#define DFREG 4
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 5
#include "fop_template.c"
#undef SFREG
#define SFREG 6
#define DFREG 6
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 7
#include "fop_template.c"
#undef SFREG
#define SFREG 8
#define DFREG 8
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 9
#include "fop_template.c"
#undef SFREG
#define SFREG 10
#define DFREG 10
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 11
#include "fop_template.c"
#undef SFREG
#define SFREG 12
#define DFREG 12
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 13
#include "fop_template.c"
#undef SFREG
#define SFREG 14
#define DFREG 14
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 15
#include "fop_template.c"
#undef SFREG
#define SFREG 16
#define DFREG 16
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 17
#include "fop_template.c"
#undef SFREG
#define SFREG 18
#define DFREG 18
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 19
#include "fop_template.c"
#undef SFREG
#define SFREG 20
#define DFREG 20
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 21
#include "fop_template.c"
#undef SFREG
#define SFREG 22
#define DFREG 22
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 23
#include "fop_template.c"
#undef SFREG
#define SFREG 24
#define DFREG 24
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 25
#include "fop_template.c"
#undef SFREG
#define SFREG 26
#define DFREG 26
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 27
#include "fop_template.c"
#undef SFREG
#define SFREG 28
#define DFREG 28
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 29
#include "fop_template.c"
#undef SFREG
#define SFREG 30
#define DFREG 30
#include "fop_template.c"
#undef SFREG
#undef DFREG
#define SFREG 31
#include "fop_template.c"
#undef SFREG

#define FTN
#include "fop_template.c"
#undef FTN

B
bellard 已提交
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
void op_dup_T0 (void)
{
    T2 = T0;
    RETURN();
}

void op_load_HI (void)
{
    T0 = env->HI;
    RETURN();
}

void op_store_HI (void)
{
    env->HI = T0;
    RETURN();
}

void op_load_LO (void)
{
    T0 = env->LO;
    RETURN();
}

void op_store_LO (void)
{
    env->LO = T0;
    RETURN();
}

/* Load and store */
#define MEMSUFFIX _raw
#include "op_mem.c"
#undef MEMSUFFIX
#if !defined(CONFIG_USER_ONLY)
#define MEMSUFFIX _user
#include "op_mem.c"
#undef MEMSUFFIX

#define MEMSUFFIX _kernel
#include "op_mem.c"
#undef MEMSUFFIX
#endif

/* Arithmetic */
void op_add (void)
{
T
ths 已提交
327
    T0 = (int32_t)((int32_t)T0 + (int32_t)T1);
B
bellard 已提交
328 329 330 331 332 333 334
    RETURN();
}

void op_addo (void)
{
    target_ulong tmp;

335 336
    tmp = (int32_t)T0;
    T0 = (int32_t)T0 + (int32_t)T1;
337
    if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {
338
        /* operands of same sign, result different sign */
339
        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
B
bellard 已提交
340
    }
T
ths 已提交
341
    T0 = (int32_t)T0;
B
bellard 已提交
342 343 344 345 346
    RETURN();
}

void op_sub (void)
{
T
ths 已提交
347
    T0 = (int32_t)((int32_t)T0 - (int32_t)T1);
B
bellard 已提交
348 349 350 351 352 353 354
    RETURN();
}

void op_subo (void)
{
    target_ulong tmp;

355
    tmp = (int32_t)T0;
B
bellard 已提交
356
    T0 = (int32_t)T0 - (int32_t)T1;
357
    if (((tmp ^ T1) & (tmp ^ T0)) >> 31) {
358
        /* operands of different sign, first operand and result different sign */
359
        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
B
bellard 已提交
360
    }
T
ths 已提交
361
    T0 = (int32_t)T0;
B
bellard 已提交
362 363 364 365 366
    RETURN();
}

void op_mul (void)
{
T
ths 已提交
367
    T0 = (int32_t)((int32_t)T0 * (int32_t)T1);
B
bellard 已提交
368 369 370 371 372 373
    RETURN();
}

void op_div (void)
{
    if (T1 != 0) {
T
ths 已提交
374 375
        env->LO = (int32_t)((int32_t)T0 / (int32_t)T1);
        env->HI = (int32_t)((int32_t)T0 % (int32_t)T1);
B
bellard 已提交
376 377 378 379 380
    }
    RETURN();
}

void op_divu (void)
381 382
{
    if (T1 != 0) {
T
ths 已提交
383 384
        env->LO = (int32_t)((uint32_t)T0 / (uint32_t)T1);
        env->HI = (int32_t)((uint32_t)T0 % (uint32_t)T1);
385 386 387 388
    }
    RETURN();
}

T
ths 已提交
389
#ifdef TARGET_MIPS64
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
/* Arithmetic */
void op_dadd (void)
{
    T0 += T1;
    RETURN();
}

void op_daddo (void)
{
    target_long tmp;

    tmp = T0;
    T0 += T1;
    if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 63) {
        /* operands of same sign, result different sign */
405
        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
    }
    RETURN();
}

void op_dsub (void)
{
    T0 -= T1;
    RETURN();
}

void op_dsubo (void)
{
    target_long tmp;

    tmp = T0;
    T0 = (int64_t)T0 - (int64_t)T1;
    if (((tmp ^ T1) & (tmp ^ T0)) >> 63) {
        /* operands of different sign, first operand and result different sign */
424
        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
    }
    RETURN();
}

void op_dmul (void)
{
    T0 = (int64_t)T0 * (int64_t)T1;
    RETURN();
}

#if TARGET_LONG_BITS > HOST_LONG_BITS
/* Those might call libgcc functions.  */
void op_ddiv (void)
{
    do_ddiv();
    RETURN();
}

void op_ddivu (void)
{
    do_ddivu();
    RETURN();
}
#else
void op_ddiv (void)
{
    if (T1 != 0) {
        env->LO = (int64_t)T0 / (int64_t)T1;
        env->HI = (int64_t)T0 % (int64_t)T1;
    }
    RETURN();
}

void op_ddivu (void)
B
bellard 已提交
459 460 461 462 463 464 465
{
    if (T1 != 0) {
        env->LO = T0 / T1;
        env->HI = T0 % T1;
    }
    RETURN();
}
466
#endif
T
ths 已提交
467
#endif /* TARGET_MIPS64 */
B
bellard 已提交
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495

/* Logical */
void op_and (void)
{
    T0 &= T1;
    RETURN();
}

void op_nor (void)
{
    T0 = ~(T0 | T1);
    RETURN();
}

void op_or (void)
{
    T0 |= T1;
    RETURN();
}

void op_xor (void)
{
    T0 ^= T1;
    RETURN();
}

void op_sll (void)
{
496
    T0 = (int32_t)((uint32_t)T0 << T1);
B
bellard 已提交
497 498 499 500 501
    RETURN();
}

void op_sra (void)
{
502
    T0 = (int32_t)((int32_t)T0 >> T1);
B
bellard 已提交
503 504 505 506 507
    RETURN();
}

void op_srl (void)
{
508
    T0 = (int32_t)((uint32_t)T0 >> T1);
B
bellard 已提交
509 510 511
    RETURN();
}

512 513 514 515 516
void op_rotr (void)
{
    target_ulong tmp;

    if (T1) {
517 518 519
       tmp = (int32_t)((uint32_t)T0 << (0x20 - T1));
       T0 = (int32_t)((uint32_t)T0 >> T1) | tmp;
    }
520 521 522
    RETURN();
}

B
bellard 已提交
523 524
void op_sllv (void)
{
T
ths 已提交
525
    T0 = (int32_t)((uint32_t)T1 << ((uint32_t)T0 & 0x1F));
B
bellard 已提交
526 527 528 529 530
    RETURN();
}

void op_srav (void)
{
T
ths 已提交
531
    T0 = (int32_t)((int32_t)T1 >> (T0 & 0x1F));
B
bellard 已提交
532 533 534 535 536
    RETURN();
}

void op_srlv (void)
{
T
ths 已提交
537
    T0 = (int32_t)((uint32_t)T1 >> (T0 & 0x1F));
B
bellard 已提交
538 539 540
    RETURN();
}

541 542 543 544 545 546
void op_rotrv (void)
{
    target_ulong tmp;

    T0 &= 0x1F;
    if (T0) {
T
ths 已提交
547 548
       tmp = (int32_t)((uint32_t)T1 << (0x20 - T0));
       T0 = (int32_t)((uint32_t)T1 >> T0) | tmp;
549 550 551 552 553
    } else
       T0 = T1;
    RETURN();
}

B
bellard 已提交
554 555 556 557
void op_clo (void)
{
    int n;

558
    if (T0 == ~((target_ulong)0)) {
B
bellard 已提交
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
        T0 = 32;
    } else {
        for (n = 0; n < 32; n++) {
            if (!(T0 & (1 << 31)))
                break;
            T0 = T0 << 1;
        }
        T0 = n;
    }
    RETURN();
}

void op_clz (void)
{
    int n;

    if (T0 == 0) {
        T0 = 32;
    } else {
        for (n = 0; n < 32; n++) {
            if (T0 & (1 << 31))
                break;
            T0 = T0 << 1;
        }
        T0 = n;
    }
    RETURN();
}

T
ths 已提交
588
#ifdef TARGET_MIPS64
589 590 591 592

#if TARGET_LONG_BITS > HOST_LONG_BITS
/* Those might call libgcc functions.  */
void op_dsll (void)
B
bellard 已提交
593
{
594 595
    CALL_FROM_TB0(do_dsll);
    RETURN();
B
bellard 已提交
596 597
}

598
void op_dsll32 (void)
B
bellard 已提交
599
{
600 601
    CALL_FROM_TB0(do_dsll32);
    RETURN();
B
bellard 已提交
602 603
}

604
void op_dsra (void)
B
bellard 已提交
605
{
606
    CALL_FROM_TB0(do_dsra);
B
bellard 已提交
607 608 609
    RETURN();
}

610
void op_dsra32 (void)
B
bellard 已提交
611
{
612
    CALL_FROM_TB0(do_dsra32);
B
bellard 已提交
613 614 615
    RETURN();
}

616
void op_dsrl (void)
B
bellard 已提交
617
{
618 619 620
    CALL_FROM_TB0(do_dsrl);
    RETURN();
}
B
bellard 已提交
621

622 623 624
void op_dsrl32 (void)
{
    CALL_FROM_TB0(do_dsrl32);
B
bellard 已提交
625 626 627
    RETURN();
}

628
void op_drotr (void)
B
bellard 已提交
629
{
630 631 632
    CALL_FROM_TB0(do_drotr);
    RETURN();
}
B
bellard 已提交
633

634 635 636
void op_drotr32 (void)
{
    CALL_FROM_TB0(do_drotr32);
B
bellard 已提交
637 638 639
    RETURN();
}

640
void op_dsllv (void)
B
bellard 已提交
641
{
642 643 644
    CALL_FROM_TB0(do_dsllv);
    RETURN();
}
B
bellard 已提交
645

646 647 648
void op_dsrav (void)
{
    CALL_FROM_TB0(do_dsrav);
B
bellard 已提交
649 650 651
    RETURN();
}

652
void op_dsrlv (void)
B
bellard 已提交
653
{
654 655 656
    CALL_FROM_TB0(do_dsrlv);
    RETURN();
}
B
bellard 已提交
657

658 659 660
void op_drotrv (void)
{
    CALL_FROM_TB0(do_drotrv);
B
bellard 已提交
661 662
    RETURN();
}
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708

#else /* TARGET_LONG_BITS > HOST_LONG_BITS */

void op_dsll (void)
{
    T0 = T0 << T1;
    RETURN();
}

void op_dsll32 (void)
{
    T0 = T0 << (T1 + 32);
    RETURN();
}

void op_dsra (void)
{
    T0 = (int64_t)T0 >> T1;
    RETURN();
}

void op_dsra32 (void)
{
    T0 = (int64_t)T0 >> (T1 + 32);
    RETURN();
}

void op_dsrl (void)
{
    T0 = T0 >> T1;
    RETURN();
}

void op_dsrl32 (void)
{
    T0 = T0 >> (T1 + 32);
    RETURN();
}

void op_drotr (void)
{
    target_ulong tmp;

    if (T1) {
       tmp = T0 << (0x40 - T1);
       T0 = (T0 >> T1) | tmp;
709
    }
710 711 712 713 714 715 716 717 718 719
    RETURN();
}

void op_drotr32 (void)
{
    target_ulong tmp;

    if (T1) {
       tmp = T0 << (0x40 - (32 + T1));
       T0 = (T0 >> (32 + T1)) | tmp;
720
    }
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
    RETURN();
}

void op_dsllv (void)
{
    T0 = T1 << (T0 & 0x3F);
    RETURN();
}

void op_dsrav (void)
{
    T0 = (int64_t)T1 >> (T0 & 0x3F);
    RETURN();
}

void op_dsrlv (void)
{
    T0 = T1 >> (T0 & 0x3F);
    RETURN();
}

void op_drotrv (void)
{
    target_ulong tmp;

    T0 &= 0x3F;
    if (T0) {
       tmp = T1 << (0x40 - T0);
       T0 = (T1 >> T0) | tmp;
    } else
       T0 = T1;
    RETURN();
}
#endif /* TARGET_LONG_BITS > HOST_LONG_BITS */

void op_dclo (void)
{
    int n;

    if (T0 == ~((target_ulong)0)) {
        T0 = 64;
    } else {
        for (n = 0; n < 64; n++) {
            if (!(T0 & (1ULL << 63)))
                break;
            T0 = T0 << 1;
        }
        T0 = n;
    }
    RETURN();
}

void op_dclz (void)
{
    int n;

    if (T0 == 0) {
        T0 = 64;
    } else {
        for (n = 0; n < 64; n++) {
            if (T0 & (1ULL << 63))
                break;
            T0 = T0 << 1;
        }
        T0 = n;
    }
    RETURN();
}
#endif

/* 64 bits arithmetic */
#if TARGET_LONG_BITS > HOST_LONG_BITS
B
bellard 已提交
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
void op_mult (void)
{
    CALL_FROM_TB0(do_mult);
    RETURN();
}

void op_multu (void)
{
    CALL_FROM_TB0(do_multu);
    RETURN();
}

void op_madd (void)
{
    CALL_FROM_TB0(do_madd);
    RETURN();
}

void op_maddu (void)
{
    CALL_FROM_TB0(do_maddu);
    RETURN();
}

void op_msub (void)
{
    CALL_FROM_TB0(do_msub);
    RETURN();
}

void op_msubu (void)
{
    CALL_FROM_TB0(do_msubu);
    RETURN();
}
828 829 830 831 832 833 834 835 836 837

#else /* TARGET_LONG_BITS > HOST_LONG_BITS */

static inline uint64_t get_HILO (void)
{
    return ((uint64_t)env->HI << 32) | ((uint64_t)(uint32_t)env->LO);
}

static inline void set_HILO (uint64_t HILO)
{
T
ths 已提交
838 839
    env->LO = (int32_t)(HILO & 0xFFFFFFFF);
    env->HI = (int32_t)(HILO >> 32);
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
}

void op_mult (void)
{
    set_HILO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
    RETURN();
}

void op_multu (void)
{
    set_HILO((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
    RETURN();
}

void op_madd (void)
{
    int64_t tmp;

    tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
    set_HILO((int64_t)get_HILO() + tmp);
    RETURN();
}

void op_maddu (void)
{
    uint64_t tmp;

    tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
    set_HILO(get_HILO() + tmp);
    RETURN();
}

void op_msub (void)
{
    int64_t tmp;

    tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
    set_HILO((int64_t)get_HILO() - tmp);
    RETURN();
}

void op_msubu (void)
{
    uint64_t tmp;

    tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
    set_HILO(get_HILO() - tmp);
    RETURN();
}
#endif /* TARGET_LONG_BITS > HOST_LONG_BITS */

T
ths 已提交
891
#ifdef TARGET_MIPS64
892 893 894 895 896 897 898 899 900 901 902
void op_dmult (void)
{
    CALL_FROM_TB0(do_dmult);
    RETURN();
}

void op_dmultu (void)
{
    CALL_FROM_TB0(do_dmultu);
    RETURN();
}
B
bellard 已提交
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919
#endif

/* Conditional moves */
void op_movn (void)
{
    if (T1 != 0)
        env->gpr[PARAM1] = T0;
    RETURN();
}

void op_movz (void)
{
    if (T1 == 0)
        env->gpr[PARAM1] = T0;
    RETURN();
}

920 921 922 923 924 925 926 927 928 929 930 931 932 933
void op_movf (void)
{
    if (!(env->fcr31 & PARAM1))
        env->gpr[PARAM2] = env->gpr[PARAM3];
    RETURN();
}

void op_movt (void)
{
    if (env->fcr31 & PARAM1)
        env->gpr[PARAM2] = env->gpr[PARAM3];
    RETURN();
}

B
bellard 已提交
934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956
/* Tests */
#define OP_COND(name, cond) \
void glue(op_, name) (void) \
{                           \
    if (cond) {             \
        T0 = 1;             \
    } else {                \
        T0 = 0;             \
    }                       \
    RETURN();               \
}

OP_COND(eq, T0 == T1);
OP_COND(ne, T0 != T1);
OP_COND(ge, (int32_t)T0 >= (int32_t)T1);
OP_COND(geu, T0 >= T1);
OP_COND(lt, (int32_t)T0 < (int32_t)T1);
OP_COND(ltu, T0 < T1);
OP_COND(gez, (int32_t)T0 >= 0);
OP_COND(gtz, (int32_t)T0 > 0);
OP_COND(lez, (int32_t)T0 <= 0);
OP_COND(ltz, (int32_t)T0 < 0);

957
/* Branches */
B
bellard 已提交
958
//#undef USE_DIRECT_JUMP
B
bellard 已提交
959 960 961 962

void OPPROTO op_goto_tb0(void)
{
    GOTO_TB(op_goto_tb0, PARAM1, 0);
963
    RETURN();
B
bellard 已提交
964 965 966 967 968
}

void OPPROTO op_goto_tb1(void)
{
    GOTO_TB(op_goto_tb1, PARAM1, 1);
969
    RETURN();
B
bellard 已提交
970
}
B
bellard 已提交
971 972 973 974 975

/* Branch to register */
void op_save_breg_target (void)
{
    env->btarget = T2;
976
    RETURN();
B
bellard 已提交
977 978 979 980 981
}

void op_restore_breg_target (void)
{
    T2 = env->btarget;
982
    RETURN();
B
bellard 已提交
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
}

void op_breg (void)
{
    env->PC = T2;
    RETURN();
}

void op_save_btarget (void)
{
    env->btarget = PARAM1;
    RETURN();
}

/* Conditional branch */
void op_set_bcond (void)
{
    T2 = T0;
    RETURN();
}

void op_save_bcond (void)
{
    env->bcond = T2;
    RETURN();
}

void op_restore_bcond (void)
{
    T2 = env->bcond;
    RETURN();
}

B
bellard 已提交
1016
void op_jnz_T2 (void)
B
bellard 已提交
1017
{
B
bellard 已提交
1018 1019
    if (T2)
        GOTO_LABEL_PARAM(1);
B
bellard 已提交
1020 1021 1022 1023
    RETURN();
}

/* CP0 functions */
1024
void op_mfc0_index (void)
B
bellard 已提交
1025
{
T
ths 已提交
1026
    T0 = env->CP0_Index;
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037
    RETURN();
}

void op_mfc0_random (void)
{
    CALL_FROM_TB0(do_mfc0_random);
    RETURN();
}

void op_mfc0_entrylo0 (void)
{
T
ths 已提交
1038
    T0 = (int32_t)env->CP0_EntryLo0;
1039 1040 1041 1042 1043
    RETURN();
}

void op_mfc0_entrylo1 (void)
{
T
ths 已提交
1044
    T0 = (int32_t)env->CP0_EntryLo1;
1045 1046 1047 1048 1049
    RETURN();
}

void op_mfc0_context (void)
{
T
ths 已提交
1050
    T0 = (int32_t)env->CP0_Context;
1051 1052 1053 1054 1055
    RETURN();
}

void op_mfc0_pagemask (void)
{
T
ths 已提交
1056
    T0 = env->CP0_PageMask;
1057 1058 1059
    RETURN();
}

1060 1061
void op_mfc0_pagegrain (void)
{
T
ths 已提交
1062
    T0 = env->CP0_PageGrain;
1063 1064 1065
    RETURN();
}

1066 1067
void op_mfc0_wired (void)
{
T
ths 已提交
1068
    T0 = env->CP0_Wired;
1069 1070 1071
    RETURN();
}

1072 1073
void op_mfc0_hwrena (void)
{
T
ths 已提交
1074
    T0 = env->CP0_HWREna;
1075 1076 1077
    RETURN();
}

1078 1079
void op_mfc0_badvaddr (void)
{
T
ths 已提交
1080
    T0 = (int32_t)env->CP0_BadVAddr;
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
    RETURN();
}

void op_mfc0_count (void)
{
    CALL_FROM_TB0(do_mfc0_count);
    RETURN();
}

void op_mfc0_entryhi (void)
{
T
ths 已提交
1092
    T0 = (int32_t)env->CP0_EntryHi;
1093 1094 1095 1096 1097
    RETURN();
}

void op_mfc0_compare (void)
{
T
ths 已提交
1098
    T0 = env->CP0_Compare;
1099 1100 1101 1102 1103
    RETURN();
}

void op_mfc0_status (void)
{
T
ths 已提交
1104
    T0 = env->CP0_Status;
1105 1106 1107
    RETURN();
}

1108 1109
void op_mfc0_intctl (void)
{
T
ths 已提交
1110
    T0 = env->CP0_IntCtl;
1111 1112 1113 1114 1115
    RETURN();
}

void op_mfc0_srsctl (void)
{
T
ths 已提交
1116 1117 1118 1119 1120 1121 1122
    T0 = env->CP0_SRSCtl;
    RETURN();
}

void op_mfc0_srsmap (void)
{
    T0 = env->CP0_SRSMap;
1123 1124 1125
    RETURN();
}

1126 1127
void op_mfc0_cause (void)
{
T
ths 已提交
1128
    T0 = env->CP0_Cause;
1129 1130 1131 1132 1133
    RETURN();
}

void op_mfc0_epc (void)
{
T
ths 已提交
1134
    T0 = (int32_t)env->CP0_EPC;
1135 1136 1137 1138 1139
    RETURN();
}

void op_mfc0_prid (void)
{
T
ths 已提交
1140
    T0 = env->CP0_PRid;
1141 1142 1143
    RETURN();
}

1144 1145
void op_mfc0_ebase (void)
{
1146
    T0 = env->CP0_EBase;
1147 1148 1149
    RETURN();
}

1150 1151
void op_mfc0_config0 (void)
{
T
ths 已提交
1152
    T0 = env->CP0_Config0;
1153 1154 1155 1156 1157
    RETURN();
}

void op_mfc0_config1 (void)
{
T
ths 已提交
1158
    T0 = env->CP0_Config1;
1159 1160 1161
    RETURN();
}

1162 1163
void op_mfc0_config2 (void)
{
T
ths 已提交
1164
    T0 = env->CP0_Config2;
1165 1166 1167 1168 1169
    RETURN();
}

void op_mfc0_config3 (void)
{
T
ths 已提交
1170
    T0 = env->CP0_Config3;
1171 1172 1173
    RETURN();
}

1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185
void op_mfc0_config6 (void)
{
    T0 = env->CP0_Config6;
    RETURN();
}

void op_mfc0_config7 (void)
{
    T0 = env->CP0_Config7;
    RETURN();
}

1186 1187
void op_mfc0_lladdr (void)
{
T
ths 已提交
1188
    T0 = (int32_t)env->CP0_LLAddr >> 4;
1189 1190 1191
    RETURN();
}

1192
void op_mfc0_watchlo0 (void)
1193
{
T
ths 已提交
1194
    T0 = (int32_t)env->CP0_WatchLo;
1195 1196 1197
    RETURN();
}

1198
void op_mfc0_watchhi0 (void)
1199
{
T
ths 已提交
1200
    T0 = env->CP0_WatchHi;
1201 1202 1203
    RETURN();
}

1204 1205
void op_mfc0_xcontext (void)
{
T
ths 已提交
1206
    T0 = (int32_t)env->CP0_XContext;
1207 1208 1209 1210 1211 1212 1213 1214 1215
    RETURN();
}

void op_mfc0_framemask (void)
{
    T0 = env->CP0_Framemask;
    RETURN();
}

1216 1217
void op_mfc0_debug (void)
{
T
ths 已提交
1218
    T0 = env->CP0_Debug;
1219 1220 1221 1222 1223 1224 1225
    if (env->hflags & MIPS_HFLAG_DM)
        T0 |= 1 << CP0DB_DM;
    RETURN();
}

void op_mfc0_depc (void)
{
T
ths 已提交
1226
    T0 = (int32_t)env->CP0_DEPC;
1227 1228 1229
    RETURN();
}

1230 1231
void op_mfc0_performance0 (void)
{
T
ths 已提交
1232
    T0 = env->CP0_Performance0;
1233 1234 1235
    RETURN();
}

1236 1237
void op_mfc0_taglo (void)
{
T
ths 已提交
1238
    T0 = env->CP0_TagLo;
1239 1240 1241 1242 1243
    RETURN();
}

void op_mfc0_datalo (void)
{
T
ths 已提交
1244
    T0 = env->CP0_DataLo;
1245 1246 1247
    RETURN();
}

1248 1249
void op_mfc0_taghi (void)
{
T
ths 已提交
1250
    T0 = env->CP0_TagHi;
1251 1252 1253 1254 1255
    RETURN();
}

void op_mfc0_datahi (void)
{
T
ths 已提交
1256
    T0 = env->CP0_DataHi;
1257 1258 1259
    RETURN();
}

1260 1261
void op_mfc0_errorepc (void)
{
T
ths 已提交
1262
    T0 = (int32_t)env->CP0_ErrorEPC;
1263 1264 1265 1266 1267
    RETURN();
}

void op_mfc0_desave (void)
{
T
ths 已提交
1268
    T0 = env->CP0_DESAVE;
B
bellard 已提交
1269 1270 1271
    RETURN();
}

1272
void op_mtc0_index (void)
B
bellard 已提交
1273
{
T
ths 已提交
1274
    env->CP0_Index = (env->CP0_Index & 0x80000000) | (T0 & (MIPS_TLB_NB - 1));
1275 1276 1277 1278 1279
    RETURN();
}

void op_mtc0_entrylo0 (void)
{
1280 1281
    /* Large physaddr not implemented */
    /* 1k pages not implemented */
T
ths 已提交
1282
    env->CP0_EntryLo0 = (int32_t)T0 & 0x3FFFFFFF;
1283 1284 1285 1286 1287
    RETURN();
}

void op_mtc0_entrylo1 (void)
{
1288 1289
    /* Large physaddr not implemented */
    /* 1k pages not implemented */
T
ths 已提交
1290
    env->CP0_EntryLo1 = (int32_t)T0 & 0x3FFFFFFF;
1291 1292 1293 1294 1295
    RETURN();
}

void op_mtc0_context (void)
{
1296
    env->CP0_Context = (env->CP0_Context & 0x007FFFFF) | (T0 & ~0x007FFFFF);
1297 1298 1299 1300 1301
    RETURN();
}

void op_mtc0_pagemask (void)
{
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312
    /* 1k pages not implemented */
    env->CP0_PageMask = T0 & 0x1FFFE000;
    RETURN();
}

void op_mtc0_pagegrain (void)
{
    /* SmartMIPS not implemented */
    /* Large physaddr not implemented */
    /* 1k pages not implemented */
    env->CP0_PageGrain = 0;
1313 1314 1315 1316 1317
    RETURN();
}

void op_mtc0_wired (void)
{
1318 1319 1320 1321 1322 1323 1324
    env->CP0_Wired = T0 & (MIPS_TLB_NB - 1);
    RETURN();
}

void op_mtc0_hwrena (void)
{
    env->CP0_HWREna = T0 & 0x0000000F;
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335
    RETURN();
}

void op_mtc0_count (void)
{
    CALL_FROM_TB2(cpu_mips_store_count, env, T0);
    RETURN();
}

void op_mtc0_entryhi (void)
{
T
ths 已提交
1336
    target_ulong old, val;
1337

1338 1339
    /* 1k pages not implemented */
    /* Ignore MIPS64 TLB for now */
1340
    val = (target_ulong)(int32_t)T0 & ~(target_ulong)0x1F00;
1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
    old = env->CP0_EntryHi;
    env->CP0_EntryHi = val;
    /* If the ASID changes, flush qemu's TLB.  */
    if ((old & 0xFF) != (val & 0xFF))
        CALL_FROM_TB2(cpu_mips_tlb_flush, env, 1);
    RETURN();
}

void op_mtc0_compare (void)
{
    CALL_FROM_TB2(cpu_mips_store_compare, env, T0);
    RETURN();
}

void op_mtc0_status (void)
{
1357
    uint32_t val, old;
1358

T
ths 已提交
1359 1360 1361
    /* No 64bit FPU, no reverse endianness, no MDMX/DSP, no 64bit ops,
       no 64bit addressing implemented. */
    val = (int32_t)T0 & 0xF878FF17;
1362
    old = env->CP0_Status;
1363 1364 1365 1366 1367
    if (!(val & (1 << CP0St_EXL)) &&
        !(val & (1 << CP0St_ERL)) &&
        !(env->hflags & MIPS_HFLAG_DM) &&
        (val & (1 << CP0St_UM)))
        env->hflags |= MIPS_HFLAG_UM;
1368
    env->CP0_Status = val;
1369 1370
    if (loglevel & CPU_LOG_EXEC)
        CALL_FROM_TB2(do_mtc0_status_debug, old, val);
1371
    CALL_FROM_TB1(cpu_mips_update_irq, env);
1372 1373 1374
    RETURN();
}

1375 1376
void op_mtc0_intctl (void)
{
T
ths 已提交
1377 1378 1379
    /* vectored interrupts not implemented, timer on int 7,
       no performance counters. */
    env->CP0_IntCtl |= T0 & 0x000002e0;
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389
    RETURN();
}

void op_mtc0_srsctl (void)
{
    /* shadow registers not implemented */
    env->CP0_SRSCtl = 0;
    RETURN();
}

T
ths 已提交
1390 1391 1392 1393 1394 1395 1396
void op_mtc0_srsmap (void)
{
    /* shadow registers not implemented */
    env->CP0_SRSMap = 0;
    RETURN();
}

1397 1398
void op_mtc0_cause (void)
{
1399 1400 1401 1402 1403
    uint32_t mask = 0x00C00300;

    if ((env->CP0_Config0 & (0x7 << CP0C0_AR)) == (1 << CP0C0_AR))
        mask |= 1 << CP0Ca_DC;

1404
    env->CP0_Cause = (env->CP0_Cause & ~mask) | (T0 & mask);
1405

1406 1407 1408 1409
    /* Handle the software interrupt as an hardware one, as they
       are very similar */
    if (T0 & CP0Ca_IP_mask) {
        CALL_FROM_TB1(cpu_mips_update_irq, env);
1410 1411 1412 1413 1414 1415
    }
    RETURN();
}

void op_mtc0_epc (void)
{
T
ths 已提交
1416
    env->CP0_EPC = (int32_t)T0;
1417 1418 1419
    RETURN();
}

1420 1421 1422 1423
void op_mtc0_ebase (void)
{
    /* vectored interrupts not implemented */
    /* Multi-CPU not implemented */
1424
    env->CP0_EBase = 0x80000000 | (T0 & 0x3FFFF000);
1425 1426 1427
    RETURN();
}

1428 1429 1430
void op_mtc0_config0 (void)
{
#if defined(MIPS_USES_R4K_TLB)
1431 1432
     /* Fixed mapping MMU not implemented */
    env->CP0_Config0 = (env->CP0_Config0 & 0x8017FF88) | (T0 & 0x00000001);
1433
#else
1434
    env->CP0_Config0 = (env->CP0_Config0 & 0xFE17FF88) | (T0 & 0x00000001);
1435 1436 1437 1438
#endif
    RETURN();
}

1439 1440 1441 1442 1443 1444 1445 1446
void op_mtc0_config2 (void)
{
    /* tertiary/secondary caches not implemented */
    env->CP0_Config2 = (env->CP0_Config2 & 0x8FFF0FFF);
    RETURN();
}

void op_mtc0_watchlo0 (void)
1447
{
T
ths 已提交
1448 1449 1450
    /* Watch exceptions for instructions, data loads, data stores
       not implemented. */
    env->CP0_WatchLo = (int32_t)(T0 & ~0x7);
1451 1452 1453
    RETURN();
}

1454
void op_mtc0_watchhi0 (void)
1455
{
T
ths 已提交
1456 1457
    env->CP0_WatchHi = (T0 & 0x40FF0FF8);
    env->CP0_WatchHi &= ~(env->CP0_WatchHi & T0 & 0x7);
1458 1459 1460
    RETURN();
}

1461 1462 1463 1464 1465 1466
void op_mtc0_framemask (void)
{
    env->CP0_Framemask = T0; /* XXX */
    RETURN();
}

1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478
void op_mtc0_debug (void)
{
    env->CP0_Debug = (env->CP0_Debug & 0x8C03FC1F) | (T0 & 0x13300120);
    if (T0 & (1 << CP0DB_DM))
        env->hflags |= MIPS_HFLAG_DM;
    else
        env->hflags &= ~MIPS_HFLAG_DM;
    RETURN();
}

void op_mtc0_depc (void)
{
T
ths 已提交
1479
    env->CP0_DEPC = (int32_t)T0;
1480 1481 1482
    RETURN();
}

1483 1484 1485 1486 1487 1488
void op_mtc0_performance0 (void)
{
    env->CP0_Performance0 = T0; /* XXX */
    RETURN();
}

1489 1490
void op_mtc0_taglo (void)
{
T
ths 已提交
1491
    env->CP0_TagLo = T0 & 0xFFFFFCF6;
1492 1493 1494
    RETURN();
}

1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512
void op_mtc0_datalo (void)
{
    env->CP0_DataLo = T0; /* XXX */
    RETURN();
}

void op_mtc0_taghi (void)
{
    env->CP0_TagHi = T0; /* XXX */
    RETURN();
}

void op_mtc0_datahi (void)
{
    env->CP0_DataHi = T0; /* XXX */
    RETURN();
}

1513 1514
void op_mtc0_errorepc (void)
{
T
ths 已提交
1515
    env->CP0_ErrorEPC = (int32_t)T0;
1516 1517 1518 1519 1520 1521
    RETURN();
}

void op_mtc0_desave (void)
{
    env->CP0_DESAVE = T0;
B
bellard 已提交
1522 1523 1524
    RETURN();
}

1525
#ifdef TARGET_MIPS64
T
ths 已提交
1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609
void op_dmfc0_entrylo0 (void)
{
    T0 = env->CP0_EntryLo0;
    RETURN();
}

void op_dmfc0_entrylo1 (void)
{
    T0 = env->CP0_EntryLo1;
    RETURN();
}

void op_dmfc0_context (void)
{
    T0 = env->CP0_Context;
    RETURN();
}

void op_dmfc0_badvaddr (void)
{
    T0 = env->CP0_BadVAddr;
    RETURN();
}

void op_dmfc0_entryhi (void)
{
    T0 = env->CP0_EntryHi;
    RETURN();
}

void op_dmfc0_epc (void)
{
    T0 = env->CP0_EPC;
    RETURN();
}

void op_dmfc0_lladdr (void)
{
    T0 = env->CP0_LLAddr >> 4;
    RETURN();
}

void op_dmfc0_watchlo0 (void)
{
    T0 = env->CP0_WatchLo;
    RETURN();
}

void op_dmfc0_xcontext (void)
{
    T0 = env->CP0_XContext;
    RETURN();
}

void op_dmfc0_depc (void)
{
    T0 = env->CP0_DEPC;
    RETURN();
}

void op_dmfc0_errorepc (void)
{
    T0 = env->CP0_ErrorEPC;
    RETURN();
}

void op_dmtc0_entrylo0 (void)
{
    /* Large physaddr not implemented */
    /* 1k pages not implemented */
    env->CP0_EntryLo0 = T0 & 0x3FFFFFFF;
    RETURN();
}

void op_dmtc0_entrylo1 (void)
{
    /* Large physaddr not implemented */
    /* 1k pages not implemented */
    env->CP0_EntryLo1 = T0 & 0x3FFFFFFF;
    RETURN();
}

void op_dmtc0_context (void)
{
1610
    env->CP0_Context = (env->CP0_Context & 0x007FFFFF) | (T0 & ~0x007FFFFF);
T
ths 已提交
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621
    RETURN();
}

void op_dmtc0_epc (void)
{
    env->CP0_EPC = T0;
    RETURN();
}

void op_dmtc0_watchlo0 (void)
{
T
ths 已提交
1622 1623 1624
    /* Watch exceptions for instructions, data loads, data stores
       not implemented. */
    env->CP0_WatchLo = T0 & ~0x7;
T
ths 已提交
1625 1626 1627 1628 1629
    RETURN();
}

void op_dmtc0_xcontext (void)
{
1630
    env->CP0_XContext = (env->CP0_XContext & 0xffffffff) | (T0 & ~0xffffffff);
T
ths 已提交
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644
    RETURN();
}

void op_dmtc0_depc (void)
{
    env->CP0_DEPC = T0;
    RETURN();
}

void op_dmtc0_errorepc (void)
{
    env->CP0_ErrorEPC = T0;
    RETURN();
}
1645
#endif /* TARGET_MIPS64 */
T
ths 已提交
1646

B
bellard 已提交
1647 1648 1649 1650 1651 1652
#if 0
# define DEBUG_FPU_STATE() CALL_FROM_TB1(dump_fpu, env)
#else
# define DEBUG_FPU_STATE() do { } while(0)
#endif

T
ths 已提交
1653 1654 1655 1656
void op_cp0_enabled(void)
{
    if (!(env->CP0_Status & (1 << CP0St_CU0)) &&
	(env->hflags & MIPS_HFLAG_UM)) {
1657
        CALL_FROM_TB2(do_raise_exception_err, EXCP_CpU, 0);
T
ths 已提交
1658 1659 1660 1661
    }
    RETURN();
}

B
bellard 已提交
1662 1663 1664
void op_cp1_enabled(void)
{
    if (!(env->CP0_Status & (1 << CP0St_CU1))) {
1665
        CALL_FROM_TB2(do_raise_exception_err, EXCP_CpU, 1);
B
bellard 已提交
1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738
    }
    RETURN();
}

/* CP1 functions */
void op_cfc1 (void)
{
    if (T1 == 0) {
        T0 = env->fcr0;
    }
    else {
        /* fetch fcr31, masking unused bits */
        T0 = env->fcr31 & 0x0183FFFF;
    }
    DEBUG_FPU_STATE();
    RETURN();
}

/* convert MIPS rounding mode in FCR31 to IEEE library */
unsigned int ieee_rm[] = { 
    float_round_nearest_even,
    float_round_to_zero,
    float_round_up,
    float_round_down
};

#define RESTORE_ROUNDING_MODE \
    set_float_rounding_mode(ieee_rm[env->fcr31 & 3], &env->fp_status)

void op_ctc1 (void)
{
    if (T1 == 0) {
        /* XXX should this throw an exception?
         * don't write to FCR0.
         * env->fcr0 = T0; 
         */
    }
    else {
        /* store new fcr31, masking unused bits */  
        env->fcr31 = T0 & 0x0183FFFF;

        /* set rounding mode */
        RESTORE_ROUNDING_MODE;

#ifndef CONFIG_SOFTFLOAT
        /* no floating point exception for native float */
        SET_FP_ENABLE(env->fcr31, 0);
#endif
    }
    DEBUG_FPU_STATE();
    RETURN();
}

void op_mfc1 (void)
{
    T0 = WT0;
    DEBUG_FPU_STATE();
    RETURN();
}

void op_mtc1 (void)
{
    WT0 = T0;
    DEBUG_FPU_STATE();
    RETURN();
}

/* Float support.
   Single precition routines have a "s" suffix, double precision a
   "d" suffix.  */

#define FLOAT_OP(name, p) void OPPROTO op_float_##name##_##p(void)

1739 1740
FLOAT_OP(cvtd, s)
{
1741
    FDT2 = float32_to_float64(FST0, &env->fp_status);
1742 1743 1744
    DEBUG_FPU_STATE();
    RETURN();
}
B
bellard 已提交
1745 1746 1747 1748 1749 1750
FLOAT_OP(cvtd, w)
{
    FDT2 = int32_to_float64(WT0, &env->fp_status);
    DEBUG_FPU_STATE();
    RETURN();
}
1751 1752
FLOAT_OP(cvts, d)
{
P
pbrook 已提交
1753
    FST2 = float64_to_float32(FDT0, &env->fp_status);
1754 1755 1756
    DEBUG_FPU_STATE();
    RETURN();
}
B
bellard 已提交
1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930
FLOAT_OP(cvts, w)
{
    FST2 = int32_to_float32(WT0, &env->fp_status);
    DEBUG_FPU_STATE();
    RETURN();
}
FLOAT_OP(cvtw, s)
{
    WT2 = float32_to_int32(FST0, &env->fp_status);
    DEBUG_FPU_STATE();
    RETURN();
}
FLOAT_OP(cvtw, d)
{
    WT2 = float64_to_int32(FDT0, &env->fp_status);
    DEBUG_FPU_STATE();
    RETURN();
}

FLOAT_OP(roundw, d)
{
    set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
    WT2 = float64_round_to_int(FDT0, &env->fp_status);
    RESTORE_ROUNDING_MODE;

    DEBUG_FPU_STATE();
    RETURN();
}
FLOAT_OP(roundw, s)
{
    set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
    WT2 = float32_round_to_int(FST0, &env->fp_status);
    RESTORE_ROUNDING_MODE;
    DEBUG_FPU_STATE();
    RETURN();
}

FLOAT_OP(truncw, d)
{
    WT2 = float64_to_int32_round_to_zero(FDT0, &env->fp_status);
    DEBUG_FPU_STATE();
    RETURN();
}
FLOAT_OP(truncw, s)
{
    WT2 = float32_to_int32_round_to_zero(FST0, &env->fp_status);
    DEBUG_FPU_STATE();
    RETURN();
}

FLOAT_OP(ceilw, d)
{
    set_float_rounding_mode(float_round_up, &env->fp_status);
    WT2 = float64_round_to_int(FDT0, &env->fp_status);
    RESTORE_ROUNDING_MODE;

    DEBUG_FPU_STATE();
    RETURN();
}
FLOAT_OP(ceilw, s)
{
    set_float_rounding_mode(float_round_up, &env->fp_status);
    WT2 = float32_round_to_int(FST0, &env->fp_status);
    RESTORE_ROUNDING_MODE;
    DEBUG_FPU_STATE();
    RETURN();
}

FLOAT_OP(floorw, d)
{
    set_float_rounding_mode(float_round_down, &env->fp_status);
    WT2 = float64_round_to_int(FDT0, &env->fp_status);
    RESTORE_ROUNDING_MODE;

    DEBUG_FPU_STATE();
    RETURN();
}
FLOAT_OP(floorw, s)
{
    set_float_rounding_mode(float_round_down, &env->fp_status);
    WT2 = float32_round_to_int(FST0, &env->fp_status);
    RESTORE_ROUNDING_MODE;
    DEBUG_FPU_STATE();
    RETURN();
}

/* binary operations */
#define FLOAT_BINOP(name) \
FLOAT_OP(name, d)         \
{                         \
    FDT2 = float64_ ## name (FDT0, FDT1, &env->fp_status);    \
    DEBUG_FPU_STATE();    \
}                         \
FLOAT_OP(name, s)         \
{                         \
    FST2 = float32_ ## name (FST0, FST1, &env->fp_status);    \
    DEBUG_FPU_STATE();    \
}
FLOAT_BINOP(add)
FLOAT_BINOP(sub)
FLOAT_BINOP(mul)
FLOAT_BINOP(div)
#undef FLOAT_BINOP

/* unary operations, modifying fp status  */
#define FLOAT_UNOP(name)  \
FLOAT_OP(name, d)         \
{                         \
    FDT2 = float64_ ## name(FDT0, &env->fp_status);   \
    DEBUG_FPU_STATE();    \
}                         \
FLOAT_OP(name, s)         \
{                         \
    FST2 = float32_ ## name(FST0, &env->fp_status);   \
    DEBUG_FPU_STATE();    \
}
FLOAT_UNOP(sqrt)
#undef FLOAT_UNOP

/* unary operations, not modifying fp status  */
#define FLOAT_UNOP(name)  \
FLOAT_OP(name, d)         \
{                         \
    FDT2 = float64_ ## name(FDT0);   \
    DEBUG_FPU_STATE();    \
}                         \
FLOAT_OP(name, s)         \
{                         \
    FST2 = float32_ ## name(FST0);   \
    DEBUG_FPU_STATE();    \
}
FLOAT_UNOP(abs)
FLOAT_UNOP(chs)
#undef FLOAT_UNOP

FLOAT_OP(mov, d)
{
    FDT2 = FDT0;
    DEBUG_FPU_STATE();
    RETURN();
}
FLOAT_OP(mov, s)
{
    FST2 = FST0;
    DEBUG_FPU_STATE();
    RETURN();
}

#ifdef CONFIG_SOFTFLOAT
#define clear_invalid() do {                                \
    int flags = get_float_exception_flags(&env->fp_status); \
    flags &= ~float_flag_invalid;                           \
    set_float_exception_flags(flags, &env->fp_status);      \
} while(0)
#else
#define clear_invalid() do { } while(0)
#endif

extern void dump_fpu_s(CPUState *env);

#define FOP_COND(fmt, op, sig, cond)           \
void op_cmp_ ## fmt ## _ ## op (void)          \
{                                              \
    if (cond)                                  \
        SET_FP_COND(env->fcr31);               \
    else                                       \
        CLEAR_FP_COND(env->fcr31);             \
    if (!sig)                                  \
        clear_invalid();                       \
    /*CALL_FROM_TB1(dump_fpu_s, env);*/ \
    DEBUG_FPU_STATE();                         \
    RETURN();                                  \
}

B
bellard 已提交
1931
int float64_is_unordered(float64 a, float64 b STATUS_PARAM)
B
bellard 已提交
1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
{
    if (float64_is_nan(a) || float64_is_nan(b)) {
        float_raise(float_flag_invalid, status);
        return 1;
    }
    else {
        return 0;
    }
}

FOP_COND(d, f,   0,                                                      0) 
FOP_COND(d, un,  0, float64_is_unordered(FDT1, FDT0, &env->fp_status))
FOP_COND(d, eq,  0,                                                      float64_eq(FDT0, FDT1, &env->fp_status))
FOP_COND(d, ueq, 0, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_eq(FDT0, FDT1, &env->fp_status))
FOP_COND(d, olt, 0,                                                      float64_lt(FDT0, FDT1, &env->fp_status))
FOP_COND(d, ult, 0, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_lt(FDT0, FDT1, &env->fp_status))
FOP_COND(d, ole, 0,                                                      float64_le(FDT0, FDT1, &env->fp_status))
FOP_COND(d, ule, 0, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_le(FDT0, FDT1, &env->fp_status))
/* NOTE: the comma operator will make "cond" to eval to false,
 * but float*_is_unordered() is still called
 */
FOP_COND(d, sf,  1,                                                      (float64_is_unordered(FDT0, FDT1, &env->fp_status), 0))
FOP_COND(d, ngle,1, float64_is_unordered(FDT1, FDT0, &env->fp_status))
FOP_COND(d, seq, 1,                                                      float64_eq(FDT0, FDT1, &env->fp_status))
FOP_COND(d, ngl, 1, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_eq(FDT0, FDT1, &env->fp_status))
FOP_COND(d, lt,  1,                                                      float64_lt(FDT0, FDT1, &env->fp_status))
FOP_COND(d, nge, 1, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_lt(FDT0, FDT1, &env->fp_status))
FOP_COND(d, le,  1,                                                      float64_le(FDT0, FDT1, &env->fp_status))
FOP_COND(d, ngt, 1, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_le(FDT0, FDT1, &env->fp_status))

flag float32_is_unordered(float32 a, float32 b STATUS_PARAM)
{
    extern flag float32_is_nan( float32 a );
    if (float32_is_nan(a) || float32_is_nan(b)) {
        float_raise(float_flag_invalid, status);
        return 1;
    }
    else {
        return 0;
    }
}

/* NOTE: the comma operator will make "cond" to eval to false,
 * but float*_is_unordered() is still called
 */
FOP_COND(s, f,   0,                                                      0) 
FOP_COND(s, un,  0, float32_is_unordered(FST1, FST0, &env->fp_status))
FOP_COND(s, eq,  0,                                                      float32_eq(FST0, FST1, &env->fp_status))
FOP_COND(s, ueq, 0, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_eq(FST0, FST1, &env->fp_status))
FOP_COND(s, olt, 0,                                                      float32_lt(FST0, FST1, &env->fp_status))
FOP_COND(s, ult, 0, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_lt(FST0, FST1, &env->fp_status))
FOP_COND(s, ole, 0,                                                      float32_le(FST0, FST1, &env->fp_status))
FOP_COND(s, ule, 0, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_le(FST0, FST1, &env->fp_status))
/* NOTE: the comma operator will make "cond" to eval to false,
 * but float*_is_unordered() is still called
 */
FOP_COND(s, sf,  1,                                                      (float32_is_unordered(FST0, FST1, &env->fp_status), 0))
FOP_COND(s, ngle,1, float32_is_unordered(FST1, FST0, &env->fp_status))
FOP_COND(s, seq, 1,                                                      float32_eq(FST0, FST1, &env->fp_status))
FOP_COND(s, ngl, 1, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_eq(FST0, FST1, &env->fp_status))
FOP_COND(s, lt,  1,                                                      float32_lt(FST0, FST1, &env->fp_status))
FOP_COND(s, nge, 1, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_lt(FST0, FST1, &env->fp_status))
FOP_COND(s, le,  1,                                                      float32_le(FST0, FST1, &env->fp_status))
FOP_COND(s, ngt, 1, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_le(FST0, FST1, &env->fp_status))

void op_bc1f (void)
{
    T0 = ! IS_FP_COND_SET(env->fcr31);
    DEBUG_FPU_STATE();
    RETURN();
}

void op_bc1t (void)
{
    T0 = IS_FP_COND_SET(env->fcr31);
    DEBUG_FPU_STATE();
    RETURN();
}

B
bellard 已提交
2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037
#if defined(MIPS_USES_R4K_TLB)
void op_tlbwi (void)
{
    CALL_FROM_TB0(do_tlbwi);
    RETURN();
}

void op_tlbwr (void)
{
    CALL_FROM_TB0(do_tlbwr);
    RETURN();
}

void op_tlbp (void)
{
    CALL_FROM_TB0(do_tlbp);
    RETURN();
}

void op_tlbr (void)
{
    CALL_FROM_TB0(do_tlbr);
    RETURN();
}
#endif

/* Specials */
2038 2039 2040 2041 2042 2043 2044
#if defined (CONFIG_USER_ONLY)
void op_tls_value (void)
{
  T0 = env->tls_value;
}
#endif

B
bellard 已提交
2045 2046 2047
void op_pmon (void)
{
    CALL_FROM_TB1(do_pmon, PARAM1);
2048 2049 2050 2051 2052 2053
    RETURN();
}

void op_di (void)
{
    T0 = env->CP0_Status;
2054 2055
    env->CP0_Status = T0 & ~(1 << CP0St_IE);
    CALL_FROM_TB1(cpu_mips_update_irq, env);
2056 2057 2058 2059 2060 2061
    RETURN();
}

void op_ei (void)
{
    T0 = env->CP0_Status;
2062 2063
    env->CP0_Status = T0 | (1 << CP0St_IE);
    CALL_FROM_TB1(cpu_mips_update_irq, env);
2064
    RETURN();
B
bellard 已提交
2065 2066 2067 2068 2069
}

void op_trap (void)
{
    if (T0) {
2070
        CALL_FROM_TB1(do_raise_exception, EXCP_TRAP);
B
bellard 已提交
2071 2072 2073 2074
    }
    RETURN();
}

B
bellard 已提交
2075 2076
void op_debug (void)
{
2077 2078
    CALL_FROM_TB1(do_raise_exception, EXCP_DEBUG);
    RETURN();
B
bellard 已提交
2079 2080
}

B
bellard 已提交
2081 2082 2083
void op_set_lladdr (void)
{
    env->CP0_LLAddr = T2;
2084
    RETURN();
B
bellard 已提交
2085 2086
}

2087 2088
void debug_pre_eret (void);
void debug_post_eret (void);
B
bellard 已提交
2089 2090
void op_eret (void)
{
2091 2092
    if (loglevel & CPU_LOG_EXEC)
        CALL_FROM_TB0(debug_pre_eret);
T
ths 已提交
2093
    if (env->CP0_Status & (1 << CP0St_ERL)) {
B
bellard 已提交
2094
        env->PC = env->CP0_ErrorEPC;
T
ths 已提交
2095
        env->CP0_Status &= ~(1 << CP0St_ERL);
B
bellard 已提交
2096
    } else {
B
bellard 已提交
2097
        env->PC = env->CP0_EPC;
T
ths 已提交
2098
        env->CP0_Status &= ~(1 << CP0St_EXL);
B
bellard 已提交
2099
    }
T
ths 已提交
2100 2101 2102 2103 2104
    if (!(env->CP0_Status & (1 << CP0St_EXL)) &&
        !(env->CP0_Status & (1 << CP0St_ERL)) &&
        !(env->hflags & MIPS_HFLAG_DM) &&
        (env->CP0_Status & (1 << CP0St_UM)))
        env->hflags |= MIPS_HFLAG_UM;
2105 2106
    if (loglevel & CPU_LOG_EXEC)
        CALL_FROM_TB0(debug_post_eret);
B
bellard 已提交
2107
    env->CP0_LLAddr = 1;
2108
    RETURN();
B
bellard 已提交
2109 2110 2111 2112
}

void op_deret (void)
{
2113 2114
    if (loglevel & CPU_LOG_EXEC)
        CALL_FROM_TB0(debug_pre_eret);
B
bellard 已提交
2115
    env->PC = env->CP0_DEPC;
T
ths 已提交
2116 2117 2118 2119 2120 2121
    env->hflags |= MIPS_HFLAG_DM;
    if (!(env->CP0_Status & (1 << CP0St_EXL)) &&
        !(env->CP0_Status & (1 << CP0St_ERL)) &&
        !(env->hflags & MIPS_HFLAG_DM) &&
        (env->CP0_Status & (1 << CP0St_UM)))
        env->hflags |= MIPS_HFLAG_UM;
2122 2123
    if (loglevel & CPU_LOG_EXEC)
        CALL_FROM_TB0(debug_post_eret);
T
ths 已提交
2124
    env->CP0_LLAddr = 1;
2125 2126 2127 2128 2129
    RETURN();
}

void op_rdhwr_cpunum(void)
{
2130
    if (!(env->hflags & MIPS_HFLAG_UM) ||
2131
        (env->CP0_HWREna & (1 << 0)) ||
2132 2133
        (env->CP0_Status & (1 << CP0St_CU0)))
        T0 = env->CP0_EBase & 0x3ff;
2134
    else
2135
        CALL_FROM_TB1(do_raise_exception, EXCP_RI);
2136 2137 2138 2139 2140
    RETURN();
}

void op_rdhwr_synci_step(void)
{
2141
    if (!(env->hflags & MIPS_HFLAG_UM) ||
2142
        (env->CP0_HWREna & (1 << 1)) ||
2143 2144
        (env->CP0_Status & (1 << CP0St_CU0)))
        T0 = env->SYNCI_Step;
2145
    else
2146
        CALL_FROM_TB1(do_raise_exception, EXCP_RI);
2147 2148 2149 2150 2151
    RETURN();
}

void op_rdhwr_cc(void)
{
2152
    if (!(env->hflags & MIPS_HFLAG_UM) ||
2153
        (env->CP0_HWREna & (1 << 2)) ||
2154 2155
        (env->CP0_Status & (1 << CP0St_CU0)))
        T0 = env->CP0_Count;
2156
    else
2157
        CALL_FROM_TB1(do_raise_exception, EXCP_RI);
2158 2159 2160 2161 2162
    RETURN();
}

void op_rdhwr_ccres(void)
{
2163
    if (!(env->hflags & MIPS_HFLAG_UM) ||
2164
        (env->CP0_HWREna & (1 << 3)) ||
2165 2166
        (env->CP0_Status & (1 << CP0St_CU0)))
        T0 = env->CCRes;
2167
    else
2168 2169 2170 2171
        CALL_FROM_TB1(do_raise_exception, EXCP_RI);
    RETURN();
}

B
bellard 已提交
2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198
void op_save_state (void)
{
    env->hflags = PARAM1;
    RETURN();
}

void op_save_pc (void)
{
    env->PC = PARAM1;
    RETURN();
}

void op_raise_exception (void)
{
    CALL_FROM_TB1(do_raise_exception, PARAM1);
    RETURN();
}

void op_raise_exception_err (void)
{
    CALL_FROM_TB2(do_raise_exception_err, PARAM1, PARAM2);
    RETURN();
}

void op_exit_tb (void)
{
    EXIT_TB();
2199
    RETURN();
B
bellard 已提交
2200 2201
}

B
bellard 已提交
2202 2203 2204 2205
void op_wait (void)
{
    env->halted = 1;
    CALL_FROM_TB1(do_raise_exception, EXCP_HLT);
2206 2207 2208 2209 2210 2211 2212 2213 2214
    RETURN();
}

/* Bitfield operations. */
void op_ext(void)
{
    unsigned int pos = PARAM1;
    unsigned int size = PARAM2;

T
ths 已提交
2215
    T0 = ((uint32_t)T1 >> pos) & ((size < 32) ? ((1 << size) - 1) : ~0);
2216 2217 2218 2219 2220 2221 2222
    RETURN();
}

void op_ins(void)
{
    unsigned int pos = PARAM1;
    unsigned int size = PARAM2;
T
ths 已提交
2223
    target_ulong mask = ((size < 32) ? ((1 << size) - 1) : ~0) << pos;
2224

2225
    T0 = (T2 & ~mask) | (((uint32_t)T1 << pos) & mask);
2226 2227 2228 2229 2230 2231 2232 2233 2234
    RETURN();
}

void op_wsbh(void)
{
    T0 = ((T1 << 8) & ~0x00FF00FF) | ((T1 >> 8) & 0x00FF00FF);
    RETURN();
}

T
ths 已提交
2235
#ifdef TARGET_MIPS64
2236 2237 2238 2239 2240
void op_dext(void)
{
    unsigned int pos = PARAM1;
    unsigned int size = PARAM2;

T
ths 已提交
2241
    T0 = (T1 >> pos) & ((size < 32) ? ((1 << size) - 1) : ~0);
2242 2243 2244 2245 2246 2247 2248
    RETURN();
}

void op_dins(void)
{
    unsigned int pos = PARAM1;
    unsigned int size = PARAM2;
T
ths 已提交
2249
    target_ulong mask = ((size < 32) ? ((1 << size) - 1) : ~0) << pos;
2250 2251 2252 2253 2254

    T0 = (T2 & ~mask) | ((T1 << pos) & mask);
    RETURN();
}

2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265
void op_dsbh(void)
{
    T0 = ((T1 << 8) & ~0x00FF00FF00FF00FFULL) | ((T1 >> 8) & 0x00FF00FF00FF00FFULL);
    RETURN();
}

void op_dshd(void)
{
    T0 = ((T1 << 16) & ~0x0000FFFF0000FFFFULL) | ((T1 >> 16) & 0x0000FFFF0000FFFFULL);
    RETURN();
}
2266
#endif
2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277

void op_seb(void)
{
    T0 = ((T1 & 0xFF) ^ 0x80) - 0x80;
    RETURN();
}

void op_seh(void)
{
    T0 = ((T1 & 0xFFFF) ^ 0x8000) - 0x8000;
    RETURN();
B
bellard 已提交
2278
}