|
From: Bernhard H. <ber...@be...> - 2003-07-14 21:29:25
|
> <test.asm snip> > 188: mov r2,#0x00 > 191: mov r3,_main_response_1_1 > 193: mov a,r3 > 195: orl a,r2 > 196: mov _P_Data,a > > This part is a huge simplification of my macro WRITE_P_DATA. With the > given values of On_Mask and Inv_Mask, almost the entire expression can be > reduced. I could do this by hand, but I would rather leave it, as I may > need to change either the On_Mask or Inv_Mask later. When the masks are > any other values, the expression actually does a fair amount of work. Yes, > me being lazy now means more work for the compiler, but that's what > computers are for, right? So anyway, it looks like the compiler was > (correctly) able to reduce the macro down to: > P_Data = 0x00 | response[0]; > That it got that far is actually pretty impressive. But, ORing with zero > changes nothing. So this could be reduced further to: > P_Data = response[0]; > And in asm, this could be written with a single line: > mov _P_Data,_main_response_1_1 I've commited a better optimization for these cases: a & 0 a & 0xff a | 0 a | 0xff a ^ 0 Please don't complain, if your macro still isn't optimized to > mov _P_Data,_main_response_1_1 There's a write access on P_Data, and P_Data is a SFR, and SFRs are volatile. Therefore the read access must not be optimized away. Finally your code exposes a bug in gen.c. I will have a look on this next time. Bernhard |