Logic Statements in MIPS

.pdf

School

San Diego State University *

*We aren’t endorsed by this school

Course

240

Subject

Electrical Engineering

Date

Jan 9, 2024

Type

pdf

Pages

2

Uploaded by ConstableRam18621 on coursehero.com

1. Write a code fragment to multiply the content of register $t0 with 8 without using mult or mul instruction. li $t0, 3 sll $t0, $t0, 3 # 2^3 = 8 2. Write a code fragment to multiply the content of register $t0 with 80 without using mult or mul instruction. sll $t1, $t0, 4 # Multiply previous result ($t1) by 8 sll $t2, $t1, 3 # Subtract 48 from $t2 to get 80 subu $t0, $t2, 48 3. Write a code fragment to clear bits 2, 4, 6, and 7 of the register $t2. Store the result in $s0 li $t2, 0x199 # 8 bits set li $s0, 0010 1101 not $s0, $s0 and $s0, $t2, $s0 # Clear bits 4. Write a code fragment to set bits 7, 6, 5, 3, and 0 of the register $t2. Store the result in $s0 li $t1, 0b111010111 # Binary: 111010111 (bits 7, 6, 5, 3, and 0 set to 1) or $s0, $t2, $t1 5. Write a code fragment to toggle bits 7, 2, and 0 of the register $t2. Store the result in $s0 li $t1, 0b10000101 xor $s0, $t2, $t1 # XOR to toggle bits
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help