Why this code is giving exception at storing the float number. I am unable to figure out the problem. Here is the code:
li $t1,0
Loop:
add $t0,$t1,$s0
li $v0,6
syscall
mov.s $f1,$f0
swc1 $f1,0($t0)
addi $t1,$t1,4
beq $t1,20,Mult
j Loop
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are probably getting an unalignment exception executing
swc1 $f1,0($t0).The instruction
swc1needs the second argument to be an effective memory address aligned at word boundary. This means that the two least significant bits of this effective memory address (in your case the address stored at$t0) need to be zero.The code you posted does not show the initialization of
$s0which is likely to have at least one of the two least significant bits with 1.To fix your code, ensure that
$s0starts with those bits in zero so the effective memory address used inswc1is word-aligned.If the initialization of
$s0is done withla $s0, labelyou might want to use.align 2directive when you declare the buffer to store the data, e.g.: