• m68k assembly question: jsr vs. bsr

    From John Paul Adrian Glaubitz@21:1/5 to All on Wed Feb 1 23:20:01 2023
    Hi!

    Can anyone answer this question regarding the difference between "bsr" and "jsr":

    https://github.com/llvm/llvm-project/issues/60354#issuecomment-1412018845

    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer
    `. `' Physicist
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geert Uytterhoeven@21:1/5 to [email protected] on Thu Feb 2 08:50:01 2023
    Hi Adrian,

    On Wed, Feb 1, 2023 at 11:17 PM John Paul Adrian Glaubitz <[email protected]> wrote:
    Can anyone answer this question regarding the difference between "bsr" and "jsr":

    https://github.com/llvm/llvm-project/issues/60354#issuecomment-1412018845

    "jsr" is an absolute jump to a subroutine.
    "bsr" is a relative jump (8-bit, 16-bit, or 32-bit signed offset) to a subroutine,
    i.e. typically for calling a nearby function.

    There's also "jbsr", which is an assembler macro that picks the most appropriate: bsr does not need relocation, but bsr.l is 68020+ only.

    Gr{oetje,eeting}s,

    Geert

    --
    Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

    In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
    -- Linus Torvalds

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Schwab@21:1/5 to Geert Uytterhoeven on Thu Feb 2 20:20:01 2023
    On Feb 02 2023, Geert Uytterhoeven wrote:

    Hi Adrian,

    On Wed, Feb 1, 2023 at 11:17 PM John Paul Adrian Glaubitz <[email protected]> wrote:
    Can anyone answer this question regarding the difference between "bsr" and "jsr":

    https://github.com/llvm/llvm-project/issues/60354#issuecomment-1412018845

    "jsr" is an absolute jump to a subroutine.
    "bsr" is a relative jump (8-bit, 16-bit, or 32-bit signed offset) to a subroutine,
    i.e. typically for calling a nearby function.

    jsr/jmp also take pcrel, but bsr/bra with 8-bit disp is shorter.

    --
    Andreas Schwab, [email protected]
    GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
    "And now for something completely different."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)