-Asr: It is Assumed that HLI Code Saves Written Registers

Group

CODE GENERATION

Scope

Function

Syntax
  -Asr
  
  
Arguments

None

Default

None

Defines

None

Pragmas

None

Description

With this option set, the compiler assumes that registers touched in HLI are saved or restored in the HLI code as well. If this option is not set, the compiler saves and restores the registers as needed.

Listing: Sample Source Code for the Two Following Examples


void bar(char);
char PORT;

void myfun(void) {

  PORT = 4;

  asm {

    lda   #4

    sta   PORT

  }

  bar(4);

}
Listing: Code Sample Without the -Asr Option


  4:    PORT = 4;
0000 a604             LDA   #4

0002 c70000           STA   PORT

  5:    __asm {

  6:    lda   #4

0005 a604             LDA   #4

  7:    sta   PORT

0007 c70000           STA   PORT

  8:  }

  9:    bar(4);

000a a604             LDA   #4

000c cc0000           JMP   bar

With the -Asr option set (as shown in the following listing), the compiler assumes that the A register is the same as before the __asm block. However, in our example we do NOT save or restore the A register, so the compiler generates incorrect code.

Listing: Code Sample With the -Asr Option


  4:    PORT = 4;
0000 a604             LDA   #4

0002 c70000           STA   PORT

  5:    __asm {

  6:      lda #4

0005 a604             LDA   #4

  7:      sta PORT

0007 c70000           STA   PORT

  8:   }

  9:   bar(4);

000a cc0000           JMP   bar