Tue Jan 17 12:08:43 2012 UTC ()
Add some space to the output.


(skrll)
diff -r1.13 -r1.14 src/sys/arch/hppa/hppa/db_disasm.c

cvs diff -r1.13 -r1.14 src/sys/arch/hppa/hppa/db_disasm.c (expand / switch to unified diff)

--- src/sys/arch/hppa/hppa/db_disasm.c 2012/01/16 09:01:35 1.13
+++ src/sys/arch/hppa/hppa/db_disasm.c 2012/01/17 12:08:43 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db_disasm.c,v 1.13 2012/01/16 09:01:35 skrll Exp $ */ 1/* $NetBSD: db_disasm.c,v 1.14 2012/01/17 12:08:43 skrll Exp $ */
2 2
3/* $OpenBSD: db_disasm.c,v 1.9 2000/04/18 20:02:45 mickey Exp $ */ 3/* $OpenBSD: db_disasm.c,v 1.9 2000/04/18 20:02:45 mickey Exp $ */
4 4
5/* 5/*
6 * Copyright (c) 1999,2005 Michael Shalayeff 6 * Copyright (c) 1999,2005 Michael Shalayeff
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Permission to use, copy, modify, and distribute this software for any 9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above 10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies. 11 * copyright notice and this permission notice appear in all copies.
12 * 12 *
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * the above copyright notice and this notice appears in all 28 * the above copyright notice and this notice appears in all
29 * copies, and that the name of Hewlett-Packard Company not be 29 * copies, and that the name of Hewlett-Packard Company not be
30 * used in advertising or publicity pertaining to distribution 30 * used in advertising or publicity pertaining to distribution
31 * of the software without specific, written prior permission. 31 * of the software without specific, written prior permission.
32 * Hewlett-Packard Company makes no representations about the 32 * Hewlett-Packard Company makes no representations about the
33 * suitability of this software for any purpose. 33 * suitability of this software for any purpose.
34 */ 34 */
35 35
36/* 36/*
37 * unasm.c -- HP_PA Instruction Printer 37 * unasm.c -- HP_PA Instruction Printer
38 */ 38 */
39 39
40#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.13 2012/01/16 09:01:35 skrll Exp $"); 41__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.14 2012/01/17 12:08:43 skrll Exp $");
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45 45
46#include <machine/db_machdep.h> 46#include <machine/db_machdep.h>
47#include <ddb/db_access.h> 47#include <ddb/db_access.h>
48#include <ddb/db_sym.h> 48#include <ddb/db_sym.h>
49#include <ddb/db_output.h> 49#include <ddb/db_output.h>
50#include <ddb/db_interface.h> 50#include <ddb/db_interface.h>
51 51
52 52
53/* IMPORTANT NOTE: 53/* IMPORTANT NOTE:
54 * All modules using this header may assume that the datatype "int" is a 54 * All modules using this header may assume that the datatype "int" is a
@@ -1286,123 +1286,123 @@ iExInit(void) @@ -1286,123 +1286,123 @@ iExInit(void)
1286 1286
1287 1287
1288 1288
1289/*##################### Functions and Subroutines ##########################*/ 1289/*##################### Functions and Subroutines ##########################*/
1290 1290
1291/**************************************/ 1291/**************************************/
1292/* Miscellaneous Disassembly Routines */ 1292/* Miscellaneous Disassembly Routines */
1293/**************************************/ 1293/**************************************/
1294 1294
1295/* Add instructions */ 1295/* Add instructions */
1296int 1296int
1297addDasm(const struct inst *i, OFS ofs, union insn w) 1297addDasm(const struct inst *i, OFS ofs, union insn w)
1298{ 1298{
1299 db_printf("%s\t%%r%d,%%r%d,%%r%d",addDCond(Cond4(w)), 1299 db_printf("%s\t%%r%d, %%r%d, %%r%d",addDCond(Cond4(w)),
1300 Rsa(w),Rsb(w),Rtc(w)); 1300 Rsa(w),Rsb(w),Rtc(w));
1301 return (1); 1301 return (1);
1302} 1302}
1303 1303
1304/* Unit instructions */ 1304/* Unit instructions */
1305int 1305int
1306unitDasm(const struct inst *i, OFS ofs, union insn w) 1306unitDasm(const struct inst *i, OFS ofs, union insn w)
1307{ 1307{
1308 db_printf(unitDCond(Cond4(w))); 1308 db_printf(unitDCond(Cond4(w)));
1309 if (Match("dcor") || Match("idcor")) 1309 if (Match("dcor") || Match("idcor"))
1310 db_printf("\t%%r%d,%%r%d",Rsb(w),Rtc(w)); 1310 db_printf("\t%%r%d, %%r%d",Rsb(w),Rtc(w));
1311 else 1311 else
1312 db_printf("\t%%r%d,%%r%d,%%r%d",Rsa(w),Rsb(w),Rtc(w)); 1312 db_printf("\t%%r%d, %%r%d, %%r%d",Rsa(w),Rsb(w),Rtc(w));
1313 return (1); 1313 return (1);
1314} 1314}
1315 1315
1316/* Immediate Arithmetic instructions */ 1316/* Immediate Arithmetic instructions */
1317int 1317int
1318iaDasm(const struct inst *i, OFS ofs, union insn w) 1318iaDasm(const struct inst *i, OFS ofs, union insn w)
1319{ 1319{
1320 if (Match("addi")) 1320 if (Match("addi"))
1321 db_printf("%s\t%d,%%r%d,%%r%d", 1321 db_printf("%s\t%d, %%r%d, %%r%d",
1322 addDCond(Cond4(w)),Im11(w),Rsb(w),Rta(w)); 1322 addDCond(Cond4(w)),Im11(w),Rsb(w),Rta(w));
1323 else 1323 else
1324 db_printf("%s\t%d,%%r%d,%%r%d", 1324 db_printf("%s\t%d, %%r%d, %%r%d",
1325 subDCond(Cond4(w)),Im11(w),Rsb(w),Rta(w)); 1325 subDCond(Cond4(w)),Im11(w),Rsb(w),Rta(w));
1326 return (1); 1326 return (1);
1327} 1327}
1328 1328
1329/* Shift double instructions */ 1329/* Shift double instructions */
1330int 1330int
1331shdDasm(const struct inst *i, OFS ofs, union insn w) 1331shdDasm(const struct inst *i, OFS ofs, union insn w)
1332{ 1332{
1333 if (Match("vshd")) 1333 if (Match("vshd"))
1334 db_printf("%s\t%%r%d,%%r%d,%%r%d", 1334 db_printf("%s\t%%r%d, %%r%d, %%r%d",
1335 edDCond(Cond(w)), Rsa(w),Rsb(w),Rtc(w)); 1335 edDCond(Cond(w)), Rsa(w),Rsb(w),Rtc(w));
1336 else 1336 else
1337 db_printf("%s\t%%r%d,%%r%d,%d,%%r%d", 1337 db_printf("%s\t%%r%d, %%r%d, %d, %%r%d",
1338 edDCond(Cond(w)),Rsa(w),Rsb(w),31-Imd5(w),Rtc(w)); 1338 edDCond(Cond(w)),Rsa(w),Rsb(w),31-Imd5(w),Rtc(w));
1339 return (1); 1339 return (1);
1340} 1340}
1341 1341
1342/* Extract instructions */ 1342/* Extract instructions */
1343int 1343int
1344extrDasm(const struct inst *i, OFS ofs, union insn w) 1344extrDasm(const struct inst *i, OFS ofs, union insn w)
1345{ 1345{
1346 db_printf("%s\t%%r%d,%d,%d,%%r%d", 1346 db_printf("%s\t%%r%d, %d, %d, %%r%d",
1347 edDCond(Cond(w)),Rsb(w),Imd5(w),32 - Rsc(w),Rta(w)); 1347 edDCond(Cond(w)),Rsb(w),Imd5(w),32 - Rsc(w),Rta(w));
1348 return (1); 1348 return (1);
1349} 1349}
1350 1350
1351 1351
1352/* Variable extract instructions */ 1352/* Variable extract instructions */
1353int 1353int
1354vextrDasm(const struct inst *i, OFS ofs, union insn w) 1354vextrDasm(const struct inst *i, OFS ofs, union insn w)
1355{ 1355{
1356 db_printf("%s\t%%r%d,%d,%%r%d", 1356 db_printf("%s\t%%r%d, %d, %%r%d",
1357 edDCond(Cond(w)),Rsb(w),32 - Rsc(w),Rta(w)); 1357 edDCond(Cond(w)),Rsb(w),32 - Rsc(w),Rta(w));
1358 return (1); 1358 return (1);
1359} 1359}
1360 1360
1361 1361
1362/* Deposit instructions */ 1362/* Deposit instructions */
1363int 1363int
1364depDasm(const struct inst *i, OFS ofs, union insn w) 1364depDasm(const struct inst *i, OFS ofs, union insn w)
1365{ 1365{
1366 db_printf("%s\t%%r%d,%d,%d,%%r%d", 1366 db_printf("%s\t%%r%d, %d, %d, %%r%d",
1367 edDCond(Cond(w)),Rsa(w),31 - Imd5(w),32 - Rsc(w),Rtb(w)); 1367 edDCond(Cond(w)),Rsa(w),31 - Imd5(w),32 - Rsc(w),Rtb(w));
1368 return (1); 1368 return (1);
1369} 1369}
1370 1370
1371 1371
1372/* Variable deposit instructions */ 1372/* Variable deposit instructions */
1373int 1373int
1374vdepDasm(const struct inst *i, OFS ofs, union insn w) 1374vdepDasm(const struct inst *i, OFS ofs, union insn w)
1375{ 1375{
1376 db_printf("%s\t%%r%d,%d,%%r%d", 1376 db_printf("%s\t%%r%d, %d, %%r%d",
1377 edDCond(Cond(w)),Rsa(w),32 - Rsc(w),Rtb(w)); 1377 edDCond(Cond(w)),Rsa(w),32 - Rsc(w),Rtb(w));
1378 return (1); 1378 return (1);
1379} 1379}
1380 1380
1381 1381
1382/* Deposit Immediate instructions */ 1382/* Deposit Immediate instructions */
1383int 1383int
1384depiDasm(const struct inst *i, OFS ofs, union insn w) 1384depiDasm(const struct inst *i, OFS ofs, union insn w)
1385{ 1385{
1386 db_printf("%s\t%d,%d,%d,%%r%d", 1386 db_printf("%s\t%d, %d, %d, %%r%d",
1387 edDCond(Cond(w)),Ima5(w),31 - Imd5(w),32 - Imc5A(w),Rtb(w)); 1387 edDCond(Cond(w)),Ima5(w),31 - Imd5(w),32 - Imc5A(w),Rtb(w));
1388 return (1); 1388 return (1);
1389} 1389}
1390 1390
1391/* Variable Deposit Immediate instructions */ 1391/* Variable Deposit Immediate instructions */
1392int 1392int
1393vdepiDasm(const struct inst *i, OFS ofs, union insn w) 1393vdepiDasm(const struct inst *i, OFS ofs, union insn w)
1394{ 1394{
1395 db_printf("%s\t%d,%d,%%r%d",edDCond(Cond(w)),Ima5(w),32-Imc5A(w),Rtb(w)); 1395 db_printf("%s\t%d, %d, %%r%d",edDCond(Cond(w)),Ima5(w),32-Imc5A(w),Rtb(w));
1396 return (1); 1396 return (1);
1397} 1397}
1398 1398
1399/*--------------------------------------------------------------------------- 1399/*---------------------------------------------------------------------------
1400 * conditionType$DisassembleCondition - Return a string which contains the 1400 * conditionType$DisassembleCondition - Return a string which contains the
1401 * ascii description of the passed numeric condition. 1401 * ascii description of the passed numeric condition.
1402 *---------------------------------------------------------------------------*/ 1402 *---------------------------------------------------------------------------*/
1403 1403
1404const char * 1404const char *
1405subDCond(u_int cond) 1405subDCond(u_int cond)
1406{ 1406{
1407 switch(cond) { 1407 switch(cond) {
1408 case EQZ: return(",="); 1408 case EQZ: return(",=");
@@ -1507,57 +1507,57 @@ int @@ -1507,57 +1507,57 @@ int
1507ldDasm(const struct inst *i, OFS ofs, union insn w) 1507ldDasm(const struct inst *i, OFS ofs, union insn w)
1508{ 1508{
1509 int d = Disp(w); 1509 int d = Disp(w);
1510 char s[2]; 1510 char s[2];
1511 1511
1512 s[1] = '\0'; 1512 s[1] = '\0';
1513 if (d < 0) { 1513 if (d < 0) {
1514 d = -d; 1514 d = -d;
1515 s[0] = '-'; 1515 s[0] = '-';
1516 } else 1516 } else
1517 s[0] = '\0'; 1517 s[0] = '\0';
1518 1518
1519 if (Rsb(w) == 0 && Match("ldo")) { 1519 if (Rsb(w) == 0 && Match("ldo")) {
1520 db_printf("ldi\t%s%X,%%r%d",s,d,Rta(w)); 1520 db_printf("ldi\t%s%X, %%r%d",s,d,Rta(w));
1521 return (1); 1521 return (1);
1522 } 1522 }
1523 db_printf("%s\t%s%s%X",i->mnem,(d < 2048? "R'":""), s, d); 1523 db_printf("%s\t%s%s%X",i->mnem,(d < 2048? "R'":""), s, d);
1524 if (Dss(w)) 1524 if (Dss(w))
1525 db_printf("(%%sr%d,%%r%d),%%r%d",Dss(w),Rsb(w),Rta(w)); 1525 db_printf("(%%sr%d, %%r%d), %%r%d",Dss(w),Rsb(w),Rta(w));
1526 else 1526 else
1527 db_printf("(%%r%d),%%r%d",Rsb(w),Rta(w)); 1527 db_printf("(%%r%d), %%r%d",Rsb(w),Rta(w));
1528 return (1); 1528 return (1);
1529} 1529}
1530 1530
1531/* Store [modify] instructions */ 1531/* Store [modify] instructions */
1532int 1532int
1533stDasm(const struct inst *i, OFS ofs, union insn w) 1533stDasm(const struct inst *i, OFS ofs, union insn w)
1534{ 1534{
1535 int d = Disp(w); 1535 int d = Disp(w);
1536 char s[2]; 1536 char s[2];
1537 1537
1538 db_printf("\t%%r%d,",Rta(w)); 1538 db_printf("\t%%r%d, ",Rta(w));
1539 1539
1540 s[1] = '\0'; 1540 s[1] = '\0';
1541 if (d < 0) { 1541 if (d < 0) {
1542 d = -d; 1542 d = -d;
1543 s[0] = '-'; 1543 s[0] = '-';
1544 } else 1544 } else
1545 s[0] = '\0'; 1545 s[0] = '\0';
1546 1546
1547 db_printf("%s%s%X", (d < 2048? "R'":""), s, d); 1547 db_printf("%s%s%X", (d < 2048? "R'":""), s, d);
1548 1548
1549 if (Dss(w)) 1549 if (Dss(w))
1550 db_printf("(%%sr%d,%%r%d)",Dss(w),Rsb(w)); 1550 db_printf("(%%sr%d, %%r%d)",Dss(w),Rsb(w));
1551 else 1551 else
1552 db_printf("(%%r%d)",Rsb(w)); 1552 db_printf("(%%r%d)",Rsb(w));
1553 return (1); 1553 return (1);
1554} 1554}
1555 1555
1556/* Load indexed instructions */ 1556/* Load indexed instructions */
1557int 1557int
1558ldxDasm(const struct inst *i, OFS ofs, union insn w) 1558ldxDasm(const struct inst *i, OFS ofs, union insn w)
1559{ 1559{
1560 const char *p; 1560 const char *p;
1561 1561
1562 if (ShortDisp(w)) { 1562 if (ShortDisp(w)) {
1563 db_printf("s"); 1563 db_printf("s");
@@ -1571,115 +1571,115 @@ ldxDasm(const struct inst *i, OFS ofs, u @@ -1571,115 +1571,115 @@ ldxDasm(const struct inst *i, OFS ofs, u
1571 switch (CacheCtrl(w)) { 1571 switch (CacheCtrl(w)) {
1572 default: 1572 default:
1573 case NOACTION: p = ""; break; 1573 case NOACTION: p = ""; break;
1574 case STACKREF: p = ",c"; break; 1574 case STACKREF: p = ",c"; break;
1575 case SEQPASS: p = ",q"; break; 1575 case SEQPASS: p = ",q"; break;
1576 case PREFETCH: p = ",p"; break; 1576 case PREFETCH: p = ",p"; break;
1577 } 1577 }
1578 if (ShortDisp(w)) 1578 if (ShortDisp(w))
1579 db_printf("%s\t%d", p, Ima5(w)); 1579 db_printf("%s\t%d", p, Ima5(w));
1580 else 1580 else
1581 db_printf("%s\t%%r%d", p, Rsa(w)); 1581 db_printf("%s\t%%r%d", p, Rsa(w));
1582 1582
1583 if (Dss(w)) 1583 if (Dss(w))
1584 db_printf("(%%sr%d,%%r%d),%%r%d",Dss(w),Rsb(w),Rtc(w)); 1584 db_printf("(%%sr%d, %%r%d), %%r%d",Dss(w),Rsb(w),Rtc(w));
1585 else 1585 else
1586 db_printf("(%%r%d),%%r%d",Rsb(w),Rtc(w)); 1586 db_printf("(%%r%d), %%r%d",Rsb(w),Rtc(w));
1587 return (1); 1587 return (1);
1588} 1588}
1589 1589
1590/* Store short displacement instructions */ 1590/* Store short displacement instructions */
1591int 1591int
1592stsDasm(const struct inst *i, OFS ofs, union insn w) 1592stsDasm(const struct inst *i, OFS ofs, union insn w)
1593{ 1593{
1594 const char *p; 1594 const char *p;
1595 1595
1596 if (Modify(w)) 1596 if (Modify(w))
1597 db_printf(",m%s", ModBefore(w)? "b":"a"); 1597 db_printf(",m%s", ModBefore(w)? "b":"a");
1598 1598
1599 switch (CacheCtrl(w)) { 1599 switch (CacheCtrl(w)) {
1600 default: 1600 default:
1601 case NOACTION: p = ""; break; 1601 case NOACTION: p = ""; break;
1602 case STACKREF: p = ",c"; break; 1602 case STACKREF: p = ",c"; break;
1603 case SEQPASS: p = ",q"; break; 1603 case SEQPASS: p = ",q"; break;
1604 case PREFETCH: p = ",p"; break; 1604 case PREFETCH: p = ",p"; break;
1605 } 1605 }
1606 db_printf("%s\t%%r%d,", p, Rta(w)); 1606 db_printf("%s\t%%r%d, ", p, Rta(w));
1607 if (Dss(w)) 1607 if (Dss(w))
1608 db_printf("%d(%%sr%d,%%r%d)",Imc5(w),Dss(w),Rsb(w)); 1608 db_printf("%d(%%sr%d, %%r%d)",Imc5(w),Dss(w),Rsb(w));
1609 else 1609 else
1610 db_printf("%d(%%r%d)",Imc5(w),Rsb(w)); 1610 db_printf("%d(%%r%d)",Imc5(w),Rsb(w));
1611 return (1); 1611 return (1);
1612} 1612}
1613 1613
1614/* Store Bytes Instruction */ 1614/* Store Bytes Instruction */
1615int 1615int
1616stbysDasm(const struct inst *i, OFS ofs, union insn w) 1616stbysDasm(const struct inst *i, OFS ofs, union insn w)
1617{ 1617{
1618 const char *p; 1618 const char *p;
1619 1619
1620 db_printf(ModBefore(w)? ",e":",b"); 1620 db_printf(ModBefore(w)? ",e":",b");
1621 if (Modify(w)) 1621 if (Modify(w))
1622 db_printf(",m"); 1622 db_printf(",m");
1623 switch (CacheCtrl(w)) { 1623 switch (CacheCtrl(w)) {
1624 default: 1624 default:
1625 case NOACTION: p = ""; break; 1625 case NOACTION: p = ""; break;
1626 case STACKREF: p = ",f"; break; 1626 case STACKREF: p = ",f"; break;
1627 case SEQPASS: p = ",r"; break; 1627 case SEQPASS: p = ",r"; break;
1628 case PREFETCH: p = ",z"; break; 1628 case PREFETCH: p = ",z"; break;
1629 } 1629 }
1630 db_printf("%s\t%%r%d,", p, Rta(w)); 1630 db_printf("%s\t%%r%d, ", p, Rta(w));
1631 if (Dss(w)) 1631 if (Dss(w))
1632 db_printf("%d(%%sr%d,%%r%d)",Imc5(w),Dss(w),Rsb(w)); 1632 db_printf("%d(%%sr%d, %%r%d)",Imc5(w),Dss(w),Rsb(w));
1633 else 1633 else
1634 db_printf("%d(%%r%d)",Imc5(w),Rsb(w)); 1634 db_printf("%d(%%r%d)",Imc5(w),Rsb(w));
1635 return (1); 1635 return (1);
1636} 1636}
1637 1637
1638/* Long Immediate instructions */ 1638/* Long Immediate instructions */
1639int 1639int
1640limmDasm(const struct inst *i, OFS ofs, union insn w) 1640limmDasm(const struct inst *i, OFS ofs, union insn w)
1641{ 1641{
1642 db_printf("\tL'%X,%%r%d", Im21(w), Rtb(w)); 1642 db_printf("\tL'%X, %%r%d", Im21(w), Rtb(w));
1643 return (1); 1643 return (1);
1644} 1644}
1645 1645
1646 1646
1647/* Branch and Link instruction(s) (Branch, too!!) */ 1647/* Branch and Link instruction(s) (Branch, too!!) */
1648int 1648int
1649blDasm(const struct inst *i, OFS ofs, union insn w) 1649blDasm(const struct inst *i, OFS ofs, union insn w)
1650{ 1650{
1651 OFS tgtofs = ofs + 8 + Bdisp(w); 1651 OFS tgtofs = ofs + 8 + Bdisp(w);
1652 u_int link = Rtb(w); 1652 u_int link = Rtb(w);
1653 1653
1654 if (link && !Match("gate")) 1654 if (link && !Match("gate"))
1655 db_printf("l"); 1655 db_printf("l");
1656 if (Nu(w)) 1656 if (Nu(w))
1657 db_printf(",n"); 1657 db_printf(",n");
1658 db_printf("\t"); 1658 db_printf("\t");
1659 1659
1660 db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf); 1660 db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf);
1661 1661
1662 if (link || Match("gate")) 1662 if (link || Match("gate"))
1663 db_printf(",%%r%d",link); 1663 db_printf(", %%r%d",link);
1664 1664
1665 return (1); 1665 return (1);
1666} 1666}
1667 1667
1668/* Branch Register instruction */ 1668/* Branch Register instruction */
1669int 1669int
1670brDasm(const struct inst *i, OFS ofs, union insn w) 1670brDasm(const struct inst *i, OFS ofs, union insn w)
1671{ 1671{
1672 db_printf("%s\t%%r%d,%%r%d", Nu(w)?",n":"", Rsa(w), Rtb(w)); 1672 db_printf("%s\t%%r%d, %%r%d", Nu(w)?",n":"", Rsa(w), Rtb(w));
1673 return (1); 1673 return (1);
1674} 1674}
1675 1675
1676/* Dispatch instructions */ 1676/* Dispatch instructions */
1677int 1677int
1678bvDasm(const struct inst *i, OFS ofs, union insn w) 1678bvDasm(const struct inst *i, OFS ofs, union insn w)
1679{ 1679{
1680 db_printf("%s\t%%r%d(%%r%d)", Nu(w)?",n":"", Rsa(w), Rsb(w)); 1680 db_printf("%s\t%%r%d(%%r%d)", Nu(w)?",n":"", Rsa(w), Rsb(w));
1681 return (1); 1681 return (1);
1682} 1682}
1683 1683
1684/* Branch External instructions */ 1684/* Branch External instructions */
1685int 1685int
@@ -1687,191 +1687,191 @@ beDasm(const struct inst *i, OFS ofs, un @@ -1687,191 +1687,191 @@ beDasm(const struct inst *i, OFS ofs, un
1687{ 1687{
1688 int d = Bdisp(w); 1688 int d = Bdisp(w);
1689 const char *p; 1689 const char *p;
1690 char s[2]; 1690 char s[2];
1691 1691
1692 s[1] = '\0'; 1692 s[1] = '\0';
1693 if (d < 0) { 1693 if (d < 0) {
1694 d = -d; 1694 d = -d;
1695 s[0] = '-'; 1695 s[0] = '-';
1696 } else 1696 } else
1697 s[0] = '\0'; 1697 s[0] = '\0';
1698 1698
1699 p = Nu(w)? ",n":""; 1699 p = Nu(w)? ",n":"";
1700 db_printf("%s\tR'%s%X(%%sr%d,%%r%d)", p, 1700 db_printf("%s\tR'%s%X(%%sr%d, %%r%d)", p,
1701 s, d, Sr(w), Rsb(w)); 1701 s, d, Sr(w), Rsb(w));
1702 return (1); 1702 return (1);
1703} 1703}
1704 1704
1705 1705
1706/* Compare/Add and Branch instructions */ 1706/* Compare/Add and Branch instructions */
1707int 1707int
1708cbDasm(const struct inst *i, OFS ofs, union insn w) 1708cbDasm(const struct inst *i, OFS ofs, union insn w)
1709{ 1709{
1710 OFS tgtofs = ofs + 8 + Cbdisp(w); 1710 OFS tgtofs = ofs + 8 + Cbdisp(w);
1711 1711
1712 if (Match("movb")) 1712 if (Match("movb"))
1713 db_printf(edDCond(Cond(w))); 1713 db_printf(edDCond(Cond(w)));
1714 else if (Match("addb")) 1714 else if (Match("addb"))
1715 db_printf(addDCond(Cond(w) << 1)); 1715 db_printf(addDCond(Cond(w) << 1));
1716 else 1716 else
1717 db_printf(subDCond(Cond(w) << 1)); 1717 db_printf(subDCond(Cond(w) << 1));
1718 db_printf("%s\t%%r%d,%%r%d,", Nu(w)?",n":"", Rsa(w), Rsb(w)); 1718 db_printf("%s\t%%r%d, %%r%d,", Nu(w)?",n":"", Rsa(w), Rsb(w));
1719 db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf); 1719 db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf);
1720 return (1); 1720 return (1);
1721} 1721}
1722 1722
1723/* Compare/Add and Branch Immediate instructions */ 1723/* Compare/Add and Branch Immediate instructions */
1724int 1724int
1725cbiDasm(const struct inst *i, OFS ofs, union insn w) 1725cbiDasm(const struct inst *i, OFS ofs, union insn w)
1726{ 1726{
1727 OFS tgtofs = ofs + 8 + Cbdisp(w); 1727 OFS tgtofs = ofs + 8 + Cbdisp(w);
1728 1728
1729 if (Match("movib")) 1729 if (Match("movib"))
1730 db_printf(edDCond(Cond(w))); 1730 db_printf(edDCond(Cond(w)));
1731 else if (Match("addib")) 1731 else if (Match("addib"))
1732 db_printf(addDCond(Cond(w) << 1)); 1732 db_printf(addDCond(Cond(w) << 1));
1733 else 1733 else
1734 db_printf(subDCond(Cond(w) << 1)); 1734 db_printf(subDCond(Cond(w) << 1));
1735 db_printf("%s\t%d,%%r%d,", Nu(w)? ",n":"", Ima5(w), Rsb(w)); 1735 db_printf("%s\t%d, %%r%d, ", Nu(w)? ",n":"", Ima5(w), Rsb(w));
1736 db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf); 1736 db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf);
1737 return (1); 1737 return (1);
1738} 1738}
1739 1739
1740/* Branch on Bit instructions */ 1740/* Branch on Bit instructions */
1741int 1741int
1742bbDasm(const struct inst *i, OFS ofs, union insn w) 1742bbDasm(const struct inst *i, OFS ofs, union insn w)
1743{ 1743{
1744 OFS tgtofs = ofs + 8 + Cbdisp(w); 1744 OFS tgtofs = ofs + 8 + Cbdisp(w);
1745 const char *p; 1745 const char *p;
1746 1746
1747 db_printf(edDCond(Cond(w))); 1747 db_printf(edDCond(Cond(w)));
1748 p = Nu(w)? ",n":""; 1748 p = Nu(w)? ",n":"";
1749 if (Match("bvb")) 1749 if (Match("bvb"))
1750 db_printf("%s\t%%r%d,", p, Rta(w)); 1750 db_printf("%s\t%%r%d, ", p, Rta(w));
1751 else 1751 else
1752 db_printf("%s\t%%r%d,%d,", p, Rsa(w), Imb5(w)); 1752 db_printf("%s\t%%r%d, %d, ", p, Rsa(w), Imb5(w));
1753 db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf); 1753 db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf);
1754 return (1); 1754 return (1);
1755} 1755}
1756 1756
1757/* Arithmetic instructions */ 1757/* Arithmetic instructions */
1758int 1758int
1759ariDasm(const struct inst *i, OFS ofs, union insn w) 1759ariDasm(const struct inst *i, OFS ofs, union insn w)
1760{ 1760{
1761 if (Match("or") && Rsb(w) == 0 && Cond4(w) == NEV) { 1761 if (Match("or") && Rsb(w) == 0 && Cond4(w) == NEV) {
1762 if (Rsa(w) == 0 && Rtc(w) == 0) 1762 if (Rsa(w) == 0 && Rtc(w) == 0)
1763 db_printf("nop"); 1763 db_printf("nop");
1764 else 1764 else
1765 db_printf("copy\t%%r%d,%%r%d",Rsa(w),Rtc(w)); 1765 db_printf("copy\t%%r%d, %%r%d",Rsa(w),Rtc(w));
1766 } else 1766 } else
1767 db_printf("%s%s\t%%r%d,%%r%d,%%r%d", i->mnem, 1767 db_printf("%s%s\t%%r%d, %%r%d, %%r%d", i->mnem,
1768 subDCond(Cond4(w)), Rsa(w),Rsb(w),Rtc(w)); 1768 subDCond(Cond4(w)), Rsa(w),Rsb(w),Rtc(w));
1769 return(1); 1769 return(1);
1770} 1770}
1771 1771
1772/* System control operations */ 1772/* System control operations */
1773int 1773int
1774scDasm(const struct inst *i, OFS ofs, union insn w) 1774scDasm(const struct inst *i, OFS ofs, union insn w)
1775{ 1775{
1776 if (Match("mtctl")) { 1776 if (Match("mtctl")) {
1777 if (Rtb(w) == 11) 1777 if (Rtb(w) == 11)
1778 db_printf("mtsar\t%%r%d",Rsa(w)); 1778 db_printf("mtsar\t%%r%d",Rsa(w));
1779 else 1779 else
1780 db_printf("mtctl\t%%r%d,%%cr%d",Rsa(w),Rtb(w)); 1780 db_printf("mtctl\t%%r%d, %%cr%d",Rsa(w),Rtb(w));
1781 return (1); 1781 return (1);
1782 } 1782 }
1783 db_printf(i->mnem); 1783 db_printf(i->mnem);
1784 if (Match("ssm") || Match("rsm")) 1784 if (Match("ssm") || Match("rsm"))
1785 db_printf("\t%d,%%r%d",Ima5A(w),Rtc(w)); 1785 db_printf("\t%d, %%r%d",Ima5A(w),Rtc(w));
1786 else if (Match("mtsm")) db_printf("\t%%r%d",Rsa(w)); 1786 else if (Match("mtsm")) db_printf("\t%%r%d",Rsa(w));
1787 else if (Match("ldprid")) db_printf("\t%%r%d",Rtc(w)); 1787 else if (Match("ldprid")) db_printf("\t%%r%d",Rtc(w));
1788 else if (Match("mtsp")) db_printf("\t%%r%d,%%sr%d",Rsa(w),Sr(w)); 1788 else if (Match("mtsp")) db_printf("\t%%r%d, %%sr%d",Rsa(w),Sr(w));
1789 else if (Match("mfsp")) db_printf("\t%%sr%d,%%r%d",Sr(w),Rtc(w)); 1789 else if (Match("mfsp")) db_printf("\t%%sr%d, %%r%d",Sr(w),Rtc(w));
1790 else if (Match("mfctl")) db_printf("\t%%cr%d,%%r%d",Rsb(w),Rtc(w)); 1790 else if (Match("mfctl")) db_printf("\t%%cr%d, %%r%d",Rsb(w),Rtc(w));
1791 else if (Match("ldsid")) { 1791 else if (Match("ldsid")) {
1792 if (Dss(w)) 1792 if (Dss(w))
1793 db_printf("\t(%%sr%d,%%r%d),%%r%d",Dss(w),Rsb(w),Rtc(w)); 1793 db_printf("\t(%%sr%d, %%r%d), %%r%d",Dss(w),Rsb(w),Rtc(w));
1794 else 1794 else
1795 db_printf("\t(%%r%d),%%r%d",Rsb(w),Rtc(w)); 1795 db_printf("\t(%%r%d), %%r%d",Rsb(w),Rtc(w));
1796 } else { 1796 } else {
1797 db_printf("?????"); 1797 db_printf("?????");
1798 return (0); 1798 return (0);
1799 } 1799 }
1800 return (1); 1800 return (1);
1801} 1801}
1802 1802
1803/* Instruction cache/tlb control instructions */ 1803/* Instruction cache/tlb control instructions */
1804int 1804int
1805mmgtDasm(const struct inst *i, OFS ofs, union insn w) 1805mmgtDasm(const struct inst *i, OFS ofs, union insn w)
1806{ 1806{
1807 if (Match("probe")) { 1807 if (Match("probe")) {
1808 if (ProbeI(w)) { 1808 if (ProbeI(w)) {
1809 if (Dss(w)) 1809 if (Dss(w))
1810 db_printf("i\t(%%sr%d,%%r%d),%d,%%r%d", 1810 db_printf("i\t(%%sr%d, %%r%d), %d, %%r%d",
1811 Dss(w),Rsb(w),Rsa(w),Rtc(w)); 1811 Dss(w),Rsb(w),Rsa(w),Rtc(w));
1812 else 1812 else
1813 db_printf("i\t(%%r%d),%d,%%r%d", 1813 db_printf("i\t(%%r%d), %d, %%r%d",
1814 Rsb(w),Rsa(w),Rtc(w)); 1814 Rsb(w),Rsa(w),Rtc(w));
1815 } else { 1815 } else {
1816 if (Dss(w)) 1816 if (Dss(w))
1817 db_printf("\t(%%sr%d,%%r%d),%%r%d,%%r%d", 1817 db_printf("\t(%%sr%d, %%r%d), %%r%d, %%r%d",
1818 Dss(w),Rsb(w),Rsa(w),Rtc(w)); 1818 Dss(w),Rsb(w),Rsa(w),Rtc(w));
1819 else 1819 else
1820 db_printf("\t(%%r%d),%%r%d,%%r%d", 1820 db_printf("\t(%%r%d), %%r%d, %%r%d",
1821 Rsb(w),Rsa(w),Rtc(w)); 1821 Rsb(w),Rsa(w),Rtc(w));
1822 } 1822 }
1823 } 1823 }
1824 else if (Match("lha") || Match("lpa")) { 1824 else if (Match("lha") || Match("lpa")) {
1825 if (Modify(w)) 1825 if (Modify(w))
1826 db_printf(",m"); 1826 db_printf(",m");
1827 if (Dss(w)) 1827 if (Dss(w))
1828 db_printf("\t%%r%d(%%sr%d,%%r%d),%%r%d", 1828 db_printf("\t%%r%d(%%sr%d, %%r%d), %%r%d",
1829 Rsa(w),Dss(w),Rsb(w),Rtc(w)); 1829 Rsa(w),Dss(w),Rsb(w),Rtc(w));
1830 else 1830 else
1831 db_printf("\t%%r%d(%%r%d),%%r%d",Rsa(w),Rsb(w),Rtc(w)); 1831 db_printf("\t%%r%d(%%r%d), %%r%d",Rsa(w),Rsb(w),Rtc(w));
1832 } 1832 }
1833 else if (Match("pdtlb") || Match("pdc") || Match("fdc")) { 1833 else if (Match("pdtlb") || Match("pdc") || Match("fdc")) {
1834 if (Modify(w)) db_printf(",m"); 1834 if (Modify(w)) db_printf(",m");
1835 if (Dss(w)) 1835 if (Dss(w))
1836 db_printf("\t%%r%d(%%sr%d,%%r%d)",Rsa(w),Dss(w),Rsb(w)); 1836 db_printf("\t%%r%d(%%sr%d, %%r%d)",Rsa(w),Dss(w),Rsb(w));
1837 else 1837 else
1838 db_printf("\t%%r%d(%%r%d)",Rsa(w),Rsb(w)); 1838 db_printf("\t%%r%d(%%r%d)",Rsa(w),Rsb(w));
1839 } 1839 }
1840 else if (Match("pitlb") || Match("fic")) { 1840 else if (Match("pitlb") || Match("fic")) {
1841 if (Modify(w)) 1841 if (Modify(w))
1842 db_printf(",m"); 1842 db_printf(",m");
1843 db_printf("\t%%r%d(%%sr%d,%%r%d)",Rsa(w),Sr(w),Rsb(w)); 1843 db_printf("\t%%r%d(%%sr%d, %%r%d)",Rsa(w),Sr(w),Rsb(w));
1844 } 1844 }
1845 else if (Match("idtlb")) { 1845 else if (Match("idtlb")) {
1846 if (Dss(w)) 1846 if (Dss(w))
1847 db_printf("\t%%r%d,(%%sr%d,%%r%d)",Rsa(w),Dss(w),Rsb(w)); 1847 db_printf("\t%%r%d, (%%sr%d, %%r%d)",Rsa(w),Dss(w),Rsb(w));
1848 else 1848 else
1849 db_printf("\t%%r%d,(%%r%d)",Rsa(w),Rsb(w)); 1849 db_printf("\t%%r%d, (%%r%d)",Rsa(w),Rsb(w));
1850 } 1850 }
1851 else if (Match("iitlb")) 1851 else if (Match("iitlb"))
1852 db_printf("\t%%r%d,(%%sr%d,%%r%d)",Rsa(w),Sr(w),Rsb(w)); 1852 db_printf("\t%%r%d, (%%sr%d, %%r%d)",Rsa(w),Sr(w),Rsb(w));
1853 else { 1853 else {
1854 db_printf("?????"); 1854 db_printf("?????");
1855 return (0); 1855 return (0);
1856 } 1856 }
1857 return(1); 1857 return(1);
1858} 1858}
1859 1859
1860/* break instruction */ 1860/* break instruction */
1861int 1861int
1862brkDasm(const struct inst *i, OFS ofs, union insn w) 1862brkDasm(const struct inst *i, OFS ofs, union insn w)
1863{ 1863{
1864 db_printf("\t%d,%d",Bi1(w),Bi2(w)); 1864 db_printf("\t%d, %d",Bi1(w),Bi2(w));
1865 return (1); 1865 return (1);
1866} 1866}
1867 1867
1868int 1868int
1869floatDasm(const struct inst *i, OFS ofs, union insn w) 1869floatDasm(const struct inst *i, OFS ofs, union insn w)
1870{ 1870{
1871 u_int op1, r1, fmt, t; 1871 u_int op1, r1, fmt, t;
1872 u_int op2, r2, dfmt; 1872 u_int op2, r2, dfmt;
1873 const char *p; 1873 const char *p;
1874 1874
1875 op1 = CoprExt1(w); 1875 op1 = CoprExt1(w);
1876 op2 = CoprExt2(w); 1876 op2 = CoprExt2(w);
1877 fmt = (op1 >> 2) & 3; /* get precision of source */ 1877 fmt = (op1 >> 2) & 3; /* get precision of source */
@@ -1894,88 +1894,88 @@ floatDasm(const struct inst *i, OFS ofs, @@ -1894,88 +1894,88 @@ floatDasm(const struct inst *i, OFS ofs,
1894 r2++; 1894 r2++;
1895 1895
1896 if ((op1 & 1) == 0) { /* class 2 */ 1896 if ((op1 & 1) == 0) { /* class 2 */
1897 /* Opclass 2: 2 sources, no destination */ 1897 /* Opclass 2: 2 sources, no destination */
1898 switch((op1 >> 4) & 7) { 1898 switch((op1 >> 4) & 7) {
1899 case 0: 1899 case 0:
1900 p = "cmp"; 1900 p = "cmp";
1901 break; 1901 break;
1902 default: 1902 default:
1903 db_printf(fcoprUndef); 1903 db_printf(fcoprUndef);
1904 return(0); 1904 return(0);
1905 } 1905 }
1906 db_printf("%s,%s",p,fmtStrTbl[fmt]); 1906 db_printf("%s,%s",p,fmtStrTbl[fmt]);
1907 db_printf(",%s\t%%f%s,%%f%s", 1907 db_printf(",%s\t%%f%s, %%f%s",
1908 condStrTbl[op2], ST(r1), ST(r2)); 1908 condStrTbl[op2], ST(r1), ST(r2));
1909 return (1); 1909 return (1);
1910 } 1910 }
1911 /* 1911 /*
1912 * get target register (class 3) 1912 * get target register (class 3)
1913 */ 1913 */
1914 t = (op2 << 1); 1914 t = (op2 << 1);
1915 if ((fmt & 1) == 0 && (Uid(w) & 1)) 1915 if ((fmt & 1) == 0 && (Uid(w) & 1))
1916 t++; 1916 t++;
1917 /* Opclass 3: 2 sources, 1 destination */ 1917 /* Opclass 3: 2 sources, 1 destination */
1918 switch((op1 >> 4) & 7) { 1918 switch((op1 >> 4) & 7) {
1919 case 0: p = "add"; break; 1919 case 0: p = "add"; break;
1920 case 1: p = "sub"; break; 1920 case 1: p = "sub"; break;
1921 case 2: p = (Fpi(w)) ? "mpyi" : "mpy"; break; 1921 case 2: p = (Fpi(w)) ? "mpyi" : "mpy"; break;
1922 case 3: p = "div"; break; 1922 case 3: p = "div"; break;
1923 case 4: p = "rem"; break; 1923 case 4: p = "rem"; break;
1924 default: db_printf(fcoprUndef); return (0); 1924 default: db_printf(fcoprUndef); return (0);
1925 } 1925 }
1926 db_printf("%s,%s", p, fmtStrTbl[fmt]); 1926 db_printf("%s,%s", p, fmtStrTbl[fmt]);
1927 db_printf("\t%%f%s,%%f%s,%%f%s",ST(r1),ST(r2),ST(t)); 1927 db_printf("\t%%f%s, %%f%s, %%f%s",ST(r1),ST(r2),ST(t));
1928 } else if (op1 & 1) { /* class 1 */ 1928 } else if (op1 & 1) { /* class 1 */
1929 dfmt = (op1 >> 4) & 3; 1929 dfmt = (op1 >> 4) & 3;
1930#define DT(r) ((dfmt & 1)? fdreg[(r)]:fsreg[(r)]) 1930#define DT(r) ((dfmt & 1)? fdreg[(r)]:fsreg[(r)])
1931 1931
1932 /* 1932 /*
1933 * get target register 1933 * get target register
1934 */ 1934 */
1935 t = (op2 << 1); 1935 t = (op2 << 1);
1936 if ((dfmt & 1) == 0 && (Uid(w) & 1)) 1936 if ((dfmt & 1) == 0 && (Uid(w) & 1))
1937 t++; 1937 t++;
1938 /* Opclass 1: 1 source, 1 destination conversions */ 1938 /* Opclass 1: 1 source, 1 destination conversions */
1939 p = &"ff\0\0xf\0\0fx\0\0fxt\0"[((op1) >> 4) & 0x0c]; 1939 p = &"ff\0\0xf\0\0fx\0\0fxt\0"[((op1) >> 4) & 0x0c];
1940#if 0 1940#if 0
1941 switch((op1 >> 6) & 3) { 1941 switch((op1 >> 6) & 3) {
1942 default: 1942 default:
1943 case 0: p = "ff"; break; 1943 case 0: p = "ff"; break;
1944 case 1: p = "xf"; break; 1944 case 1: p = "xf"; break;
1945 case 2: p = "fx"; break; 1945 case 2: p = "fx"; break;
1946 case 3: p = "fxt"; break; 1946 case 3: p = "fxt"; break;
1947 } 1947 }
1948#endif 1948#endif
1949 db_printf("%s,%s", p, fmtStrTbl[fmt]); 1949 db_printf("%s,%s", p, fmtStrTbl[fmt]);
1950 db_printf(",%s\t%%f%s,%%f%s",fmtStrTbl[dfmt],ST(r1),DT(t)); 1950 db_printf(",%s\t%%f%s, %%f%s",fmtStrTbl[dfmt],ST(r1),DT(t));
1951 } else { /* class 0 */ 1951 } else { /* class 0 */
1952 /* 1952 /*
1953 * get target register 1953 * get target register
1954 */ 1954 */
1955 t = (op2 << 1); 1955 t = (op2 << 1);
1956 if ((fmt & 1) == 0 && (Uid(w) & 1)) 1956 if ((fmt & 1) == 0 && (Uid(w) & 1))
1957 t++; 1957 t++;
1958 /* Opclass 0: 1 source, 1 destination */ 1958 /* Opclass 0: 1 source, 1 destination */
1959 switch((op1 >> 4) & 7) { 1959 switch((op1 >> 4) & 7) {
1960 case 1: p = "rsqrt"; break; 1960 case 1: p = "rsqrt"; break;
1961 case 2: p = "cpy"; break; 1961 case 2: p = "cpy"; break;
1962 case 3: p = "abs"; break; 1962 case 3: p = "abs"; break;
1963 case 4: p = "sqrt"; break; 1963 case 4: p = "sqrt"; break;
1964 case 5: p = "rnd"; break; 1964 case 5: p = "rnd"; break;
1965 default: db_printf(fcoprUndef); return (0); 1965 default: db_printf(fcoprUndef); return (0);
1966 } 1966 }
1967 db_printf("%s,%s",p,fmtStrTbl[fmt]); 1967 db_printf("%s,%s",p,fmtStrTbl[fmt]);
1968 db_printf("\t%%f%s,%%f%s",ST(r1),ST(t)); 1968 db_printf("\t%%f%s, %%f%s",ST(r1),ST(t));
1969 } 1969 }
1970 return (1); 1970 return (1);
1971} 1971}
1972 1972
1973int 1973int
1974fcoprDasm(union insn w, u_int op1, u_int op2) 1974fcoprDasm(union insn w, u_int op1, u_int op2)
1975{ 1975{
1976 u_int r1, r2, t, fmt, dfmt; 1976 u_int r1, r2, t, fmt, dfmt;
1977 const char *p; 1977 const char *p;
1978 1978
1979 if (AstNu(w) && op1 == ((1<<4) | 2)) { 1979 if (AstNu(w) && op1 == ((1<<4) | 2)) {
1980 if (op2 == 0 || op2 == 1 || op2 == 2) { 1980 if (op2 == 0 || op2 == 1 || op2 == 2) {
1981 db_printf("ftest"); 1981 db_printf("ftest");
@@ -1992,68 +1992,68 @@ fcoprDasm(union insn w, u_int op1, u_int @@ -1992,68 +1992,68 @@ fcoprDasm(union insn w, u_int op1, u_int
1992 } 1992 }
1993 switch(op1 & 3) { 1993 switch(op1 & 3) {
1994 case 0: 1994 case 0:
1995 /* Opclass 0: 1 source, 1 destination */ 1995 /* Opclass 0: 1 source, 1 destination */
1996 r1 = (op1 >> 12) & 0x1f; t = op2; fmt = (op1 >> 2) & 3; 1996 r1 = (op1 >> 12) & 0x1f; t = op2; fmt = (op1 >> 2) & 3;
1997 switch((op1 >> 4) & 7) { 1997 switch((op1 >> 4) & 7) {
1998 case 1: p = "rsqrt"; break; 1998 case 1: p = "rsqrt"; break;
1999 case 2: p = "cpy"; break; 1999 case 2: p = "cpy"; break;
2000 case 3: p = "abs"; break; 2000 case 3: p = "abs"; break;
2001 case 4: p = "sqrt"; break; 2001 case 4: p = "sqrt"; break;
2002 case 5: p = "rnd"; break; 2002 case 5: p = "rnd"; break;
2003 default: db_printf(fcoprUndef); return(0); 2003 default: db_printf(fcoprUndef); return(0);
2004 } 2004 }
2005 db_printf("f%s,%s\t%%fr%d,%%fr%d", p, fmtStrTbl[fmt], r1, t); 2005 db_printf("f%s,%s\t%%fr%d, %%fr%d", p, fmtStrTbl[fmt], r1, t);
2006 break; 2006 break;
2007 case 1: 2007 case 1:
2008 /* Opclass 1: 1 source, 1 destination conversions */ 2008 /* Opclass 1: 1 source, 1 destination conversions */
2009 r1 = (op1 >> 12) & 0x1f; t = op2; 2009 r1 = (op1 >> 12) & 0x1f; t = op2;
2010 fmt = (op1 >> 2) & 3; dfmt = (op1 >> 4) & 3; 2010 fmt = (op1 >> 2) & 3; dfmt = (op1 >> 4) & 3;
2011 p = &"ff\0\0xf\0\0fx\0\0fxt\0"[((op1) >> 4) & 0x0c]; 2011 p = &"ff\0\0xf\0\0fx\0\0fxt\0"[((op1) >> 4) & 0x0c];
2012#if 0 2012#if 0
2013 switch((op1 >> 6) & 3) { 2013 switch((op1 >> 6) & 3) {
2014 case 0: p = "ff"; break; 2014 case 0: p = "ff"; break;
2015 case 1: p = "xf"; break; 2015 case 1: p = "xf"; break;
2016 case 2: p = "fx"; break; 2016 case 2: p = "fx"; break;
2017 case 3: p = "fxt"; break; 2017 case 3: p = "fxt"; break;
2018 } 2018 }
2019#endif 2019#endif
2020 db_printf("fcnv%s,%s,%s\t%%fr%d,%%fr%d", 2020 db_printf("fcnv%s,%s,%s\t%%fr%d, %%fr%d",
2021 p, fmtStrTbl[fmt], fmtStrTbl[dfmt], r1, t); 2021 p, fmtStrTbl[fmt], fmtStrTbl[dfmt], r1, t);
2022 break; 2022 break;
2023 case 2: 2023 case 2:
2024 /* Opclass 2: 2 sources, no destination */ 2024 /* Opclass 2: 2 sources, no destination */
2025 r1 = (op1 >> 12) & 0x1f; r2 = (op1 >> 7) & 0x1f; 2025 r1 = (op1 >> 12) & 0x1f; r2 = (op1 >> 7) & 0x1f;
2026 fmt = (op1 >> 2) & 3; 2026 fmt = (op1 >> 2) & 3;
2027 switch((op1 >> 4) & 7) { 2027 switch((op1 >> 4) & 7) {
2028 case 0: p = "fcmp"; break; 2028 case 0: p = "fcmp"; break;
2029 default: db_printf(fcoprUndef); return (0); 2029 default: db_printf(fcoprUndef); return (0);
2030 } 2030 }
2031 db_printf("%s,%s,%s\t%%fr%d,%%fr%d", 2031 db_printf("%s,%s,%s\t%%fr%d, %%fr%d",
2032 p,fmtStrTbl[fmt],condStrTbl[op2],r1,r2); 2032 p,fmtStrTbl[fmt],condStrTbl[op2],r1,r2);
2033 break; 2033 break;
2034 case 3: 2034 case 3:
2035 /* Opclass 3: 2 sources, 1 destination */ 2035 /* Opclass 3: 2 sources, 1 destination */
2036 r1 = (op1 >> 12) & 0x1f; r2 = (op1 >> 7) & 0x1f; t = op2; 2036 r1 = (op1 >> 12) & 0x1f; r2 = (op1 >> 7) & 0x1f; t = op2;
2037 fmt = (op1 >> 2) & 3; 2037 fmt = (op1 >> 2) & 3;
2038 switch((op1 >> 4) & 7) { 2038 switch((op1 >> 4) & 7) {
2039 case 0: p = "add"; break; 2039 case 0: p = "add"; break;
2040 case 1: p = "sub"; break; 2040 case 1: p = "sub"; break;
2041 case 2: p = "mpy"; break; 2041 case 2: p = "mpy"; break;
2042 case 3: p = "div"; break; 2042 case 3: p = "div"; break;
2043 case 4: p = "rem"; break; 2043 case 4: p = "rem"; break;
2044 default: db_printf(fcoprUndef); return (0); 2044 default: db_printf(fcoprUndef); return (0);
2045 } 2045 }
2046 db_printf("f%s,%s\t%%fr%d,%%fr%d,%%fr%d", 2046 db_printf("f%s,%s\t%%fr%d, %%fr%d, %%fr%d",
2047 p, fmtStrTbl[fmt], r1, r2, t); 2047 p, fmtStrTbl[fmt], r1, r2, t);
2048 break; 2048 break;
2049 default: 2049 default:
2050 db_printf(fcoprUndef); 2050 db_printf(fcoprUndef);
2051 return(0); 2051 return(0);
2052 } 2052 }
2053 return (1); 2053 return (1);
2054} 2054}
2055 2055
2056int 2056int
2057coprDasm(const struct inst *i, OFS ofs, union insn w) 2057coprDasm(const struct inst *i, OFS ofs, union insn w)
2058{ 2058{
2059 u_int uid = Uid(w); 2059 u_int uid = Uid(w);
@@ -2107,43 +2107,43 @@ coprDasm(const struct inst *i, OFS ofs,  @@ -2107,43 +2107,43 @@ coprDasm(const struct inst *i, OFS ofs,
2107 if (load) { 2107 if (load) {
2108 const char *p; 2108 const char *p;
2109 2109
2110 if (dreg) 2110 if (dreg)
2111 p = fdreg[(Rtc(w)<<1)+(uid&1)]; 2111 p = fdreg[(Rtc(w)<<1)+(uid&1)];
2112 else 2112 else
2113 p = fsreg[(Rtc(w)<<1)+(uid&1)]; 2113 p = fsreg[(Rtc(w)<<1)+(uid&1)];
2114 2114
2115 if (ShortDisp(w)) 2115 if (ShortDisp(w))
2116 db_printf("\t%d",Ima5(w)); 2116 db_printf("\t%d",Ima5(w));
2117 else 2117 else
2118 db_printf("\t%%r%d",Rsa(w)); 2118 db_printf("\t%%r%d",Rsa(w));
2119 if (Dss(w)) 2119 if (Dss(w))
2120 db_printf("(%%sr%d,%%r%d),%%f%s", Dss(w),Rsb(w), p); 2120 db_printf("(%%sr%d, %%r%d), %%f%s", Dss(w),Rsb(w), p);
2121 else 2121 else
2122 db_printf("(%%r%d),%%f%s",Rsb(w), p); 2122 db_printf("(%%r%d), %%f%s",Rsb(w), p);
2123 } else { 2123 } else {
2124 const char *p; 2124 const char *p;
2125 2125
2126 if (dreg) 2126 if (dreg)
2127 p = fdreg[(Rsc(w)<<1)+(uid&1)]; 2127 p = fdreg[(Rsc(w)<<1)+(uid&1)];
2128 else 2128 else
2129 p = fsreg[(Rsc(w)<<1)+(uid&1)]; 2129 p = fsreg[(Rsc(w)<<1)+(uid&1)];
2130 2130
2131 if (ShortDisp(w)) 2131 if (ShortDisp(w))
2132 db_printf("\t%%f%s,%d", p, Ima5(w)); 2132 db_printf("\t%%f%s, %d", p, Ima5(w));
2133 else 2133 else
2134 db_printf("\t%%f%s,%%r%d", p, Rta(w)); 2134 db_printf("\t%%f%s, %%r%d", p, Rta(w));
2135 if (Dss(w)) 2135 if (Dss(w))
2136 db_printf("(%%sr%d,%%r%d)",Dss(w),Rsb(w)); 2136 db_printf("(%%sr%d, %%r%d)",Dss(w),Rsb(w));
2137 else 2137 else
2138 db_printf("(%%r%d)",Rsb(w)); 2138 db_printf("(%%r%d)",Rsb(w));
2139 } 2139 }
2140 return (1); 2140 return (1);
2141} 2141}
2142 2142
2143int 2143int
2144lpkDasm(const struct inst *i, OFS ofs, union insn w) 2144lpkDasm(const struct inst *i, OFS ofs, union insn w)
2145{ 2145{
2146 /* 2146 /*
2147 * Floating point STore Quad 2147 * Floating point STore Quad
2148 * Short or Indexed 2148 * Short or Indexed
2149 */ 2149 */
@@ -2153,84 +2153,84 @@ lpkDasm(const struct inst *i, OFS ofs, u @@ -2153,84 +2153,84 @@ lpkDasm(const struct inst *i, OFS ofs, u
2153 } else { 2153 } else {
2154 if (Modify(w)) 2154 if (Modify(w))
2155 db_printf(",%sm", IndxShft(w)? "s":""); 2155 db_printf(",%sm", IndxShft(w)? "s":"");
2156 else if (IndxShft(w)) 2156 else if (IndxShft(w))
2157 db_printf(",s"); 2157 db_printf(",s");
2158 } 2158 }
2159 switch (CacheCtrl(w)) { 2159 switch (CacheCtrl(w)) {
2160 case NOACTION: break; 2160 case NOACTION: break;
2161 case STACKREF: db_printf(",c"); break; 2161 case STACKREF: db_printf(",c"); break;
2162 case SEQPASS: db_printf(",q"); break; 2162 case SEQPASS: db_printf(",q"); break;
2163 case PREFETCH: db_printf(",p"); break; 2163 case PREFETCH: db_printf(",p"); break;
2164 } 2164 }
2165 if (ShortDisp(w)) 2165 if (ShortDisp(w))
2166 db_printf("\t%%fr%d,%d",Rsc(w),Ima5(w)); 2166 db_printf("\t%%fr%d, %d",Rsc(w),Ima5(w));
2167 else 2167 else
2168 db_printf("\t%%fr%d,%%r%d",Rsc(w),Rta(w)); 2168 db_printf("\t%%fr%d, %%r%d",Rsc(w),Rta(w));
2169 if (Dss(w)) 2169 if (Dss(w))
2170 db_printf("(%%sr%d,%%r%d)",Dss(w),Rsb(w)); 2170 db_printf("(%%sr%d, %%r%d)",Dss(w),Rsb(w));
2171 else 2171 else
2172 db_printf("(%%r%d)",Rsb(w)); 2172 db_printf("(%%r%d)",Rsb(w));
2173 return (1); 2173 return (1);
2174} 2174}
2175 2175
2176int 2176int
2177diagDasm(const struct inst *i, OFS ofs, union insn w) 2177diagDasm(const struct inst *i, OFS ofs, union insn w)
2178{ 2178{
2179 if (0x0b0 == BitfR(w,19,8,_b198)) /* mtcpu */ 2179 if (0x0b0 == BitfR(w,19,8,_b198)) /* mtcpu */
2180 db_printf("mtcpu\t%%r%d,%%dr%d", Rsa(w), Rtb(w)); 2180 db_printf("mtcpu\t%%r%d, %%dr%d", Rsa(w), Rtb(w));
2181 else if (0x0d0 == BitfR(w,19,8,_b198)) /* mfcpu */ 2181 else if (0x0d0 == BitfR(w,19,8,_b198)) /* mfcpu */
2182 db_printf("mfcpu\t%%dr%d,%%r%d", Rsb(w), Rta(w)); 2182 db_printf("mfcpu\t%%dr%d, %%r%d", Rsb(w), Rta(w));
2183 else { 2183 else {
2184 db_printf(i->mnem); 2184 db_printf(i->mnem);
2185 if (Match("diag")) 2185 if (Match("diag"))
2186 db_printf("\t0x%X",w.w & 0x03ffffff); 2186 db_printf("\t0x%X",w.w & 0x03ffffff);
2187 else { 2187 else {
2188 db_printf("?????"); 2188 db_printf("?????");
2189 return (0); 2189 return (0);
2190 } 2190 }
2191 } 2191 }
2192 return (1); 2192 return (1);
2193} 2193}
2194 2194
2195int 2195int
2196fmpysubDasm(const struct inst *i, OFS ofs, union insn w) 2196fmpysubDasm(const struct inst *i, OFS ofs, union insn w)
2197{ 2197{
2198 if (SinglePrec(w)) 2198 if (SinglePrec(w))
2199 db_printf("SUB,SGL\t%%f%s,%%f%s,%%f%s,%%f%s,%%f%s", 2199 db_printf("sub,sgl\t%%f%s, %%f%s, %%f%s, %%f%s, %%f%s",
2200 fsreg[Ms1(w)], fsreg[Ms2(w)], fsreg[Mt(w)], 2200 fsreg[Ms1(w)], fsreg[Ms2(w)], fsreg[Mt(w)],
2201 fsreg[As(w)], fsreg[Ad(w)]); 2201 fsreg[As(w)], fsreg[Ad(w)]);
2202 else 2202 else
2203 db_printf("SUB,DBL\t%%f%s,%%f%s,%%f%s,%%f%s,%%f%s", 2203 db_printf("sub,dbl\t%%f%s, %%f%s, %%f%s, %%f%s, %%f%s",
2204 fdreg[Ms1(w)], fdreg[Ms2(w)], fdreg[Mt(w)], 2204 fdreg[Ms1(w)], fdreg[Ms2(w)], fdreg[Mt(w)],
2205 fdreg[As(w)], fdreg[Ad(w)]); 2205 fdreg[As(w)], fdreg[Ad(w)]);
2206 return (1); 2206 return (1);
2207} 2207}
2208 2208
2209int 2209int
2210fmpyaddDasm(const struct inst *i, OFS ofs, union insn w) 2210fmpyaddDasm(const struct inst *i, OFS ofs, union insn w)
2211{ 2211{
2212 const char 2212 const char
2213 *ms1 = SinglePrec(w) ? fsreg[Ms1(w)] : fdreg[Ms1(w)], 2213 *ms1 = SinglePrec(w) ? fsreg[Ms1(w)] : fdreg[Ms1(w)],
2214 *ms2 = SinglePrec(w) ? fsreg[Ms2(w)] : fdreg[Ms2(w)], 2214 *ms2 = SinglePrec(w) ? fsreg[Ms2(w)] : fdreg[Ms2(w)],
2215 *mt = SinglePrec(w) ? fsreg[Mt(w)] : fdreg[Mt(w)], 2215 *mt = SinglePrec(w) ? fsreg[Mt(w)] : fdreg[Mt(w)],
2216 *as = SinglePrec(w) ? fsreg[As(w)] : fdreg[As(w)], 2216 *as = SinglePrec(w) ? fsreg[As(w)] : fdreg[As(w)],
2217 *ad = SinglePrec(w) ? fsreg[Ad(w)] : fdreg[Ad(w)]; 2217 *ad = SinglePrec(w) ? fsreg[Ad(w)] : fdreg[Ad(w)];
2218 2218
2219 if (Rsd(w) == 0) 2219 if (Rsd(w) == 0)
2220 db_printf("\t%%fcfxt,%s,%%f%s,%%f%s,%%f%s", 2220 db_printf("\t%%fcfxt, %s, %%f%s, %%f%s, %%f%s",
2221 ((SinglePrec(w)) ? "sgl" : "dbl"), ms1, ms2, mt); 2221 ((SinglePrec(w)) ? "sgl" : "dbl"), ms1, ms2, mt);
2222 else 2222 else
2223 db_printf("add%s\t%%f%s,%%f%s,%%f%s,%%f%s,%%f%s", 2223 db_printf("add%s\t%%f%s, %%f%s, %%f%s, %%f%s, %%f%s",
2224 ((SinglePrec(w)) ? "sgl" : "dbl"), ms1, ms2, mt, as, ad); 2224 ((SinglePrec(w)) ? "sgl" : "dbl"), ms1, ms2, mt, as, ad);
2225 2225
2226 return (1); 2226 return (1);
2227} 2227}
2228 2228
2229vaddr_t 2229vaddr_t
2230db_disasm(vaddr_t loc, bool flag) 2230db_disasm(vaddr_t loc, bool flag)
2231{ 2231{
2232 const struct inst *i; 2232 const struct inst *i;
2233 const struct majoropcode *m; 2233 const struct majoropcode *m;
2234 u_int ext; 2234 u_int ext;
2235 union insn instruct; 2235 union insn instruct;
2236 OFS ofs = 0; 2236 OFS ofs = 0;