Page 1 of 1

struct ProductionUnit { unsigned short yield; short id; bool active; }; ProductionUnit units[1000]; Convert to MIPS the

Posted: Fri Jul 01, 2022 5:37 am
by answerhappygod
struct ProductionUnit {unsigned short yield;short id;bool active; };
ProductionUnit units[1000];
Convert to MIPS the following piece of code:
for( int i{0}; i<1000; i++ )
if( units.active )
totalSum += units.yield;
The value of totalSum is already in $s7 and is alreadyinitialized to zero. The address of units is already loaded in $s0.All data members of ProductionUnit are stored in memory next toeach other (no padding) and in the same order in which they aredeclared.