« Return to Thread: : hitech compiler - deliberately generating poor code in free version?

Re: : hitech compiler - deliberately generating poor code in freeversion?

by Olin Lathrop :: Rate this Message:

Reply to Author | View in Thread

Mike Harrison wrote:

> 365:               irrxsum1+=irbyte1;
>    115    087A     MOVF 0x7a, W
>    116    00C3     MOVWF 0x43
>    117    0843     MOVF 0x43, W
>    118    07F4     ADDWF 0x74, F
>
> Should be 2 instructions
>
> 366:               ircnt1=0;
>    119    1003     BCF 0x3, 0
>    11A    3000     MOVLW 0
>    11B    1803     BTFSC 0x3, 0
>    11C    3001     MOVLW 0x1
>    11D    00FB     MOVWF 0x7b
>
> This is especially bizarre - should be 1 CLRF instruction
>
> 349:               irtmr1+=bittime2; // bittime2 is a constant
>    0DF    300E     MOVLW 0xe
>    0E0    00C3     MOVWF 0x43
>    0E1    0843     MOVF 0x43, W
>    0E2    07F5     ADDWF 0x75, F
>
> Should be 2 instructions
>
>
> 350:               ircnt1++;
>    0E3    3001     MOVLW 0x1
>    0E4    00C3     MOVWF 0x43
>    0E5    0843     MOVF 0x43, W
>    0E6    07FB     ADDWF 0x7b, F
>
> Should be 1 INCF instruction
>
> 322:               irin=PORTA;
>    090    0805     MOVF 0x5, W
>    091    00C3     MOVWF 0x43
>    092    0843     MOVF 0x43, W
>    093    00FC     MOVWF 0x7c
>
> Why is it storing in two places?

It's obviously using location 43h as a sort of working register.  This is
probably due to generating code to handle wide integers run in the single
byte case, and would hopefully dissappear with the optimizer.  If you care
about efficiency, then either use the optimizer or write it in assembly.  It
seems you're getting exactly what you paid for.

The second case looks like it didn't check for the special case of 0 and is
doing some extra instructions to deal with signed/unsigned issues.  Did you
define all the variables unsigned that didn't really need to be signed?
You've got to do your part too, especially when the optimizer is turned off.

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

 « Return to Thread: : hitech compiler - deliberately generating poor code in free version?