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

Re: : hitech compiler - deliberately generating poor code in free version?

by Isaac Marino Bavaresco :: Rate this Message:

Reply to Author | View in Thread

Terry Harris escreveu:

> On Fri, 03 Jul 2009 20:14:13 -0300, you wrote:
>
>  
>> OK, explain this under this theory:
>>
>> Look how they do 'Var = 0;' :
>>
>> bcf    STATUS,C
>> *movlw*   0
>> btfsc   STATUS,C
>> *movlw*   1
>> movwf   Var
>>    
>
> Evaluate the right hand expression and put the result in something just big
> enough (in this case the carry flag). Copy the result to the lvalue.
>  

Makes absolutely no sense. It is testing something itself set hard
coded. And there are two movlw, the expression doesn't have any
conditionals.


>> 'Var = 1;'
>>
>> clrf   Var
>> bsf   STATUS,C
>> rlf   Var,f
>>    
>
> Same again although I don't know why it chose a different method to copy.

Just to grow the code, perhaps?

>> 'Var = 2;'
>>
>> clrw
>> iorlw   2
>> movwf   Temp
>> movf   Temp,w
>> movwf   Var
>>    
>
> Same again but the expression needs a file to hold the result.
>
> It seems the compiler is being smart recognising constant expressions of 0
> and 1 will fit in a bit and treating them differently. The generated code
> looks dumb but I presume provides more scope of optimisation by the bit of
> the compiler you didn't buy.
>  

The temporary location seems reasonable in unoptimized code, but why
load w in a such awkward way?

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/ 

--
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?