MIPS address out of range 0x00000008, problems durig loading double from $sp

0

I have to write a program that will calculate factorial of doubles in MIPS. Here is my attempt, but I got out of range error and I do not know how to deal with it

The exercise description

.data

    x: .double 2.1
    theAnswer: .double 0.0
    one: .double 1.0

.text

.globl main


main:


    l.d $f2, one
    l.d $f14, x 
    jal mfact
    li $v0, 3
    s.d $f0, theAnswer
    l.d $f12, theAnswer
    syscall
    li $v0, 10
    syscall

.globl mfact
mfact:

    andi $sp, 0xfffffff8
    addi $sp, $sp, -16

    sw $ra, ($sp)
    s.d $f12, 8($sp)

    #base case
    l.d $f0, one
    c.le.d $f14,$f0
    bc1t exit


    mov.d $f12, $f14
    sub.d $f14, $f14, $f2
    jal mfact
    #multipling the numbers 
    mul.d $f0, $f12, $f0    

    exit:   #poping out
        lw $ra, ($sp)
        l.d $f12, 8($fp) #there is the RUNTIME EXCEPTION : OUT OF RANGE 0x0000008
        addu $sp,$sp,16
        jr $ra
mips
precision
factorial
outofrangeexception
asked on Stack Overflow Oct 20, 2018 by Yernur Sabyrzhanov • edited Oct 20, 2018 by phuclv

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0