spim - Mips div.s syntax error -
i using qtspim 9.9.1 write computer architecture course homework had syntax error when use div.s operator it's ok when use div. error appears when try float user disappears when integer. here code :
.text main: # print "this program solves equation of style a*x + c = 0, print out result on console." la $a0, hello_msg # load address of hello_msg $a0. li $v0, 4 # 4 print_string syscall. syscall # syscall. # print "enter (a) value please :" la $a0, enter_a_msg # load address of enter_a_msg $a0. li $v0, 4 # 4 print_string syscall. syscall # syscall. ## (a) user, put $t0. li $v0, 6 # load syscall read_float $v0. syscall # make syscall. move $t0, $f0 # move number read $t0.////////here got error////// # print "enter (c) value please :" la $a0, enter_c_msg # load address of enter_c_msg $a0. li $v0, 4 # 4 print_string syscall. syscall # syscall. ## (c) user, put $t1. li $v0, 6 # load syscall read_float $v0. syscall # make syscall. move $t1, $f0 # move number read $t1.///////also here # compute (x), put $t2. neg $t3, $t1 # -c $t3. div.s $t2, $t3, $t0 # x = -c / $t2.//// here error # print "value of (x) :" la $a0, result_msg # load address of result_msg $a0. li $v0, 4 # 4 print_string syscall. syscall # syscall. # print (x) value . move $a0, $t2 # move (x) value $a0. li $v0, 1 # load syscall print_int $v0. syscall # make syscall. li $v0, 10 # 10 exit syscall. syscall # syscall. # data program: .data hello_msg: .asciiz "this program solves equation of style a*x + c = 0,\nprints out result on console.\n" enter_a_msg: .asciiz "enter (a) value please :" enter_c_msg: .asciiz "enter (c) value please :" result_msg: .asciiz "value of (x) :" # end equation.asm
move $t0, $f0
to convert floating-point register integer , move general-purpose register should use this:
cvt.w.s $f0, $f0 mfc1 $t0, $f0 if wanted move $f0 floating-point register should use e.g.:
mov.s $f1,$f0 div.s $t2, $t3, $t0
div.s works floating-point registers ($f0-$f31), not general-purpose registers ($an, $tn, $vn , on). refer mips floating-point instruction set list.
Comments
Post a Comment