Question
int update_alert_level(unsigned int* stockpiles, unsigned int cutoff, unsigned int alert_level) { int total_monster = 0; for (int i = 0; i < 10; i++) {
int update_alert_level(unsigned int* stockpiles, unsigned int cutoff, unsigned int alert_level) { int total_monster = 0; for (int i = 0; i < 10; i++) { total_monster += stockpiles[i]; } if (total_monster < cutoff) { return alert_level + 1; } else if (total_monster == cutoff) { return alert_level; } else { return alert_level - 1; } }
Convert to mips
Using:
.text
# // Ignore integer overflow for addition # int update_alert_level(unsigned int* stockpiles, unsigned int cutoff, # unsigned int alert_level) { # int total_monster = 0; # for (int i = 0; i < 10; i++) { # total_monster += stockpiles[i]; # } # if (total_monster < cutoff) { # return alert_level + 1; # } else if (total_monster == cutoff) { # return alert_level; # } else { # return alert_level - 1; # } # } # // a0: unsigned int *stockpiles # // a1: unsigned int cutoff # // a2: unsigned int alert_level
.globl update_alert_level update_alert_level: jr $ra
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started