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
Thanks all
I just for fun to know why complier wiil sometimes smart ,and sometimes is not??
I think for complier ,it must follow some rules to complier our code,right??
So if I know the rules to mark code small and fast why not to do it??
Code1
uchar onoff = ptr_reg[y] ptr_reg[x] = onoff;
Code2
uchar onoff = ptr_reg[y] ptr_reg[x] |= onoff;
The code2 just change = to |= ,but the code size and speed is fast then code1!! Best regards
http://www.keil.com/support/man/docs/c51/c51_xc.htm
user.it.uu.se/.../engblom-esc-sf-2001.pdf