For these programming exercises, use only those instructions that have been disc
ID: 3738064 • Letter: F
Question
For these programming exercises, use only those instructions that have been discussed so far in these notes:
USING MIPS
Write a program that computes the sum:
Do this, as above, by using the j instruction to implement a non-ending loop. Before the loop, initialize a register to zero to contain the sum, initialize another register to one to be the counter, and another register to 10110. Inside the loop add the counter to the sum, increment the counter, and jump to the top of the loop.
However, now, at the top of the loop put in a beq instruction that branches out of the loop when the counter equals 10110. The target of the branch should be something like this:
Now run the program by setting the value of the PC to 0x400000 (as usual) and entering 500 or so for the number of Multiple Steps (F11). Your program will not need so many steps, but that is OK. The excess steps will be used up repeatedly executing the statment labeled "exit".
add divu mflo sll addi j mult sra addiu lb multu srl addu lbu nor sub and lh or subu andi lhu ori sw beq lui sb xor bne lw sh xori div mfhi