Пример #1
0
Файл: cSerie1.c Проект: pas/ra
/* Initialize the "hardware" and operation and function dispatcher */
void initialize() {
    int i;
    /* Initialize operations  with default values */
    for (i=0; i<OPERATION_COUNT; ++i) {
        assignOperation(i, "ndef", specialType, 0);
    }

    /* to deal with operations with OpCode = 0, i.e. R-Type */
    assignOperation(OC_ZERO, "zero", rType, 0);

    /* assign some actual operations */
    assignOperation(OC_ADDI, "addi", iType, 0);
    assignOperation(OC_J, "j", jType, 0);
    assignOperation(OC_LUI, "lui", iType, 0);
    assignOperation(OC_LW, "lw", iType, 0);
    assignOperation(OC_ORI, "ori", iType, 0);
    assignOperation(OC_SW, "sw", iType, 0);
    assignOperation(OC_STOP,"stop", specialType, 0);

    /* Initialize operations with OpCode = 0 and corresponding functions with default values*/
    for (i=0; i<FUNCTION_COUNT; ++i) {
        assignFunction(i, "ndef", 0);
    }

    /* assign some actual functions */
    assignFunction(FC_ADD, "add", 0);
    assignFunction(FC_SUB, "sub", 0);
}
Пример #2
0
Файл: mips.c Проект: matsimon/RA
/* Initialize the "hardware" and operation and function dispatcher */
void initialize() {
	int i;
	/* Initialize operations */
	for (i=0; i<OPERATION_COUNT; ++i) {
		assignOperation(i, "ndef", specialType, &undefinedOperation);
	}
	assignOperation(OC_ZERO, "zero", rType, &opCodeZeroOperation);
	/* To stop the MIPS machine */
	assignOperation(OC_STOP,"stop", specialType, &stopOperation);
	
	assignOperation(OC_ADDI, "addi", iType, &mips_addi);
	assignOperation(OC_LUI, "lui", iType ,&mips_lui);
	assignOperation(OC_LW, "lw", iType, &mips_lw);
	assignOperation(OC_ORI, "ori", iType, &mips_ori);
	assignOperation(OC_SW, "sw", iType, &mips_sw);
	
	/* Initialize operations with OpCode = 0 and corresponding functions */
	for (i=0; i<FUNCTION_COUNT; ++i) {
		assignFunction(i, "ndef", &undefinedFunction);
	}
	assignFunction(FC_ADD, "add", &mips_add);
	assignFunction(FC_DIV, "div", &mips_div);
	assignFunction(FC_MULT, "mult", &mips_mult);
	assignFunction(FC_SUB, "sub", &mips_sub);
	
    	initializeMemory();
    
	/* Initialize registers */
	for (i=0; i<REGISTER_COUNT; ++i) {
		registers[i]= 0;
	}
	
	/* Stack pointer */
	SP=65535;
	
	/* Initialize program counter */
	pc = 0;
	
	/* Yes, we want the machine to run */
	doRun = TRUE;       
	
}