Question

Write a sequence of MIPS instructions to do the following: set $t1 to 1 if the...

Write a sequence of MIPS instructions to do the following: set $t1 to 1 if the contents of $s0 is an even number and set $t1 to 0 otherwise.

Please do not use the division instruction in you code. Instead, you could use some logical instruction to test if a number is even or odd.       

0 0
Add a comment Improve this question Transcribed image text
Answer #1

li $t1, 1
and $t1, $s0, 1   # set $t1 with left most bit of $s0. so, if $s0 is even then $t1 is set to 0 and if $s0 is odd then $t1 is set to 1.

Add a comment
Know the answer?
Add Answer to:
Write a sequence of MIPS instructions to do the following: set $t1 to 1 if the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. The MIPS instruction set includes several shift instructions. They include logical-shift-left ...

    1. The MIPS instruction set includes several shift instructions. They include logical-shift-left (sll), logical-shift-right (srl), and arithmetic-shift-right (sra). [2 +2 4 points] a) Why does not MIPS offer an "arithmetic-shift-left (sla)" instruction? b) Write a MIPS code to implement the logical-shift-left (sll) instruction for a machine that did not have this particular instruction? In other words, you have to write the equivalent of the sll instruction using mul, add and other instructions. Try writing the equivalent of sll Ss1, Ss2,...

  • Write a sequence of MIPS instructions to find the absolute value of the value in register...

    Write a sequence of MIPS instructions to find the absolute value of the value in register $s0 and store it into register $t0. Assume you do not have access to multiplication instructions. Use as few instructions as possible. You do not have to assemble your code for this question, but you may do so to validate that it works.

  • Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of...

    Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of MIPS instructions to accomplish the required computation. (8 Points) 1) bgt $t1, 100, Label # bgt means branch if greater than 2) ble $s2, 10, Next # ble means branch if less than or equal 3) ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0 4) neg $s5, $s4 # $s5 will have the...

  • MIPS Programming Assignment 4 (logical operations) Please write a complete MIPS assembly language programs for the...

    MIPS Programming Assignment 4 (logical operations) Please write a complete MIPS assembly language programs for the following questions and print a hardcopy of your code to submit 1. Swap each pair of elements in the string "chararn be an even number of characters in "chararray". (see loop4.a) 2 "numbers" is an array of five words. Catculate the sum of aftetements in "number muttiples of 4. Use the and instruction, not div or remfor thisquestion(S 3. "number" is a word. Write...

  • Usc only the following MIPS instructions for assignment questions 3, 4 and 5: add, sub, addi,...

    Usc only the following MIPS instructions for assignment questions 3, 4 and 5: add, sub, addi, j, beq, bne, lw, sw. You may not need as many lines as we provide space for 4. (4 pts) Write a MIPS program starting at address 20 that writes a value of 488 to register $7. Next, you will test if register $10 is equal to register $7. If the values are equal, continue execution at address 48; otherwise set the value in...

  • Please solve the following 5. Given the following MIPS instructions with their corresponding addresses answer the...

    Please solve the following 5. Given the following MIPS instructions with their corresponding addresses answer the following questions. a. Instruction Start: Address 1000 s1l St1, Ss2, 4 1w $t0, 128(St) bne St0, S t1. Exit Here 004 Here 1008 012 .. Exit: 1096 Write the machine code for cnch of the above MIPS instructions (5 pts) i. i. Find the total number of bits required to store the instructions (3 pts) Scanned by CamScanner 5. Given the following MIPS instructions...

  • For the following C statement, write a minimal sequence of MIPS assembly instructions that does the...

    For the following C statement, write a minimal sequence of MIPS assembly instructions that does the identical operation. Assume $t1 = A, $t2 = B, and $s1 is the base address of C. A = C[0] << 4;

  • 4. (3 pts. each) Write the hexadecimal representation of each MIPS assembly instruction: (4.1) sub $s3,...

    4. (3 pts. each) Write the hexadecimal representation of each MIPS assembly instruction: (4.1) sub $s3, $t1, $s2 (4.2) bne $t3, $t4, 18 (4.3) sll $s0, $t5, 2 5. (20 pts.) Consider the following C (or java) code: else f=f+2; By storing the value of j in Ss0, write a sequence of MIPS assembly instructions that will execute these lines of code for the following two cases: (5.1) assuming that the values of f, g and h are stored in...

  • For project six, you will be given a list of MIPS machine language code instructions in...

    For project six, you will be given a list of MIPS machine language code instructions in memory. Your task is to Disassemble the contents and show the MIPS instructions. Make sure to calculate the correct branch target address for each branch instruction. If the resulting BTA happens to be outside the given code, this is OK, just make sure you calculate the BTA correctl Contents Address 0x00400024 Ox3c111001 0x00400028 Ox3410000a 0x0040002c Ox2a01000a 0x00400030 0x14200006 0x00400034 Ox8e280000 0x00400038 Ox01094820 0x0040003c Ox22100001...

  • 5. Write the MIPS minimal sequence of instructions for the following C procedure code: int array_sum...

    5. Write the MIPS minimal sequence of instructions for the following C procedure code: int array_sum (a[], b[])                                  { int i;                                       i =1; for (i=1; i<100; i=i+1) { b[i] = D + a[i-1] + a[i] + a[i+1] ;}                                                             } Assume that: a and b are arrays of words and the base address of “a” is in $a0 and the base address of “b” is in $a1, Register $S1 is associated with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT