-Ontc: Disable tail call optimization

Group

OPTIMIZATIONS

Scope

Function

Syntax
-Ontc

Arguments

None

Default

None

Defines

None

Pragmas

None

Description

By default, the compiler replaces trailing calls (JSR/BSR) with JMP instructions if the function does not contain any other function calls. This allows the compiler to remove all the entry and exit code from the current function.

Example
void f1() {

  i++;

}

void f2() {

  f1();

}

The following listing shows an example without -Ontc:

Listing: Example - Without -Ontc

Function: f1

Source  : d:\junk\rs08\test.c

Options : -Lasm=%n.lst

    7:    i++;

  0000 3c01             INC        i:1

  0002 3602             BNE        L6

  0004 3c00             INC        i

  0006          L6:

    8:  }

  0006 be               RTS

    9:

   10:  void f2() {

Function: f2

Source  : d:\junk\rs08\test.c

Options : -Lasm=%n.lst

   11:    f1();

  0000 3000             BRA        PART_0_7(f1)

   12:  }

The following listing shows an example with -Ontc:

Listing: Example - With -Ontc

Function: f1

Source  : d:\junk\rs08\test.c

Options : -Lasm=%n.lst -Ontc

    7:    i++;

  0000 3c01             INC        i:1

  0002 3602             BNE        L6

  0004 3c00             INC        i

  0006          L6:     

    8:  }

  0006 be               RTS        

    9:  

   10:  void f2() {

Function: f2

Source  : d:\junk\rs08\test.c

Options : -Lasm=%n.lst -Ontc

  0000 45               SHA        

  0001 b700             STA        __OVL_f2_14__PSID_75300003

  0003 42               SLA        

  0004 b701             STA        __OVL_f2_14__PSID_75300003:1

   11:    f1();

  0006 ad00             BSR        PART_0_7(f1)

  0008 b600             LDA        __OVL_f2_14__PSID_75300003

  000a 45               SHA        

  000b b601             LDA        __OVL_f2_14__PSID_75300003:1

  000d 42               SLA        

   12:  }

  000e be               RTS        

   13: