/** * Initializes all 32 registers with a value 0. * There has to be a better way to do this... think about it. */ void initializeRegisters() { //allocate for array registers = (struct reg *) malloc(sizeof(struct reg)*32); //Register names in order given by SPIM char* const names[] = {"r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9","k0", "k1", "gp", "sp", "s8", "ra"}; int i; for(i=0; i < 32; i++) { registers[i] = *createReg(names[i], 0); } }
void write_to_dyReg(void** val, unsigned long long int reg_num, char d_type){ // Theres Allot Of Overhead switch(d_type){ case 0: if(reg_nHandle.isProtected == 1){ throw_cpu_fatal(16); } if(reg_num == reg_nHandle.amountRegisters){ createReg(); } else{ reg_table[reg_num] = val; type_table[reg_num] = d_type; } } }