1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 143 144 145 146 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 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 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 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 459 460 461 462 463 464 465 466 467 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 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 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 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 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 709 710 711 712 713 714 715 716 717 718 719 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 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 828 829 830 831 832 833 834 835 836 837 838 839 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 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 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 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 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 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 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 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769
|
static char _[] = " @(#)asm.c 5.23 93/10/26 10:17:03, Srini, AMD";
/******************************************************************************
* Copyright 1991 Advanced Micro Devices, Inc.
*
* This software is the property of Advanced Micro Devices, Inc (AMD) which
* specifically grants the user the right to modify, use and distribute this
* software provided this notice is not removed or altered. All other rights
* are reserved by AMD.
*
* AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
* SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
* DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
* USE OF THIS SOFTWARE.
*
* So that all may benefit from your experience, please report any problems
* or suggestions about this software to the 29K Technical Support Center at
* 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
* 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
*
* Advanced Micro Devices, Inc.
* 29K Support Products
* Mail Stop 573
* 5900 E. Ben White Blvd.
* Austin, TX 78741
* 800-292-9263
*****************************************************************************
* Engineer: Srini Subramanian.
*****************************************************************************
* This module supports the assemble command to assemble 29K instructions
* in memory.
*****************************************************************************
*/
#include <stdio.h>
#include "opcodes.h"
#include "memspcs.h"
#include "main.h"
#include "monitor.h"
#include "macros.h"
#include "miniint.h"
#include "error.h"
#ifdef MSDOS
#include <string.h>
#define strcasecmp stricmp
#else
#include <string.h>
#endif
/*
** There are approximately 23 different instruction formats for the
** Am29000. Instructions are assembled using one of these formats.
**
** Note: Opcodes in the "switch" statement are sorted in numerical
** order.
**
*/
int get_addr_29k_m PARAMS((char *, struct addr_29k_t *, INT32));
int addr_29k_ok PARAMS((struct addr_29k_t *));
void convert32 PARAMS((BYTE *));
int set_data PARAMS((BYTE *, BYTE *, int));
int asm_instr PARAMS((struct instr_t *, char **, int));
int asm_arith_logic PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_load_store PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_vector PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_no_parms PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_one_parms PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_float PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_call_jmp PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_calli_jmpi PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_class PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_clz PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_const PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_consth PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_convert PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_div0 PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_exhws PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_jmp PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_jmpi PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_mfsr PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_mtsr PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_mtsrim PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_mftlb PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_mttlb PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_sqrt PARAMS((struct instr_t *, struct addr_29k_t *, int));
int asm_emulate PARAMS((struct instr_t *, struct addr_29k_t *, int));
extern void Mini_poll_kbd PARAMS((char *cmd_buffer, int size, int mode));
extern int Mini_cmdfile_input PARAMS((char *cmd_buffer, int size));
extern int tokenize_cmd PARAMS((char *, char **));
extern void lcase_tokens PARAMS((char **, int));
extern INT32 do_assemble PARAMS(( struct addr_29k_t addr_29k,
char *token[],
int token_count));
#ifndef XRAY
extern char cmd_buffer[];
#define MAX_ASM_TOKENS 15
static char *asm_token[MAX_ASM_TOKENS];
static int asm_token_count;
/*
** This function is used to assemble an instruction. The command
** takes as parameters an array of strings (*token[]) and a
** count (token_count) which gives the number of tokens in the
** array. These tokens should have the following values:
**
** token[0] - 'a' (the assemble command)
** token[1] - <address> (the address to assemble instruction at)
** token[2] - <opcode> (the 29K opcode nmemonic)
** token[3] to token[n] - parameters to the assembly instruction.
**
*/
INT32
asm_cmd(token, token_count)
char *token[];
int token_count;
{
INT32 result;
struct addr_29k_t addr_29k;
int asm_done;
/*
** Parse parameters
*/
if ((token_count < 2) || (token_count > 9)) {
return (EMSYNTAX);
} else if (token_count == 2) {
/* Get address of assembly */
result = get_addr_29k_m(token[1], &addr_29k, I_MEM);
if (result != 0)
return (result);
result = addr_29k_ok(&addr_29k);
if (result != 0)
return (result);
asm_done = 0;
fprintf(stderr, "0x%08lx:\t", addr_29k.address);
do {
if (io_config.cmd_file_io == TRUE) {
if (Mini_cmdfile_input(cmd_buffer, BUFFER_SIZE) == SUCCESS) {
fprintf(stderr, "%s", cmd_buffer);
} else {
Mini_poll_kbd(cmd_buffer, BUFFER_SIZE, BLOCK); /* block */
}
} else {
Mini_poll_kbd(cmd_buffer, BUFFER_SIZE, BLOCK); /* block */
}
if (io_config.log_file) /* make a log file */
#ifdef MSDOS
fprintf(io_config.log_file, "%s\n", cmd_buffer);
#else
fprintf(io_config.log_file, "%s", cmd_buffer);
#endif
if (io_config.echo_mode == (INT32) TRUE)
#ifdef MSDOS
fprintf(io_config.echo_file, "%s\n", cmd_buffer);
#else
fprintf(io_config.echo_file, "%s", cmd_buffer);
#endif
asm_token_count = tokenize_cmd(cmd_buffer, asm_token);
lcase_tokens(asm_token, asm_token_count);
if (strcmp(token[0], ".") == 0)
asm_done = 1;
else {
result= do_assemble(addr_29k, &asm_token[0], asm_token_count);
if (result != SUCCESS)
warning (result);
else
addr_29k.address = addr_29k.address + 4;
fprintf(stderr, "0x%08lx:\t", addr_29k.address);
}
} while (asm_done != 1);
} else {
/* Get address of assembly */
result = get_addr_29k_m(token[1], &addr_29k, I_MEM);
if (result != 0)
return (result);
result = addr_29k_ok(&addr_29k);
if (result != 0)
return (result);
return (do_assemble(addr_29k, &token[2], (token_count-2)));
}
return (SUCCESS);
}
INT32
do_assemble(addr_29k, token, token_count)
struct addr_29k_t addr_29k;
char *token[];
int token_count;
{
INT32 result;
struct instr_t instr;
INT32 retval;
BYTE *write_data;
INT32 bytes_ret;
INT32 hostendian; /* for UDI conformant */
/* Initialize instr */
instr.op = 0;
instr.c = 0;
instr.a = 0;
instr.b = 0;
/* Assemble instruction */
result = asm_instr(&instr, &(token[0]), token_count);
if (result != 0)
return (EMSYNTAX);
/* Will the data overflow the message buffer? done in TIP */
write_data = (BYTE *) &instr;
hostendian = FALSE;
if ((retval = Mini_write_req (addr_29k.memory_space,
addr_29k.address,
1, /* count */
(INT16) sizeof(INST32), /* size */
&bytes_ret,
write_data,
hostendian)) != SUCCESS) {
return(FAILURE);
};
return (SUCCESS);
}
#endif
/*
** This function is used to assemble a single Am29000 instruction.
** The token[] array contains the lower-case tokens for a single
** assembler instruction. The token_count contains the number of
** tokens in the array. This number should be at least 1 (as in the
** cases of instructions like IRET) and at most 5 (for instructions
** like LOAD).
*/
#ifdef XRAY
extern struct t_inst_table {
char *inst_mnem;
unsigned char oprn_fmt;
} inst_table[];
#endif
int
asm_instr(instr, token, token_count)
struct instr_t *instr;
char *token[];
int token_count;
{
int i;
int result;
struct addr_29k_t parm[10];
char temp_opcode[20];
char *temp_ptr;
int opcode_found;
static char *str_0x40="0x40";
static char *str_gr1="gr1";
/* Is token_count valid, and is the first token a string? */
if ((token_count < 1) ||
(token_count > 7) ||
(strcmp(token[0], "") == 0))
return (EMSYNTAX);
/* Get opcode */
/*
** Note: Since the opcode_name[] string used in the disassembler
** uses padded strings, we cannot do a strcmp(). We canot do a
** strncmp() of the length of token[0] either, since "and" will
** match up (for instance) with "andn". So we copy the string,
** null terminate at the first pad character (space), and then
** compare. This is inefficient, but necessary.
*/
i=0;
opcode_found = FALSE;
while ((i<256) && (opcode_found != TRUE)) {
#ifdef XRAY
result = strcasecmp(token[0], inst_table[i].inst_mnem);
#else
temp_ptr = strcpy(temp_opcode, opcode_name[i]);
if (strcmp(temp_ptr, "") != 0)
temp_ptr = strtok(temp_opcode, " ");
result = strcmp(token[0], temp_ptr);
#endif
if (result == 0) {
opcode_found = TRUE;
instr->op = (BYTE) i;
}
i = i + 1;
} /* end while */
/* Check for a NOP */
if ((opcode_found == FALSE) &&
(strcasecmp(token[0], "nop") == 0)) {
opcode_found = TRUE;
instr->op = ASEQ0;
/* Fake up tokens to give "aseq 0x40,gr1,gr1" */
token_count = 4;
token[1] = str_0x40;
token[2] = str_gr1;
token[3] = str_gr1;
}
if (opcode_found == FALSE)
return (EMSYNTAX);
if ((strcasecmp(token[0], "iretinv") == 0) ||
(strcasecmp(token[0], "inv") == 0) ) {
/* iretinv and inv instructions */
for (i=1; i<token_count; i=i+1) {
result = get_addr_29k_m(token[i], &(parm[i-1]), GENERIC_SPACE);
if (result != 0)
return (result);
}
} else {
/* Make the other tokens into addr_29k */
for (i=1; i<token_count; i=i+1) {
result = get_addr_29k_m(token[i], &(parm[i-1]), I_MEM);
if (result != 0)
return (result);
/* Check if register values are legal */
if (ISREG(parm[i-1].memory_space)) {
result = addr_29k_ok(&(parm[i-1]));
if (result != 0)
return (EMBADREG);
}
/* Set bit 7 if a LOCAL_REG */
if (parm[i-1].memory_space == LOCAL_REG)
parm[i-1].address = (parm[i-1].address | 0x80);
}
}
switch (instr->op) {
/* Opcodes 0x00 to 0x0F */
case ILLEGAL_00: result = EMSYNTAX;
break;
case CONSTN: result = asm_const(instr, parm, 2);
break;
case CONSTH: result = asm_consth(instr, parm, 2);
break;
case CONST: result = asm_const(instr, parm, 2);
break;
case MTSRIM: result = asm_mtsrim(instr, parm, 2);
break;
case CONSTHZ: result = asm_const(instr, parm, 2);
break;
case LOADL0: result = asm_load_store(instr, parm, 4);
break;
case LOADL1: result = asm_load_store(instr, parm, 4);
break;
case CLZ0: result = asm_clz(instr, parm, 2);
break;
case CLZ1: result = asm_clz(instr, parm, 2);
break;
case EXBYTE0: result = asm_arith_logic(instr, parm, 3);
break;
case EXBYTE1: result = asm_arith_logic(instr, parm, 3);
break;
case INBYTE0: result = asm_arith_logic(instr, parm, 3);
break;
case INBYTE1: result = asm_arith_logic(instr, parm, 3);
break;
case STOREL0: result = asm_load_store(instr, parm, 4);
break;
case STOREL1: result = asm_load_store(instr, parm, 4);
break;
/* Opcodes 0x10 to 0x1F */
case ADDS0: result = asm_arith_logic(instr, parm, 3);
break;
case ADDS1: result = asm_arith_logic(instr, parm, 3);
break;
case ADDU0: result = asm_arith_logic(instr, parm, 3);
break;
case ADDU1: result = asm_arith_logic(instr, parm, 3);
break;
case ADD0: result = asm_arith_logic(instr, parm, 3);
break;
case ADD1: result = asm_arith_logic(instr, parm, 3);
break;
case LOAD0: result = asm_load_store(instr, parm, 4);
break;
case LOAD1: result = asm_load_store(instr, parm, 4);
break;
case ADDCS0: result = asm_arith_logic(instr, parm, 3);
break;
case ADDCS1: result = asm_arith_logic(instr, parm, 3);
break;
case ADDCU0: result = asm_arith_logic(instr, parm, 3);
break;
case ADDCU1: result = asm_arith_logic(instr, parm, 3);
break;
case ADDC0: result = asm_arith_logic(instr, parm, 3);
break;
case ADDC1: result = asm_arith_logic(instr, parm, 3);
break;
case STORE0: result = asm_load_store(instr, parm, 4);
break;
case STORE1: result = asm_load_store(instr, parm, 4);
break;
/* Opcodes 0x20 to 0x2F */
case SUBS0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBS1: result = asm_arith_logic(instr, parm, 3);
break;
case SUBU0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBU1: result = asm_arith_logic(instr, parm, 3);
break;
case SUB0: result = asm_arith_logic(instr, parm, 3);
break;
case SUB1: result = asm_arith_logic(instr, parm, 3);
break;
case LOADSET0: result = asm_load_store(instr, parm, 4);
break;
case LOADSET1: result = asm_load_store(instr, parm, 4);
break;
case SUBCS0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBCS1: result = asm_arith_logic(instr, parm, 3);
break;
case SUBCU0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBCU1: result = asm_arith_logic(instr, parm, 3);
break;
case SUBC0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBC1: result = asm_arith_logic(instr, parm, 3);
break;
case CPBYTE0: result = asm_arith_logic(instr, parm, 3);
break;
case CPBYTE1: result = asm_arith_logic(instr, parm, 3);
break;
/* Opcodes 0x30 to 0x3F */
case SUBRS0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBRS1: result = asm_arith_logic(instr, parm, 3);
break;
case SUBRU0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBRU1: result = asm_arith_logic(instr, parm, 3);
break;
case SUBR0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBR1: result = asm_arith_logic(instr, parm, 3);
break;
case LOADM0: result = asm_load_store(instr, parm, 4);
break;
case LOADM1: result = asm_load_store(instr, parm, 4);
break;
case SUBRCS0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBRCS1: result = asm_arith_logic(instr, parm, 3);
break;
case SUBRCU0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBRCU1: result = asm_arith_logic(instr, parm, 3);
break;
case SUBRC0: result = asm_arith_logic(instr, parm, 3);
break;
case SUBRC1: result = asm_arith_logic(instr, parm, 3);
break;
case STOREM0: result = asm_load_store(instr, parm, 4);
break;
case STOREM1: result = asm_load_store(instr, parm, 4);
break;
/* Opcodes 0x40 to 0x4F */
case CPLT0: result = asm_arith_logic(instr, parm, 3);
break;
case CPLT1: result = asm_arith_logic(instr, parm, 3);
break;
case CPLTU0: result = asm_arith_logic(instr, parm, 3);
break;
case CPLTU1: result = asm_arith_logic(instr, parm, 3);
break;
case CPLE0: result = asm_arith_logic(instr, parm, 3);
break;
case CPLE1: result = asm_arith_logic(instr, parm, 3);
break;
case CPLEU0: result = asm_arith_logic(instr, parm, 3);
break;
case CPLEU1: result = asm_arith_logic(instr, parm, 3);
break;
case CPGT0: result = asm_arith_logic(instr, parm, 3);
break;
case CPGT1: result = asm_arith_logic(instr, parm, 3);
break;
case CPGTU0: result = asm_arith_logic(instr, parm, 3);
break;
case CPGTU1: result = asm_arith_logic(instr, parm, 3);
break;
case CPGE0: result = asm_arith_logic(instr, parm, 3);
break;
case CPGE1: result = asm_arith_logic(instr, parm, 3);
break;
case CPGEU0: result = asm_arith_logic(instr, parm, 3);
break;
case CPGEU1: result = asm_arith_logic(instr, parm, 3);
break;
/* Opcodes 0x50 to 0x5F */
case ASLT0: result = asm_vector(instr, parm, 3);
break;
case ASLT1: result = asm_vector(instr, parm, 3);
break;
case ASLTU0: result = asm_vector(instr, parm, 3);
break;
case ASLTU1: result = asm_vector(instr, parm, 3);
break;
case ASLE0: result = asm_vector(instr, parm, 3);
break;
case ASLE1: result = asm_vector(instr, parm, 3);
break;
case ASLEU0: result = asm_vector(instr, parm, 3);
break;
case ASLEU1: result = asm_vector(instr, parm, 3);
break;
case ASGT0: result = asm_vector(instr, parm, 3);
break;
case ASGT1: result = asm_vector(instr, parm, 3);
break;
case ASGTU0: result = asm_vector(instr, parm, 3);
break;
case ASGTU1: result = asm_vector(instr, parm, 3);
break;
case ASGE0: result = asm_vector(instr, parm, 3);
break;
case ASGE1: result = asm_vector(instr, parm, 3);
break;
case ASGEU0: result = asm_vector(instr, parm, 3);
break;
case ASGEU1: result = asm_vector(instr, parm, 3);
break;
/* Opcodes 0x60 to 0x6F */
case CPEQ0: result = asm_arith_logic(instr, parm, 3);
break;
case CPEQ1: result = asm_arith_logic(instr, parm, 3);
break;
case CPNEQ0: result = asm_arith_logic(instr, parm, 3);
break;
case CPNEQ1: result = asm_arith_logic(instr, parm, 3);
break;
case MUL0: result = asm_arith_logic(instr, parm, 3);
break;
case MUL1: result = asm_arith_logic(instr, parm, 3);
break;
case MULL0: result = asm_arith_logic(instr, parm, 3);
break;
case MULL1: result = asm_arith_logic(instr, parm, 3);
break;
case DIV0_OP0: result = asm_div0(instr, parm, 2);
break;
case DIV0_OP1: result = asm_div0(instr, parm, 2);
break;
case DIV_OP0: result = asm_arith_logic(instr, parm, 3);
break;
case DIV_OP1: result = asm_arith_logic(instr, parm, 3);
break;
case DIVL0: result = asm_arith_logic(instr, parm, 3);
break;
case DIVL1: result = asm_arith_logic(instr, parm, 3);
break;
case DIVREM0: result = asm_arith_logic(instr, parm, 3);
break;
case DIVREM1: result = asm_arith_logic(instr, parm, 3);
break;
/* Opcodes 0x70 to 0x7F */
case ASEQ0: result = asm_vector(instr, parm, 3);
break;
case ASEQ1: result = asm_vector(instr, parm, 3);
break;
case ASNEQ0: result = asm_vector(instr, parm, 3);
break;
case ASNEQ1: result = asm_vector(instr, parm, 3);
break;
case MULU0: result = asm_arith_logic(instr, parm, 3);
break;
case MULU1: result = asm_arith_logic(instr, parm, 3);
break;
case ILLEGAL_76: result = EMSYNTAX;
break;
case ILLEGAL_77: result = EMSYNTAX;
break;
case INHW0: result = asm_arith_logic(instr, parm, 3);
break;
case INHW1: result = asm_arith_logic(instr, parm, 3);
break;
case EXTRACT0: result = asm_arith_logic(instr, parm, 3);
break;
case EXTRACT1: result = asm_arith_logic(instr, parm, 3);
break;
case EXHW0: result = asm_arith_logic(instr, parm, 3);
break;
case EXHW1: result = asm_arith_logic(instr, parm, 3);
break;
case EXHWS: result = asm_exhws(instr, parm, 2);
break;
case ILLEGAL_7F: result = EMSYNTAX;
break;
/* Opcodes 0x80 to 0x8F */
case SLL0: result = asm_arith_logic(instr, parm, 3);
break;
case SLL1: result = asm_arith_logic(instr, parm, 3);
break;
case SRL0: result = asm_arith_logic(instr, parm, 3);
break;
case SRL1: result = asm_arith_logic(instr, parm, 3);
break;
case ILLEGAL_84: result = EMSYNTAX;
break;
case ILLEGAL_85: result = EMSYNTAX;
break;
case SRA0: result = asm_arith_logic(instr, parm, 3);
break;
case SRA1: result = asm_arith_logic(instr, parm, 3);
break;
case IRET:
result = asm_no_parms(instr, parm, 0);
break;
case HALT_OP: result = asm_no_parms(instr, parm, 0);
break;
case ILLEGAL_8A: result = EMSYNTAX;
break;
case ILLEGAL_8B: result = EMSYNTAX;
break;
case IRETINV:
if (token_count > 1)
result = asm_one_parms(instr, parm, 1);
else
result = asm_no_parms(instr, parm, 0);
break;
case ILLEGAL_8D: result = EMSYNTAX;
break;
case ILLEGAL_8E: result = EMSYNTAX;
break;
case ILLEGAL_8F: result = EMSYNTAX;
break;
/* Opcodes 0x90 to 0x9F */
case AND_OP0: result = asm_arith_logic(instr, parm, 3);
break;
case AND_OP1: result = asm_arith_logic(instr, parm, 3);
break;
case OR_OP0: result = asm_arith_logic(instr, parm, 3);
break;
case OR_OP1: result = asm_arith_logic(instr, parm, 3);
break;
case XOR_OP0: result = asm_arith_logic(instr, parm, 3);
break;
case XOR_OP1: result = asm_arith_logic(instr, parm, 3);
break;
case XNOR0: result = asm_arith_logic(instr, parm, 3);
break;
case XNOR1: result = asm_arith_logic(instr, parm, 3);
break;
case NOR0: result = asm_arith_logic(instr, parm, 3);
break;
case NOR1: result = asm_arith_logic(instr, parm, 3);
break;
case NAND0: result = asm_arith_logic(instr, parm, 3);
break;
case NAND1: result = asm_arith_logic(instr, parm, 3);
break;
case ANDN0: result = asm_arith_logic(instr, parm, 3);
break;
case ANDN1: result = asm_arith_logic(instr, parm, 3);
break;
case SETIP: result = asm_float(instr, parm, 3);
break;
case INV:
if (token_count > 1)
result = asm_one_parms(instr, parm, 1);
else
result = asm_no_parms(instr, parm, 0);
break;
/* Opcodes 0xA0 to 0xAF */
case JMP0: result = asm_jmp(instr, parm, 1);
break;
case JMP1: result = asm_jmp(instr, parm, 1);
break;
case ILLEGAL_A2: result = EMSYNTAX;
break;
case ILLEGAL_A3: result = EMSYNTAX;
break;
case JMPF0: result = asm_call_jmp(instr, parm, 2);
break;
case JMPF1: result = asm_call_jmp(instr, parm, 2);
break;
case ILLEGAL_A6: result = EMSYNTAX;
break;
case ILLEGAL_A7: result = EMSYNTAX;
break;
case CALL0: result = asm_call_jmp(instr, parm, 2);
break;
case CALL1: result = asm_call_jmp(instr, parm, 2);
break;
case ORN_OP0: result = EMSYNTAX;
break;
case ORN_OP1: result = EMSYNTAX;
break;
case JMPT0: result = asm_call_jmp(instr, parm, 2);
break;
case JMPT1: result = asm_call_jmp(instr, parm, 2);
break;
case ILLEGAL_AE: result = EMSYNTAX;
break;
case ILLEGAL_AF: result = EMSYNTAX;
break;
/* Opcodes 0xB0 to 0xBF */
case ILLEGAL_B0: result = EMSYNTAX;
break;
case ILLEGAL_B1: result = EMSYNTAX;
break;
case ILLEGAL_B2: result = EMSYNTAX;
break;
case ILLEGAL_B3: result = EMSYNTAX;
break;
case JMPFDEC0: result = asm_call_jmp(instr, parm, 2);
break;
case JMPFDEC1: result = asm_call_jmp(instr, parm, 2);
break;
case MFTLB: result = asm_mftlb(instr, parm, 2);
break;
case ILLEGAL_B7: result = EMSYNTAX;
break;
case ILLEGAL_B8: result = EMSYNTAX;
break;
case ILLEGAL_B9: result = EMSYNTAX;
break;
case ILLEGAL_BA: result = EMSYNTAX;
break;
case ILLEGAL_BB: result = EMSYNTAX;
break;
case ILLEGAL_BC: result = EMSYNTAX;
break;
case ILLEGAL_BD: result = EMSYNTAX;
break;
case MTTLB: result = asm_mttlb(instr, parm, 2);
break;
case ILLEGAL_BF: result = EMSYNTAX;
break;
/* Opcodes 0xC0 to 0xCF */
case JMPI: result = asm_jmpi(instr, parm, 1);
break;
case ILLEGAL_C1: result = EMSYNTAX;
break;
case ILLEGAL_C2: result = EMSYNTAX;
break;
case ILLEGAL_C3: result = EMSYNTAX;
break;
case JMPFI: result = asm_calli_jmpi(instr, parm, 2);
break;
case ILLEGAL_C5: result = EMSYNTAX;
break;
case MFSR: result = asm_mfsr(instr, parm, 2);
break;
case ILLEGAL_C7: result = EMSYNTAX;
break;
case CALLI: result = asm_calli_jmpi(instr, parm, 2);
break;
case ILLEGAL_C9: result = EMSYNTAX;
break;
case ILLEGAL_CA: result = EMSYNTAX;
break;
case ILLEGAL_CB: result = EMSYNTAX;
break;
case JMPTI: result = asm_calli_jmpi(instr, parm, 2);
break;
case ILLEGAL_CD: result = EMSYNTAX;
break;
case MTSR: result = asm_mtsr(instr, parm, 2);
break;
case ILLEGAL_CF: result = EMSYNTAX;
break;
/* Opcodes 0xD0 to 0xDF */
case ILLEGAL_D0: result = EMSYNTAX;
break;
case ILLEGAL_D1: result = EMSYNTAX;
break;
case ILLEGAL_D2: result = EMSYNTAX;
break;
case ILLEGAL_D3: result = EMSYNTAX;
break;
case ILLEGAL_D4: result = EMSYNTAX;
break;
case ILLEGAL_D5: result = EMSYNTAX;
break;
case ILLEGAL_D6: result = EMSYNTAX;
break;
case EMULATE: result = asm_emulate(instr, parm, 3);
break;
case ILLEGAL_D8: result = EMSYNTAX;
break;
case ILLEGAL_D9: result = EMSYNTAX;
break;
case ILLEGAL_DA: result = EMSYNTAX;
break;
case ILLEGAL_DB: result = EMSYNTAX;
break;
case ILLEGAL_DC: result = EMSYNTAX;
break;
case ILLEGAL_DD: result = EMSYNTAX;
break;
case MULTM: result = asm_float(instr, parm, 3);
break;
case MULTMU: result = asm_float(instr, parm, 3);
break;
/* Opcodes 0xE0 to 0xEF */
case MULTIPLY: result = asm_float(instr, parm, 3);
break;
case DIVIDE: result = asm_float(instr, parm, 3);
break;
case MULTIPLU: result = asm_float(instr, parm, 3);
break;
case DIVIDU: result = asm_float(instr, parm, 3);
break;
case CONVERT: result = asm_convert(instr, parm, 6);
break;
case SQRT: result = asm_sqrt(instr, parm, 3);
break;
case CLASS: result = asm_class(instr, parm, 3);
break;
case ILLEGAL_E7: result = EMSYNTAX;
break;
case ILLEGAL_E8: result = EMSYNTAX;
break;
case ILLEGAL_E9: result = EMSYNTAX;
break;
case FEQ: result = asm_float(instr, parm, 3);
break;
case DEQ: result = asm_float(instr, parm, 3);
break;
case FGT: result = asm_float(instr, parm, 3);
break;
case DGT: result = asm_float(instr, parm, 3);
break;
case FGE: result = asm_float(instr, parm, 3);
break;
case DGE: result = asm_float(instr, parm, 3);
break;
/* Opcodes 0xF0 to 0xFF */
case FADD: result = asm_float(instr, parm, 3);
break;
case DADD: result = asm_float(instr, parm, 3);
break;
case FSUB: result = asm_float(instr, parm, 3);
break;
case DSUB: result = asm_float(instr, parm, 3);
break;
case FMUL: result = asm_float(instr, parm, 3);
break;
case DMUL: result = asm_float(instr, parm, 3);
break;
case FDIV: result = asm_float(instr, parm, 3);
break;
case DDIV: result = asm_float(instr, parm, 3);
break;
case ILLEGAL_F8: result = EMSYNTAX;
break;
case FDMUL: result = asm_float(instr, parm, 3);
break;
case ILLEGAL_FA: result = EMSYNTAX;
break;
case ILLEGAL_FB: result = EMSYNTAX;
break;
case ILLEGAL_FC: result = EMSYNTAX;
break;
case ILLEGAL_FD: result = EMSYNTAX;
break;
case ILLEGAL_FE: result = EMSYNTAX;
break;
case ILLEGAL_FF: result = EMSYNTAX;
break;
} /* end switch */
return (result);
} /* End asm_instr() */
/*
** The following functions are used to convert instruction
** parameters as an arrays of addr_29k_t memory space / address
** pairs into a 32 bit Am29000 binary instruction.
** All of the Am29000 instruction formats are supported below.
*/
/*
** Formats: <nmemonic>, RC, RA, (RB or I)
** Examples: ADD, OR, SLL, all arithmetic and
** logic instructions
**
*/
int
asm_arith_logic(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 3)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISGENERAL(parm[2].memory_space)) {
/* Make sure M flag is cleared */
instr->op = (BYTE) (instr->op & 0xfe);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (BYTE) (parm[2].address & 0xff);
}
else
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISMEM(parm[2].memory_space)) {
/* Make sure M flag is set */
instr->op = (BYTE) (instr->op | 0x01);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (BYTE) (parm[2].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_arith_logic() */
/*
** Formats: <nmemonic>, VN, RA, (RB or I)
** Examples: ASSEQ, ASLE, ASLT, all trap assertion
** instructions
**
*/
int
asm_vector(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 3)
return (EMSYNTAX);
if (ISMEM(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISGENERAL(parm[2].memory_space)) {
/* Make sure M flag is cleared */
instr->op = (BYTE) (instr->op & 0xfe);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (BYTE) (parm[2].address & 0xff);
}
else
if (ISMEM(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISMEM(parm[2].memory_space)) {
/* Make sure M flag is set */
instr->op = (BYTE) (instr->op | 0x01);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (BYTE) (parm[2].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_vector() */
/*
** Formats: <nmemonic>, CE, CNTL, RA, (RB or I)
** Examples: LOAD, LOADM, STORE, all load and store
** instructions
**
*/
int
asm_load_store(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
int ce;
int cntl;
if (parm_count != 4)
return (EMSYNTAX);
if (ISMEM(parm[0].memory_space) &&
ISMEM(parm[1].memory_space) &&
ISGENERAL(parm[2].memory_space) &&
ISGENERAL(parm[3].memory_space)) {
/* Make sure M flag is cleared */
instr->op = (BYTE) (instr->op & 0xfe);
if (parm[0].address > 1)
return (EMSYNTAX);
if (parm[1].address > 0x7f)
return (EMSYNTAX);
ce = (int) ((parm[0].address << 7) & 0x80);
cntl = (int) (parm[1].address & 0x7f);
instr->c = (BYTE) (ce | cntl);
instr->a = (BYTE) (parm[2].address & 0xff);
instr->b = (BYTE) (parm[3].address & 0xff);
}
else
if (ISMEM(parm[0].memory_space) &&
ISMEM(parm[1].memory_space) &&
ISGENERAL(parm[2].memory_space) &&
ISMEM(parm[3].memory_space)) {
/* Make sure M flag is set */
instr->op = (BYTE) (instr->op | 0x01);
if (parm[0].address > 1)
return (EMSYNTAX);
if (parm[1].address > 0x7f)
return (EMSYNTAX);
if (parm[3].address > 0xff)
return (EMSYNTAX);
ce = (int) ((parm[0].address << 7) & 0x80);
cntl = (int) (parm[1].address & 0x7f);
instr->c = (BYTE) (ce | cntl);
instr->a = (BYTE) (parm[2].address & 0xff);
instr->b = (BYTE) (parm[3].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_load_store() */
/*
** Formats: <nmemonic>
** Examples: HALT, INV, IRET
*/
/*ARGSUSED*/
int
asm_no_parms(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 0)
return (EMSYNTAX);
/* Put zeros in the "reserved" fields */
instr->c = 0;
instr->a = 0;
instr->b = 0;
return (0);
} /* end asm_no_parms() */
int
asm_one_parms(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 1)
return (EMSYNTAX);
instr->c = (BYTE) (parm[0].address & 0x3);
/* Put zeros in the "reserved" fields */
instr->a = 0;
instr->b = 0;
return (0);
} /* end asm_one_parms */
/*
** Formats: <nmemonic>, RC, RA, RB
** Examples: DADD, FADD, all floating point
** instructions
**
*/
int
asm_float(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 3)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISGENERAL(parm[2].memory_space)) {
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (BYTE) (parm[2].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_float() */
/*
** Formats: <nmemonic> RA, <target>
** Examples: CALL, JMPF, JMPFDEC, JMPT
**
** Note: This function is used only with the CALL,
** JMPF, JMPFDEC and JMPT operations.
*/
int
asm_call_jmp(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISMEM(parm[1].memory_space)) {
/* Make sure M flag is set */
if (parm[1].memory_space != PC_RELATIVE)
instr->op = (BYTE) (instr->op | 0x01);
else
instr->op = (BYTE) instr->op ;
instr->c = (BYTE) ((parm[1].address >> 10) & 0xff);
instr->a = (BYTE) (parm[0].address & 0xff);
instr->b = (BYTE) ((parm[1].address >> 2) & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_call_jmp() */
/*
** Formats: <nmemonic> RA, RB
** Examples: CALLI, JMPFI, JMPTI
**
** Note: This function is used only with the CALLI,
** JMPFI and JMPTI (but not JMPI) operations.
*/
int
asm_calli_jmpi(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISREG(parm[1].memory_space)) {
instr->c = 0;
instr->a = (BYTE) (parm[0].address & 0xff);
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_calli_jmpi() */
/*
** Formats: <nmemonic> RC, RB, FS
** Examples: CLASS
**
** Note: This function is used only with the CLASS
** operation.
*/
int
asm_class(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 3)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISMEM(parm[2].memory_space)) {
if (parm[2].address > 0x03)
return (EMSYNTAX);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (BYTE) (parm[2].address & 0x03);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_class() */
/*
** Formats: <nmemonic> RC, (RB or I)
** Examples: CLZ
**
** Note: This function is used only with the CLZ
** operation.
*/
int
asm_clz(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space)) {
/* Make sure M flag is cleared */
instr->op = (BYTE) (instr->op & 0xfe);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = 0;
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
if (ISGENERAL(parm[0].memory_space) &&
ISMEM(parm[1].memory_space)) {
/* Check param1 */
if ((parm[1].address) > 0xff)
return(EMSYNTAX);
/* Make sure M flag is set */
instr->op = (BYTE) (instr->op | 0x01);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = 0;
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_clz() */
/*
** Formats: <nmemonic> RA, <const16>
** Examples: CONST, CONSTN
**
*/
int
asm_const(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISMEM(parm[1].memory_space)) {
instr->c = (BYTE) ((parm[1].address >> 8) & 0xff);
instr->a = (BYTE) (parm[0].address & 0xff);
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_const() */
/*
** Formats: <nmemonic> RA, <const16>
** Examples: CONSTH
**
*/
int
asm_consth(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISMEM(parm[1].memory_space)) {
instr->c = (BYTE) ((parm[1].address >> 24) & 0xff);
instr->a = (BYTE) (parm[0].address & 0xff);
instr->b = (BYTE) ((parm[1].address >> 16) & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_consth() */
/*
** Formats: <nmemonic> RC, RA, UI, RND, FD, FS
** Examples: CONVERT
**
** Note: This function is used only with the CONVERT
** operation.
**
** Note: Some assembler examples show this operation with
** only five parameters. It should have six.
*/
int
asm_convert(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
BYTE ui;
BYTE rnd;
BYTE fd;
BYTE fs;
if (parm_count != 6)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISMEM(parm[2].memory_space) &&
ISMEM(parm[3].memory_space) &&
ISMEM(parm[4].memory_space) &&
ISMEM(parm[5].memory_space)) {
if (parm[2].address > 1)
return (EMSYNTAX);
if (parm[3].address > 0x07)
return (EMSYNTAX);
if (parm[4].address > 0x03)
return (EMSYNTAX);
if (parm[5].address > 0x03)
return (EMSYNTAX);
ui = (BYTE) ((parm[2].address << 7) & 0x80);
rnd = (BYTE) ((parm[3].address << 4) & 0x70);
fd = (BYTE) ((parm[4].address << 2) & 0x0c);
fs = (BYTE) (parm[5].address & 0x03);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (ui | rnd | fd | fs);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_convert() */
/*
** Formats: <nmemonic> RC, RA
** Examples: DIV0
**
** Note: This function is used only with the DIV0
** operation.
*/
int
asm_div0(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space)) {
/* Make sure M flag is cleared */
instr->op = (BYTE) (instr->op & 0xfe);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = 0;
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
if (ISGENERAL(parm[0].memory_space) &&
ISMEM(parm[1].memory_space)) {
/* Check immediate value */
if (parm[1].address > 0xff)
return (EMSYNTAX);
/* Make sure M flag is set */
instr->op = (BYTE) (instr->op | 0x01);
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = 0;
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_div0() */
/*
** Formats: <nmemonic> RC, RA
** Examples: EXHWS
**
** Note: This function is used only with the EXHWS
** operation.
*/
int
asm_exhws(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space)){
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = 0;
}
else
return(EMSYNTAX);
return (0);
} /* end asm_exhws() */
/*
** Formats: <nmemonic> <target>
** Examples: JMP
**
** Note: This function is used only with the JMP
** operation.
**
** Note: This function will only do absolute jumps.
*/
int
asm_jmp(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 1)
return (EMSYNTAX);
if (ISMEM(parm[0].memory_space)) {
/* Make sure M flag is set */
if (parm[0].memory_space != PC_RELATIVE)
instr->op = (BYTE) (instr->op | 0x01);
else
instr->op = (BYTE) instr->op ;
instr->c = (BYTE) ((parm[0].address >> 10) & 0xff);
instr->a = 0;
instr->b = (BYTE) ((parm[0].address >> 2) & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_jmp() */
/*
** Formats: <nmemonic> RB
** Examples: JMPI
**
** Note: This function is used only with the JMPI
** operation.
*/
int
asm_jmpi(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 1)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space)) {
instr->c = 0;
instr->a = 0;
instr->b = (BYTE) (parm[0].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_jmpi() */
/*
** Formats: <nmemonic> RC, SA
** Examples: MFSR
**
** Note: This function is used only with the MFSR
** operation.
*/
int
asm_mfsr(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISSPECIAL(parm[1].memory_space)) {
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = 0;
}
else
return(EMSYNTAX);
return (0);
} /* end asm_mfsr() */
/*
** Formats: <nmemonic> SA, RB
** Examples: MTSR
**
** Note: This function is used only with the MTSR
** operation.
*/
int
asm_mtsr(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISSPECIAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space)) {
instr->c = 0;
instr->a = (BYTE) (parm[0].address & 0xff);
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_mtsr() */
/*
** Formats: <nmemonic> SA, <const16>
** Examples: MTSRIM
**
** Note: This function is used only with the MTSRIM
** operation.
*/
int
asm_mtsrim(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISSPECIAL(parm[0].memory_space) &&
ISMEM(parm[1].memory_space)) {
instr->c = (BYTE) ((parm[1].address >> 8) & 0xff);
instr->a = (BYTE) (parm[0].address & 0xff);
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_mtsrim() */
/*
** Formats: <nmemonic> RC, RA
** Examples: MFTLB
**
** Note: This function is used only with the MFTLB
** operation.
*/
int
asm_mftlb(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space)) {
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = 0;
}
else
return(EMSYNTAX);
return (0);
} /* end asm_mftlb() */
/*
** Formats: <nmemonic> RA, RB
** Examples: MTTLB
**
** Note: This function is used only with the MTTLB
** operation.
*/
int
asm_mttlb(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 2)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space)) {
instr->c = 0;
instr->a = (BYTE) (parm[0].address & 0xff);
instr->b = (BYTE) (parm[1].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_mttlb() */
/*
** Formats: <nmemonic> RC, RA, FS
** Examples: SQRT
**
** Note: This function is used only with the SQRT
** operation.
*/
int
asm_sqrt(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 3)
return (EMSYNTAX);
if (ISGENERAL(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISMEM(parm[2].memory_space)) {
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (BYTE) (parm[2].address & 0x03);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_sqrt() */
/*
** Formats: <nmemonic>, VN, RA, RB
** Examples: EMULATE
**
** Note: This function is used only with the EMULATE
** operation.
**
*/
int
asm_emulate(instr, parm, parm_count)
struct instr_t *instr;
struct addr_29k_t *parm;
int parm_count;
{
if (parm_count != 3)
return (EMSYNTAX);
if (ISMEM(parm[0].memory_space) &&
ISGENERAL(parm[1].memory_space) &&
ISGENERAL(parm[2].memory_space)) {
instr->c = (BYTE) (parm[0].address & 0xff);
instr->a = (BYTE) (parm[1].address & 0xff);
instr->b = (BYTE) (parm[2].address & 0xff);
}
else
return(EMSYNTAX);
return (0);
} /* end asm_emulate() */
|