Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need my C code ready for MIPS C code: #include #include unsigned x1 = 0x6A5; // Assign Values unsigned x = 0x6A5; unsigned p=0x0; unsigned

image text in transcribed

Need my C code ready for MIPS

C code:

#include #include

unsigned x1 = 0x6A5; // Assign Values unsigned x = 0x6A5; unsigned p=0x0; unsigned q1=0x0; unsigned p1=0x0; unsigned q=0x0;

int main() {

while(x1!=0) // loop will isolate each digit of initial value (IV) until x=0 { p1=x1%16; // set p1 to IVmod16, gives remainder 0x5 p=p1+p; // store p1 to p x1=x1/16; // move to next iteration } p1=p;

if(x%p==0) // if xmodp no remainder then == Harshad # (2 cases) {

while(p1!=0) // this will make q { q1=p1%16; q=q*16; q=q1+q; p1=p1/16;

}

if(p*q==x) // verify if has mirror vals or not { printf("%#x is a 16-Harshad number, w/ mirror factors: %#x * %#x ", x, p, q );

} else { printf("%#x is a 16-Harshad number, w/out mirror factors: %#x * %#x ", x, p, x / p ); } }

else // remainder means no Harshad # { printf("%#x is not a 16-Harshad number. ", x); } }

Code is summing digits in Hex and checking if it's a 16 base Harshad number

HW1-3: The goal of this part is for you to install MiSaSiM, modify a short assembly program HW1-3-shell.asm, simulate, test and debug it in MiSaSiM. The MiSaSIM simulator can be installed according to the instructions at Copy or rename the shell program to HW1-3.asm and modify it to determine whether or not the value at location XLoc is a 16-Harshad number with mirror factors and if so, put a l in the memory location labeled Result, otherwise put a 0 in that location. For this exercise, it might be helpful to open the Options menu (the wrench on the toolbar) and select "hexadecimal as the display base. Two constraints apply for this assignment only: Do not write values to registers $0, $29, $30, or $31. Do not use helper functions or function calls (JAL instruction). In order for your solution to be properly received and graded, there are a few requirements. 1. The file must be named HW1-3.asm. 2. Your name and the date should be included in the beginning of the file. 3. The starting shell program should not be modified except for the replacement of the com- ment "# write your code here...' 4. Your program must store its result at the memory location labeled Result when it returns. This answer is used to check the correctness of your code. 5. Your program must return to the operating system via the jr instruction. Programs that include infinite loops or produce simulator warnings or errors will receive zero credit. 6. Your solution must include proper documentation. 7. Your solution must be properly uploaded to Canvas before the scheduled due date. HW1-3: The goal of this part is for you to install MiSaSiM, modify a short assembly program HW1-3-shell.asm, simulate, test and debug it in MiSaSiM. The MiSaSIM simulator can be installed according to the instructions at Copy or rename the shell program to HW1-3.asm and modify it to determine whether or not the value at location XLoc is a 16-Harshad number with mirror factors and if so, put a l in the memory location labeled Result, otherwise put a 0 in that location. For this exercise, it might be helpful to open the Options menu (the wrench on the toolbar) and select "hexadecimal as the display base. Two constraints apply for this assignment only: Do not write values to registers $0, $29, $30, or $31. Do not use helper functions or function calls (JAL instruction). In order for your solution to be properly received and graded, there are a few requirements. 1. The file must be named HW1-3.asm. 2. Your name and the date should be included in the beginning of the file. 3. The starting shell program should not be modified except for the replacement of the com- ment "# write your code here...' 4. Your program must store its result at the memory location labeled Result when it returns. This answer is used to check the correctness of your code. 5. Your program must return to the operating system via the jr instruction. Programs that include infinite loops or produce simulator warnings or errors will receive zero credit. 6. Your solution must include proper documentation. 7. Your solution must be properly uploaded to Canvas before the scheduled due date

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Excel caculation on cascade mental health clinic

Answered: 1 week ago