I am doing my homework for my computer organization class and I'm running into a small problem. Before I explain what I've done, what I expect to happen and what is happening, I want to assure everyone that I am not looking for an answer to my homework, but a solution to the problem I am having.
First, I am to write a simple arithmetic code for:
D = A^4 + B^6 / 3C - 2B
The code I have written is as follow:
main: #start of main program and load initial values to temporary registers li $t0 3 # A=3 li $t1 6 # B=6 li $t2 9 # C=9 # Multiply 3*3*3*3 to get the power of 81 mul $s1, $t0, $t0 # E = A*A mul $s2, $t0, $t0 # E = A*A mul $s3, $s1, $s2 # E = E*E # Multiply 6*6*6*6*6*6 to get the power of 46656 mul $s4, $t1, $t1 # F = B*B mul $s5, $t1, $t1 # F = B*B mul $s6, $t1, $t1 # F = B*B mul $s7, $s4, $s5 # F = F*F mul $s8, $s6, $s7 # F = F*F # Add the products of A and B add $t7, $s8, $s3 # G = F*E # Multiply C*3 & B*2 mul $t6, $t2, 3 # H = C*3 mul $t5, $t1, 2 # I = B*2 # Subtract the products of H and I sub $t4, $t6, $t5 # J = C-B # Divide the sum of A and B by the difference of H and I div $s0, $t7, $t4 # D = G/J
Now, the problem that happens is when I open my .asm file with this code with PCSpim. PCSpim will stop working and Microsoft forces me to close the program. I don't know where the problem is occurring, but as I was writing the code in the beginning I tested it each time to make sure what I was doing ended up as what I wanted and it was working. So, I just went on to finishing the code then that's where the problem started. Also, I was wondering if someone could explain to me how to use the move pseudoinstruction, as I was told by my professor that this instruction will help limit the amount of machine code lines.
Edited: I found the problem. It was on line 36. I had #t7 rather than $t7, which was causing the compiler to crash. However, I still would like some advice on how to use the move pseudo instruction. I would like to shorten my code to make it more efficient. Thanks again!