Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please do not write in paper, write the code clear and easy to understand with explanation 4. We have not studied branch instructions yet, but
please do not write in paper, write the code clear and easy to understand with explanation
4. We have not studied branch instructions yet, but they are actually quite easy to understand. In a branch instruction, a test is made for a certain condition, normally comparing two registers or perhaps determining the value of a single register. Consider the instruction "branch if less than zero:" An example is bltz St4,next. What this branch instruction instructs the computer to do is to evaluate the contents of the register St4. If the contents are less than zero ("ltz"), then the computer executes the instruction labeled "next" immediately after the branch. That instruction may be anywhere in the program, but if the contents of St4 are less than 0, the computer immediately finds the instruction labeled "next" and executes it, then continues on from that point executing instructions. If the contents of St4 are either zero or positive, the computer simply executes the instruction following the branch instruction. Let's use that simple branch instruction to do the following: Load each of the two words declared in the data statement shown to the right into registers, and then determine if either is a negative number. If either number is negative, print it out using syscall 1. If a number is not negative (0 or positive), simply ignore it. End the program with a syscall 10. Note: you can declare words as either decimal or hexadecimal. SPIM understands both number systems. .data datal: word 0x6372eef5 data2: word 0x91abccd2 5. In a data statement, declare six words, aa, bb, cc, dd, ee, and ff. The words dd-ff are basically placeholders; declare each with a value of 0. The value of aa 159, the value of bb is 27, and the value of cc is 42. In the program square aa, bb, and cc, and store the results in dd, ee, and ff, respectively. Subtract ee from dd, and then subtract ff from that result. Output the value of dd- ee -ff to the console, then stop the program as usual. /pid-1
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