I'm struggling with this question:
Prompt the user to enter a number, print the number in 16-bit two's complement
To print the number you will print each bit as either the string "1" or the string "0", using a loop that will print one bit in each iteration. Start printing with bit 15. (Recall that we number the bits starting from 0 at the low order bit.) In your loop test bit 15, and then print either "1" or "0". Use a shift instruction to get the next bit into position 15 before repeating.
I unfortunately missed a lecture that was about shifts and using masks, so I don't really have much understanding of how I would go about doing this lab. How can I print a specific bit of a number? I understand that I just keep printing bit 15, and then doing a shift left, but I have no idea this would be done in MIPS. Any help would be very much appreciated.
EDIT:
I understand the shifting perfectly, it's just printing the bit thats confusing me.
For example, if the number I wanted to convert to two's complement was 25 and is in register $t0.
First I print the 15th bit. Then I do a shift left. And then I repeat 15 times.
It should look something like this:
# Print bit
sll $t0, $t0, 1
I just don't get how to print the first bit at spot 15.