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)
|
||||
//
|
||||
instruction_type get_type_of_instruction(uint32_t instruct) {
|
||||
// TODO
|
||||
return NULL;
|
||||
if (bit_select(instruct, 26, 32) == 0) {
|
||||
return R_TYPE;
|
||||
} else {
|
||||
return I_TYPE;
|
||||
}
|
||||
|
||||
} // end get_type_of_instruction() function
|
||||
|
||||
// ------------------------------------
|
||||
|
|
2
lab04.c
2
lab04.c
|
@ -32,10 +32,12 @@ int main() {
|
|||
return EXIT_SUCCESS;
|
||||
|
||||
if (get_type_of_instruction(instruct) == R_TYPE) {
|
||||
printf("R_TYPE instruction\n");
|
||||
r_instruction* r_instruct = create_r_instruction(instruct);
|
||||
execute_r_instruction(r_instruct);
|
||||
free(r_instruct);
|
||||
} else { // I_TYPE
|
||||
printf("I_TYPE instruction\n");
|
||||
i_instruction* i_instruct = create_i_instruction(instruct);
|
||||
execute_i_instruction(i_instruct);
|
||||
free(i_instruct);
|
||||
|
|
Loading…
Reference in New Issue
Block a user