📄 main.c
字号:
/*
* Copyright 2002 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
#include "proc.h"
#include "decode.h"
global_t global;
/* Initialize the register set */
void init_globals(void){
int i = 0;
for (i = 0; i < MAX_REG_SET; i++){
REG(i) = 0;
}
}
/*
Following instructions are supported
Instructions Eg. Syntax Meaning
MOV MOV A B A = B
MOVI MOVI A 100 A = 100
ADD ADD A B A = A + B
ADDI ADDI A 100 A = A + 100
SUB SUB A B A = A - B
SUBI SUB A 100 A = A - 100
MULT MULT A B A = A * B
MULTI MULTI A 100 A = A * 100
DIV DIV A B A = A / B
DIVI DIV A 100 A = A / 100
READ READ A Read A from stdin
WRITE WRITE A Write A to stdout
Registers available are A, B, C,....,Y, Z
;Comments begin with a semi-colon(;)
*/
/*
The files which contain the input program are listed in
a file named testcase_list. This file should in a
directory above COFF directory (usually the project directory).
The paths of all files in the list file should either be
absolute or relative to the COFF directory.
The main function reads the list of input file names
from the list file. It then decodes the program in the
input file.
*/
int main(void){
char file_name[1024];
FILE * test_list = NULL;
FILE * test_file = NULL;
test_list = fopen("../testcase_list","r");
if (test_list != NULL){
/* Get the next test case file name */
while (fscanf(test_list,"%s",file_name) != EOF){
test_file = fopen(file_name,"r");
if (test_file == NULL){
printf("Unable to open file %s for reading\n",file_name);
continue;
}
printf("\n*********** READING INPUT FILE %s ***********\n",file_name);
/* Initialize globals */
init_globals();
/* Send the file pointer to the decode unit for decoding */
decode(test_file);
}
}
else{
printf("Error: Unable to locate test case list file\n");
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -