We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
Any comment is welcome, and no mail is forthcoming,
wat has happened to the dinosaur,
went extinct millions of years ago
Erik
The compiler (any compiler) is free to do as it wishes with the registers.
If the specific register usage is important to you, then you have no choice but to write in assembler
"...I try to complier same code twice times, one time, it will sotre into register, one time is not..."
BTW: this is a perfect illustration of why any attempt to write accurate timing loops in 'C' is futile!