CODE GENERATION
Function
-Asr
None
None
None
None
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.
void bar(char); char PORT; void myfun(void) { PORT = 4; asm { lda #4 sta PORT } bar(4); }
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.
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