Курсовая работа: Проектування комп`ютера

if (argc! = 3) {

printf ("error: usage: %s <assembly-code-file> <machine-code-file>\n",

argv [0]);

exit (1);

}

inFileString = argv [1];

outFileString = argv [2];

inFilePtr = fopen (inFileString, "r");

if (inFilePtr == NULL) {

printf ("error in opening %s\n", inFileString);

exit (1);

}

outFilePtr = fopen (outFileString, "w");

if (outFilePtr == NULL) {

printf ("error in opening %s\n", outFileString);

exit (1);

}

/* map symbols to addresses */

/* assume address start at 0 */

for (address=0; readandfParse (inFilePtr, label, opcode, arg0, arg1, arg2);

address++) {

/*

printf ("%d: label=%s, opcode=%s, arg0=%s, arg1=%s, arg2=%s\n",

address, label, opcode, arg0, arg1, arg2);

*/

/* check for illegal opcode */

if (strcmp (opcode, "add") && strcmp (opcode, "nand") &&

strcmp (opcode, "lw") && strcmp (opcode, "sw") &&

strcmp (opcode, "beq") && strcmp (opcode, "jalr") &&

К-во Просмотров: 485
Бесплатно скачать Курсовая работа: Проектування комп`ютера