This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to write code to help complier store variable into register??

Hi all

I try to use Generate Assembler SRC file to see the assembler code ,I found the complier is smart
enough to stroe variable into register sometimes ,
but sometimes is strange. I try to complier same code
twice times ,one time, it will sotre into register ,
one time is not,Why??

The first time ,I got this

?XD?int0_hander?MAIN
SEGMENT XDATA OVERLAYABLE

RSEG ?XD?_int0_hander?MAIN
?int_hander?BYTE:

msgsts?040: DS 1

intsts?041: DS 1

The second time,I got this

msgsts?040 is stroe in R2 register

intsts?041 is also stroe in R2 register

Another example,I have a interrupt handler function
it just read clear the interrupt status register

void irc_int_hander(void)
{
 intsts = ptr_reg[IRC_INT_STS];

dma_task_scheduler(0,0,0);

}

why "insts" will not store into register ,there is R2,R6 are free, but others more complex code can do this well.

any comment is welcome

Best Regards

0