Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write MIPS code for executable part of the code. Assume that the stack and the s

ID: 3651225 • Letter: W

Question

Write MIPS code for executable part of the code.


Assume that the stack and the static data segments are empty and that the stack and global pointers start at address 0x7fff fffc and 0x1000 8000, respectively. Assume the calling conventions as specified in Figure 2.11 and that function inputs are passed using registers $a0 and returned in register $v0. Assume that leaf functions may only use saved registers.


int X[8] = {100, 200, 300, 500, 0, -1, 20, -2};
int count1;
int count2;

int count_less_than(int*, int, int);

int main()
{
count1 = count_less_than(X, 8, 0);
count2 = count_less_than(X, 4, 320);
}

int count_less_than (int X[], int N, int threshold)
{
int count = 0, i;
for (i = 0; i < N; i++)
count += (X[i] < threshold);
return count;
}

Explanation / Answer

compiler will initialize the stack pointer to the last location of RAM. .Line 9 is another #define that specifies the transmit data ready empty ,this is where the software will start after a reset or after being powered up. The -0x8000 to 0x7fff there are other possibilities like a static global

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote