Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean to "Long call" a function in MIPS

Tags:

assembly

mips

I am coding a program that uses interrupt handling to play an ascii-based game in MIPS. I am told to "Long call" my main function from my handler. My handler takes place under .ktext 0x80000180 and looks like this:

.ktext  0x80000180

    move    $k1, $at

    beq $13, 0, keyboard
    li  $v0, 10 # Do nothing and exit
    syscall

    keyboard: # else check interupt level
    la  $t9, 0xffff0000
    beq $t9, 1, continue

    li  $v0, 10     # Do nothing and exit
    syscall
    continue:

    jal frogger     # call frogger function
    mtc0    $0, $13     # set cause register to 0

    mfc0    $k0, $12        # Fix status register
    andi    $k0, 0xfffd # clear EXL bit
    ori $k0, 0x1        # Enable interrupts
    mtc0    $k0, $12        # Store value back into status register


    move    $at, $k1

    eret

The problem is with the line jal frogger, it says Error in F:\Users\Matt\WSU\Cpts 260\HW9\HW9.asm line 32: Jump target word address beyond 26-bit range.

Is it something wrong with the rest of the code or is there a special way to call a function from the .ktext?

Thanks!

like image 371
Matt Hintzke Avatar asked Sep 16 '25 00:09

Matt Hintzke


1 Answers

Replace jal frogger by something like:

  la    $t9, frogger
  jalr  $t9

JALR uses an absolute address in MIPS.

like image 106
markgz Avatar answered Sep 18 '25 19:09

markgz