Anyone can help me sovle the error Im wokring on the code in

Anyone can help me sovle the error, I\'m wokring on the code in MIPS which try to add two float numbers and display the value. It should shows like: 40.25. But it shows 0.00000000 in the console. So please help me fix it. This below is my code.

.data
number1: .float 7.5
number2: .float 32.75

.text
.globl main

main:
lwc1 $f2, number1
lwc1 $f4, number2

add.s $f0,$f2,$f4
li $v0,2
syscall

li $v0,10
syscall

Solution

.text
main:

First integer:

la $a0,st2
$a0 li $v0, 4
syscall
li $v0, 5
syscall
move $s1, $v0

Second integer:

la $a0,st3
$a0 li $v0, 4
syscall
li $v0, 5
syscall
move $s2, $v0

Adding both integers:

add $s0,$s2,$s1

Display:

la $a0,st4
li $v0,4
syscall
li $v0,1
move $a0,$s0
syscall
la $a0,st1
li $v0,4
syscall

Move in temporary registers:

move $t3,$s0
move $t2,$s2
move $t1,$s1

Counter for first number to be printed in binary:

li $s5,32
loop1:
rol $t1,$t1,1
and $t0,$t1,1
add $t0,$t0,48
move $a0,$t0
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5
bne $s5,$zero,loop1
Print a line
la $a0,st6
li $v0,4
syscall

Counter for second number to be printed in binary:

li $s5,32
loop2:
rol $t2,$t2,1
and $t0,$t2,1
add $t0,$t0,48
move $a0,$t0
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5
bne $s5,$zero,loop2

Print a dotted line:

la $a0,st5
li $v0,4
syscall

Counter for result in binary:

li $s5,32
loop:
rol $t3,$t3,1
and $t0,$t3,1
add $t0,$t0,48
move $a0,$t0
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5
bne $s5,$zero,loop

Close the program:

li $v0,10
syscall
.end main


Output:


.data
st1: .asciiz \"\ In binary:\ \"
st2: .asciiz \"\ Enter 1st Integer:\"
st3: .asciiz \"\ Enter 2nd Integer:\"
st4: .asciiz \"\ Your answer is: \"
st5: .asciiz \"\ --------------------------------\ \" st6: .asciiz \"\ \"
.text
main:

Anyone can help me sovle the error, I\'m wokring on the code in MIPS which try to add two float numbers and display the value. It should shows like: 40.25. But
Anyone can help me sovle the error, I\'m wokring on the code in MIPS which try to add two float numbers and display the value. It should shows like: 40.25. But
Anyone can help me sovle the error, I\'m wokring on the code in MIPS which try to add two float numbers and display the value. It should shows like: 40.25. But

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site