Revision 5dc4b744 target-mips/op.c

b/target-mips/op.c
328 328
/* Arithmetic */
329 329
void op_add (void)
330 330
{
331
    T0 = SIGN_EXTEND32((int32_t)T0 + (int32_t)T1);
331
    T0 = (int32_t)((int32_t)T0 + (int32_t)T1);
332 332
    RETURN();
333 333
}
334 334

  
......
342 342
        /* operands of same sign, result different sign */
343 343
        CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
344 344
    }
345
    T0 = SIGN_EXTEND32(T0);
345
    T0 = (int32_t)T0;
346 346
    RETURN();
347 347
}
348 348

  
349 349
void op_sub (void)
350 350
{
351
    T0 = SIGN_EXTEND32((int32_t)T0 - (int32_t)T1);
351
    T0 = (int32_t)((int32_t)T0 - (int32_t)T1);
352 352
    RETURN();
353 353
}
354 354

  
......
362 362
        /* operands of different sign, first operand and result different sign */
363 363
        CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
364 364
    }
365
    T0 = SIGN_EXTEND32(T0);
365
    T0 = (int32_t)T0;
366 366
    RETURN();
367 367
}
368 368

  
369 369
void op_mul (void)
370 370
{
371
    T0 = SIGN_EXTEND32((int32_t)T0 * (int32_t)T1);
371
    T0 = (int32_t)((int32_t)T0 * (int32_t)T1);
372 372
    RETURN();
373 373
}
374 374

  
375 375
void op_div (void)
376 376
{
377 377
    if (T1 != 0) {
378
        env->LO = SIGN_EXTEND32((int32_t)T0 / (int32_t)T1);
379
        env->HI = SIGN_EXTEND32((int32_t)T0 % (int32_t)T1);
378
        env->LO = (int32_t)((int32_t)T0 / (int32_t)T1);
379
        env->HI = (int32_t)((int32_t)T0 % (int32_t)T1);
380 380
    }
381 381
    RETURN();
382 382
}
......
384 384
void op_divu (void)
385 385
{
386 386
    if (T1 != 0) {
387
        env->LO = SIGN_EXTEND32((uint32_t)T0 / (uint32_t)T1);
388
        env->HI = SIGN_EXTEND32((uint32_t)T0 % (uint32_t)T1);
387
        env->LO = (int32_t)((uint32_t)T0 / (uint32_t)T1);
388
        env->HI = (int32_t)((uint32_t)T0 % (uint32_t)T1);
389 389
    }
390 390
    RETURN();
391 391
}
......
497 497

  
498 498
void op_sll (void)
499 499
{
500
    T0 = SIGN_EXTEND32((uint32_t)T0 << (uint32_t)T1);
500
    T0 = (int32_t)((uint32_t)T0 << (uint32_t)T1);
501 501
    RETURN();
502 502
}
503 503

  
504 504
void op_sra (void)
505 505
{
506
    T0 = SIGN_EXTEND32((int32_t)T0 >> (uint32_t)T1);
506
    T0 = (int32_t)((int32_t)T0 >> (uint32_t)T1);
507 507
    RETURN();
508 508
}
509 509

  
510 510
void op_srl (void)
511 511
{
512
    T0 = SIGN_EXTEND32((uint32_t)T0 >> (uint32_t)T1);
512
    T0 = (int32_t)((uint32_t)T0 >> (uint32_t)T1);
513 513
    RETURN();
514 514
}
515 515

  
......
518 518
    target_ulong tmp;
519 519

  
520 520
    if (T1) {
521
       tmp = SIGN_EXTEND32((uint32_t)T0 << (0x20 - (uint32_t)T1));
522
       T0 = SIGN_EXTEND32((uint32_t)T0 >> (uint32_t)T1) | tmp;
521
       tmp = (int32_t)((uint32_t)T0 << (0x20 - (uint32_t)T1));
522
       T0 = (int32_t)((uint32_t)T0 >> (uint32_t)T1) | tmp;
523 523
    } else
524 524
       T0 = T1;
525 525
    RETURN();
......
527 527

  
528 528
void op_sllv (void)
529 529
{
530
    T0 = SIGN_EXTEND32((uint32_t)T1 << ((uint32_t)T0 & 0x1F));
530
    T0 = (int32_t)((uint32_t)T1 << ((uint32_t)T0 & 0x1F));
531 531
    RETURN();
532 532
}
533 533

  
534 534
void op_srav (void)
535 535
{
536
    T0 = SIGN_EXTEND32((int32_t)T1 >> (T0 & 0x1F));
536
    T0 = (int32_t)((int32_t)T1 >> (T0 & 0x1F));
537 537
    RETURN();
538 538
}
539 539

  
540 540
void op_srlv (void)
541 541
{
542
    T0 = SIGN_EXTEND32((uint32_t)T1 >> (T0 & 0x1F));
542
    T0 = (int32_t)((uint32_t)T1 >> (T0 & 0x1F));
543 543
    RETURN();
544 544
}
545 545

  
......
549 549

  
550 550
    T0 &= 0x1F;
551 551
    if (T0) {
552
       tmp = SIGN_EXTEND32((uint32_t)T1 << (0x20 - T0));
553
       T0 = SIGN_EXTEND32((uint32_t)T1 >> T0) | tmp;
552
       tmp = (int32_t)((uint32_t)T1 << (0x20 - T0));
553
       T0 = (int32_t)((uint32_t)T1 >> T0) | tmp;
554 554
    } else
555 555
       T0 = T1;
556 556
    RETURN();
......
842 842

  
843 843
static inline void set_HILO (uint64_t HILO)
844 844
{
845
    env->LO = SIGN_EXTEND32(HILO & 0xFFFFFFFF);
846
    env->HI = SIGN_EXTEND32(HILO >> 32);
845
    env->LO = (int32_t)(HILO & 0xFFFFFFFF);
846
    env->HI = (int32_t)(HILO >> 32);
847 847
}
848 848

  
849 849
void op_mult (void)
......
1032 1032
/* CP0 functions */
1033 1033
void op_mfc0_index (void)
1034 1034
{
1035
    T0 = SIGN_EXTEND32(env->CP0_index);
1035
    T0 = (int32_t)(env->CP0_index);
1036 1036
    RETURN();
1037 1037
}
1038 1038

  
......
1062 1062

  
1063 1063
void op_mfc0_pagemask (void)
1064 1064
{
1065
    T0 = SIGN_EXTEND32(env->CP0_PageMask);
1065
    T0 = (int32_t)env->CP0_PageMask;
1066 1066
    RETURN();
1067 1067
}
1068 1068

  
1069 1069
void op_mfc0_pagegrain (void)
1070 1070
{
1071
    T0 = SIGN_EXTEND32(env->CP0_PageGrain);
1071
    T0 = (int32_t)env->CP0_PageGrain;
1072 1072
    RETURN();
1073 1073
}
1074 1074

  
1075 1075
void op_mfc0_wired (void)
1076 1076
{
1077
    T0 = SIGN_EXTEND32(env->CP0_Wired);
1077
    T0 = (int32_t)env->CP0_Wired;
1078 1078
    RETURN();
1079 1079
}
1080 1080

  
1081 1081
void op_mfc0_hwrena (void)
1082 1082
{
1083
    T0 = SIGN_EXTEND32(env->CP0_HWREna);
1083
    T0 = (int32_t)env->CP0_HWREna;
1084 1084
    RETURN();
1085 1085
}
1086 1086

  
......
1104 1104

  
1105 1105
void op_mfc0_compare (void)
1106 1106
{
1107
    T0 = SIGN_EXTEND32(env->CP0_Compare);
1107
    T0 = (int32_t)env->CP0_Compare;
1108 1108
    RETURN();
1109 1109
}
1110 1110

  
1111 1111
void op_mfc0_status (void)
1112 1112
{
1113
    T0 = SIGN_EXTEND32(env->CP0_Status);
1113
    T0 = (int32_t)env->CP0_Status;
1114 1114
    if (env->hflags & MIPS_HFLAG_UM)
1115 1115
        T0 |= (1 << CP0St_UM);
1116 1116
    if (env->hflags & MIPS_HFLAG_ERL)
......
1122 1122

  
1123 1123
void op_mfc0_intctl (void)
1124 1124
{
1125
    T0 = SIGN_EXTEND32(env->CP0_IntCtl);
1125
    T0 = (int32_t)env->CP0_IntCtl;
1126 1126
    RETURN();
1127 1127
}
1128 1128

  
1129 1129
void op_mfc0_srsctl (void)
1130 1130
{
1131
    T0 = SIGN_EXTEND32(env->CP0_SRSCtl);
1131
    T0 = (int32_t)env->CP0_SRSCtl;
1132 1132
    RETURN();
1133 1133
}
1134 1134

  
1135 1135
void op_mfc0_cause (void)
1136 1136
{
1137
    T0 = SIGN_EXTEND32(env->CP0_Cause);
1137
    T0 = (int32_t)env->CP0_Cause;
1138 1138
    RETURN();
1139 1139
}
1140 1140

  
......
1146 1146

  
1147 1147
void op_mfc0_prid (void)
1148 1148
{
1149
    T0 = SIGN_EXTEND32(env->CP0_PRid);
1149
    T0 = (int32_t)env->CP0_PRid;
1150 1150
    RETURN();
1151 1151
}
1152 1152

  
......
1158 1158

  
1159 1159
void op_mfc0_config0 (void)
1160 1160
{
1161
    T0 = SIGN_EXTEND32(env->CP0_Config0);
1161
    T0 = (int32_t)env->CP0_Config0;
1162 1162
    RETURN();
1163 1163
}
1164 1164

  
1165 1165
void op_mfc0_config1 (void)
1166 1166
{
1167
    T0 = SIGN_EXTEND32(env->CP0_Config1);
1167
    T0 = (int32_t)env->CP0_Config1;
1168 1168
    RETURN();
1169 1169
}
1170 1170

  
1171 1171
void op_mfc0_config2 (void)
1172 1172
{
1173
    T0 = SIGN_EXTEND32(env->CP0_Config2);
1173
    T0 = (int32_t)env->CP0_Config2;
1174 1174
    RETURN();
1175 1175
}
1176 1176

  
1177 1177
void op_mfc0_config3 (void)
1178 1178
{
1179
    T0 = SIGN_EXTEND32(env->CP0_Config3);
1179
    T0 = (int32_t)env->CP0_Config3;
1180 1180
    RETURN();
1181 1181
}
1182 1182

  
......
1188 1188

  
1189 1189
void op_mfc0_watchlo0 (void)
1190 1190
{
1191
    T0 = SIGN_EXTEND32(env->CP0_WatchLo);
1191
    T0 = (int32_t)env->CP0_WatchLo;
1192 1192
    RETURN();
1193 1193
}
1194 1194

  
1195 1195
void op_mfc0_watchhi0 (void)
1196 1196
{
1197
    T0 = SIGN_EXTEND32(env->CP0_WatchHi);
1197
    T0 = (int32_t)env->CP0_WatchHi;
1198 1198
    RETURN();
1199 1199
}
1200 1200

  
......
1212 1212

  
1213 1213
void op_mfc0_debug (void)
1214 1214
{
1215
    T0 = SIGN_EXTEND32(env->CP0_Debug);
1215
    T0 = (int32_t)env->CP0_Debug;
1216 1216
    if (env->hflags & MIPS_HFLAG_DM)
1217 1217
        T0 |= 1 << CP0DB_DM;
1218 1218
    RETURN();
......
1226 1226

  
1227 1227
void op_mfc0_performance0 (void)
1228 1228
{
1229
    T0 = SIGN_EXTEND32(env->CP0_Performance0);
1229
    T0 = (int32_t)env->CP0_Performance0;
1230 1230
    RETURN();
1231 1231
}
1232 1232

  
1233 1233
void op_mfc0_taglo (void)
1234 1234
{
1235
    T0 = SIGN_EXTEND32(env->CP0_TagLo);
1235
    T0 = (int32_t)env->CP0_TagLo;
1236 1236
    RETURN();
1237 1237
}
1238 1238

  
1239 1239
void op_mfc0_datalo (void)
1240 1240
{
1241
    T0 = SIGN_EXTEND32(env->CP0_DataLo);
1241
    T0 = (int32_t)env->CP0_DataLo;
1242 1242
    RETURN();
1243 1243
}
1244 1244

  
1245 1245
void op_mfc0_taghi (void)
1246 1246
{
1247
    T0 = SIGN_EXTEND32(env->CP0_TagHi);
1247
    T0 = (int32_t)env->CP0_TagHi;
1248 1248
    RETURN();
1249 1249
}
1250 1250

  
1251 1251
void op_mfc0_datahi (void)
1252 1252
{
1253
    T0 = SIGN_EXTEND32(env->CP0_DataHi);
1253
    T0 = (int32_t)env->CP0_DataHi;
1254 1254
    RETURN();
1255 1255
}
1256 1256

  
......
1262 1262

  
1263 1263
void op_mfc0_desave (void)
1264 1264
{
1265
    T0 = SIGN_EXTEND32(env->CP0_DESAVE);
1265
    T0 = (int32_t)env->CP0_DESAVE;
1266 1266
    RETURN();
1267 1267
}
1268 1268

  
......
1276 1276
{
1277 1277
    /* Large physaddr not implemented */
1278 1278
    /* 1k pages not implemented */
1279
    env->CP0_EntryLo0 = T0 & SIGN_EXTEND32(0x3FFFFFFFUL);
1279
    env->CP0_EntryLo0 = T0 & (int32_t)0x3FFFFFFF;
1280 1280
    RETURN();
1281 1281
}
1282 1282

  
......
1284 1284
{
1285 1285
    /* Large physaddr not implemented */
1286 1286
    /* 1k pages not implemented */
1287
    env->CP0_EntryLo1 = T0 & SIGN_EXTEND32(0x3FFFFFFFUL);
1287
    env->CP0_EntryLo1 = T0 & (int32_t)0x3FFFFFFF;
1288 1288
    RETURN();
1289 1289
}
1290 1290

  
......
1334 1334

  
1335 1335
    /* 1k pages not implemented */
1336 1336
    /* Ignore MIPS64 TLB for now */
1337
    val = T0 & SIGN_EXTEND32(0xFFFFE0FF);
1337
    val = T0 & (int32_t)0xFFFFE0FF;
1338 1338
    old = env->CP0_EntryHi;
1339 1339
    env->CP0_EntryHi = val;
1340 1340
    /* If the ASID changes, flush qemu's TLB.  */
......
1353 1353
{
1354 1354
    uint32_t val, old, mask;
1355 1355

  
1356
    val = T0 & SIGN_EXTEND32(0xFA78FF01);
1356
    val = T0 & (int32_t)0xFA78FF01;
1357 1357
    old = env->CP0_Status;
1358 1358
    if (T0 & (1 << CP0St_UM))
1359 1359
        env->hflags |= MIPS_HFLAG_UM;
......
1431 1431
{
1432 1432
    /* vectored interrupts not implemented */
1433 1433
    /* Multi-CPU not implemented */
1434
    env->CP0_EBase = SIGN_EXTEND32(0x80000000) | (T0 & 0x3FFFF000);
1434
    env->CP0_EBase = (int32_t)0x80000000 | (T0 & 0x3FFFF000);
1435 1435
    RETURN();
1436 1436
}
1437 1437

  
......
1501 1501

  
1502 1502
void op_mtc0_taglo (void)
1503 1503
{
1504
    env->CP0_TagLo = T0 & SIGN_EXTEND32(0xFFFFFCF6);
1504
    env->CP0_TagLo = T0 & (int32_t)0xFFFFFCF6;
1505 1505
    RETURN();
1506 1506
}
1507 1507

  

Also available in: Unified diff