-Obsr: Generate Always Near Calls

Group

OPTIMIZATIONS

Scope

Function

Syntax
-Obsr

Arguments

None

Default

None

Defines

None

Pragmas

None

Description

This option forces the compiler to always generate near calls, i.e. use BSR instruction instead of a JSR in order to reduce code size. Without this option the compiler checks the range of the call to determine if a BSR can be generated instead of a JSR.

Example
extern int f(void);

int g(void) {

  return f();

The following listing shows an example without -Obsr:

Listing: Example - Without -obsr


  0000 b700             STA        __OVL_g_p0
  0002 45               SHA

  0003 b700             STA        __OVL_g_14__PSID_75300004

  0005 42               SLA

  0006 b701             STA        __OVL_g_14__PSID_75300004:1

    4:    return f();

  0008 a600             LDA        #__OVL_g_14__PSID_75300001

  000a bd0000           JSR        %FIX16(f)

  000d 4e000f           LDX        __OVL_g_p0

  0010 4e000e           MOV        __OVL_g_14__PSID_75300001,D[X]

  0013 2f               INCX

  0014 4e010e           MOV        __OVL_g_14__PSID_75300001:1,D[X]

  0017 b600             LDA        __OVL_g_14__PSID_75300004

  0019 45               SHA

  001a b601             LDA        __OVL_g_14__PSID_75300004:1

  001c 42               SLA

    5:  }

  001d be               RTS

The following listing shows an example with -Obsr:

Listing: Example - Without -obsr

  0000 b700             STA        __OVL_g_p0

  0002 45               SHA

  0003 b700             STA        __OVL_g_14__PSID_75300004

  0005 42               SLA

  0006 b701             STA        __OVL_g_14__PSID_75300004:1

    4:    return f();

  0008 a600             LDA        #__OVL_g_14__PSID_75300001

  000a ad00             BSR        PART_0_7(f)

  000c 4e000f           LDX        __OVL_g_p0

  000f 4e000e           MOV        __OVL_g_14__PSID_75300001,D[X]

  0012 2f               INCX

  0013 4e010e           MOV        __OVL_g_14__PSID_75300001:1,D[X]

  0016 b600             LDA        __OVL_g_14__PSID_75300004

  0018 45               SHA

  0019 b601             LDA        __OVL_g_14__PSID_75300004:1

  001b 42               SLA

    5:  }

  001c be               RTS