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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!