Storing a user’s input in MIPS

You are not using the read string system call correctly. I suspect you haven’t actually looked at the documentation on how to use it. You have to pass two arguments: So you should do something like: Nevertheless, this shouldn’t cause a crash since $a0 should still hold the address of firstPromptString that you set up for the printing, earlier, and that … Read more

what is the use of ori in this part of MIPS code?

The two instructions load a constant of 0x05 into register $s0 and 0x07 into register $s1. MIPS doesn’t has an instruction that directly loads a constant into a register. Therefore logical OR with a operand of zero and the immediate value is is used as a replacement. It has the same effect as move. Translated … Read more

What are .S files?

.S files are source code files written in assembly. Assembly is an extremely low-level form of programming. The files contain assembly instructions to the processor in sequential order and are typically compiled based on a selected architecture. Examples of such files are often seen in the linux kernel for specific architectures, e.g. x86, sparc, ARM, … Read more

What does movslq do?

It’s movsxd: https://www.felixcloutier.com/x86/MOVSX:MOVSXD.html. You could figure this out yourself by assembling it with an AT&T assembler and disassembling with an Intel-syntax disassembler. (e.g. objdumpd -d -Mintel foo.o) And yes, it does 32->64-bit 2’s complement sign extension, extending by copying the sign-bit of the source to all the new upper bits. (i.e. dst[63:32] = src[31], and dst[31:0] = src[31:0].) Fun fact: it’s … Read more

What is the difference between la and li in opcodes in MIPS?

They’re fairly similar, as both are (mostly) used for loading immediate values. Both of them are also pseudo-instructions, so it’s really up to each assembler that supports them to determine exactly how they should function. li stands for Load Immediate and is a convenient way of loading an immediate up to 32 bits in size. Instructions like addi and ori can … Read more

What exactly does the lb instruction do?

The answer would be c) 0xffffff88. The lb instructions sign-extends the byte into a 32-bit value. I.e. the most significant bit (msb) is copied into the upper 24 bits. 0x88 == 0b10001000, i.e. the msb is 1. So the upper 24 bits will be 0b111111111111111111111111 == 0xffffff.