mirror of
https://github.com/Comp211-SP24/lab-04-Rushilwiz.git
synced 2025-04-09 14:50:16 -04:00
finished get_instruction_type
This commit is contained in:
parent
19a7e4ec2d
commit
95023706aa
|
@ -16,8 +16,12 @@
|
||||||
// Return: instruction_type: R_TYPE or I_TYPE (see structures)
|
// Return: instruction_type: R_TYPE or I_TYPE (see structures)
|
||||||
//
|
//
|
||||||
instruction_type get_type_of_instruction(uint32_t instruct) {
|
instruction_type get_type_of_instruction(uint32_t instruct) {
|
||||||
// TODO
|
if (bit_select(instruct, 26, 32) == 0) {
|
||||||
return NULL;
|
return R_TYPE;
|
||||||
|
} else {
|
||||||
|
return I_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
} // end get_type_of_instruction() function
|
} // end get_type_of_instruction() function
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
14
lab04.c
14
lab04.c
|
@ -32,10 +32,12 @@ int main() {
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
if (get_type_of_instruction(instruct) == R_TYPE) {
|
if (get_type_of_instruction(instruct) == R_TYPE) {
|
||||||
|
printf("R_TYPE instruction\n");
|
||||||
r_instruction* r_instruct = create_r_instruction(instruct);
|
r_instruction* r_instruct = create_r_instruction(instruct);
|
||||||
execute_r_instruction(r_instruct);
|
execute_r_instruction(r_instruct);
|
||||||
free(r_instruct);
|
free(r_instruct);
|
||||||
} else { // I_TYPE
|
} else { // I_TYPE
|
||||||
|
printf("I_TYPE instruction\n");
|
||||||
i_instruction* i_instruct = create_i_instruction(instruct);
|
i_instruction* i_instruct = create_i_instruction(instruct);
|
||||||
execute_i_instruction(i_instruct);
|
execute_i_instruction(i_instruct);
|
||||||
free(i_instruct);
|
free(i_instruct);
|
||||||
|
@ -58,11 +60,11 @@ int main() {
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
// Takes the r_instruction
|
// Takes the r_instruction
|
||||||
// you created in Part 1 and, based on the MIPS instruction,
|
// you created in Part 1 and, based on the MIPS instruction,
|
||||||
// performs the operation and updates the 'registers' array
|
// performs the operation and updates the 'registers' array
|
||||||
// (see top of file).
|
// (see top of file).
|
||||||
//
|
//
|
||||||
// Hint: the "func" bits determine the operation (i.e., SLL,
|
// Hint: the "func" bits determine the operation (i.e., SLL,
|
||||||
// SRA, ADD, SUB, AND, OR).
|
// SRA, ADD, SUB, AND, OR).
|
||||||
//
|
//
|
||||||
// Arguments: r_instruction structure
|
// Arguments: r_instruction structure
|
||||||
|
@ -75,11 +77,11 @@ void execute_r_instruction(r_instruction* instruct) {
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
// Takes the i_instruction
|
// Takes the i_instruction
|
||||||
// you created in Part 1 and, based on the MIPS instruction,
|
// you created in Part 1 and, based on the MIPS instruction,
|
||||||
// performs the operation and updates the 'registers' array
|
// performs the operation and updates the 'registers' array
|
||||||
// (see top of file).
|
// (see top of file).
|
||||||
//
|
//
|
||||||
// Hint: the "opcode" bits determine the operation (.e., ADDI,
|
// Hint: the "opcode" bits determine the operation (.e., ADDI,
|
||||||
// ANDI, ORI).
|
// ANDI, ORI).
|
||||||
//
|
//
|
||||||
// Arguments: i_instruction structure
|
// Arguments: i_instruction structure
|
||||||
|
|
Loading…
Reference in New Issue
Block a user