What does it mean to "Long call" a function in 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

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

    li  $v0, 10     # Do nothing and exit

    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


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?


asked on Stack Overflow Dec 13, 2012 by Matt Hintzke

3 Answers


A long call uses the full (32-bit) address of the target. This is different from your jal call which can only encode 26 bits of address in the instruction and might be PC-relative (I don't remember whether this is the case or not). To do a long call, you would construct or load the address to a register and then branch to that.


Replace jal frogger by something like:

  la    $t9, frogger
  jalr  $t9

JALR uses an absolute address in MIPS.

answered on Stack Overflow Dec 14, 2012 by markgz

I had the same issue. I figured out that my function was being defined in the .data section. Once I put it under the .text section, it ran perfectly fine.

Also, I'm brand new to MIPS so idk what .ktext is. Sorry I can't help there.

answered on Stack Overflow Oct 24, 2020 by Zack Jandali • edited Oct 26, 2020 by abhinav3414

User contributions licensed under CC BY-SA 3.0