Mips sll weird behaviour - mips

My $t4 was originally 4.
I thought sll by 2 is suppose to times 4, which should make my t4=16.
But apparently the result is 10, why is this the case?

Turns out QtSpim shows values in hex. I am deeply frustrated with myself.

Related

How do the lines of lw add and sw translate to the chart below?

I'm just getting started learning this material. I don't understand where the 35, 9, 8 and such numbers in the chart come from. All I see in the assembly lines is the number 300.
https://ibb.co/ZYrk42H
35 is the opcode for lw, 9 is the actual register number for $t1 and 8 is the actual register number for $t0.
$t0 is a friendly register name — see here, you can see that $t0 is also $8 (aka register number 8). As you can imagine, the hardware doesn't care about the friendly names, and only wants to see the actual numbers.
35 is the opcode, as you can see here, lw has opcode 100011, which is 35

MIPS Program not Printing Primes Correctly

I have an assignment that requires us to write two functions in MIPS: One that determines if a number is prime or not, and another that finds all the primes between 3 and 102 inclusive and prints them out. Obviously, the second one uses the first; this is meant to be an exercise in jumping and branching. The source code we are given already cleans up the stack and registers, etc., for us, and provides a function to print the number in $a0, so all we need to do is the aforementioned functions. No matter what I do, my program will always just print "1" and exit, even though it should be looping over many numbers. I feel like the mistake I have made is simple, like not loading anything into a register that needs it or overlooking something similarly simple, but I'm still new to MIPS and debugging assembly code is honestly a nightmare. Here are the two functions I've written:
Here's the one for checking if a number is prime:
ori $s0,$a0,0 #make a copy of the argument
ori $t0,$s0,0 #using temp registers is good
ori $s1,$s0,0 #make another copy to use as the loop-end check
li $t2,2 #use 2 as the divisor, makes it easier to check
li $v0,0 #using "not prime" as the base case
prime_test:
slt $t1,$t2,$s1 #check if we're above the ceiling
beq $t1,$zero,found_prime
div $t0,$t2 #check if number is divisible by 2
mfhi $t3 #get remainder from hi
beq $t3,$zero,not_prime #if hi=0, it's not a prime
addi $t2,$t2,1
j prime_test
not_prime:
add $v0,$zero,$zero #return false (0) if not prime
found_prime:
jal print_number #if it's prime, print it
And here's the one for looping and checking from 3 to 102:
li $t0,102 #upper boundary
li $a0,3 #lower boundary
prime_loop:
slt $t5,$a0,$t0
beq $t5,$zero,found_all_primes
jal is_prime
slt $t2,$zero,$a0
bne $t2,$zero,prime_detected
prime_detected:
addi $a0,$a0,1 #increment the counter
j prime_loop
found_all_primes:
Honestly, I think the error is probably in the function that loops; I'm pretty sure my logic for testing if a number is prime is sound, but I could have easily overlooked something. Again, don't worry about it looking like registers aren't being restored properly, that's all taken care of already.

MIPS can li and sb be combined into one instruction?

I am new to MIPS so I apologize if this is a dumb question. I can't seem to find an answer to this question on the web. Can these two instructions be written as one instruction? The code I have below feels redundant:
li $t0, 23
sb $t0, 0x10010000
Thanks in advance for your responses!
No, they can´t be combined. There is no such thing as a "store inmediate to memory" instruction.
Mips implements a simple ISA. Being a RISC architecture, the only way to store a byte in memory is to use the sb instruction.

How does lw in mips actually work?

Is this statement a valid one?
lw $t0, 21($s0)
$s0 contains the decimal 2022.
In my opinion this is invalid, because based on what I know, The address specified by the offset + the register should always be a multiple of 4. Is this correct or not?
An extension to this question based on the answer provided, The exception will arise just on looking at the address at $s0 or after the computation of the address 21+$s0 ?
The execution of that instruction when $s0 contains the decimal 2022 will raise an exception, due to the effective address (2041=2022+21) is not aligned properly.

How to get LSB bit in MIPS?

Is there a short way to check/get for least significant bit in a 32-bit integer, in MIPS? It is obviously set for the odd numbers and an algorithm which checks for the whole number is odd or even can decide for this. But I just wonder is there a better way to do this...
andi $t0, $s0, 1 will get the least significant bit of $s0 and put it in $t0.