Jump to content
Sign in to follow this  
carolyn

Compiler Efficiency

Recommended Posts

I have just started using this compiler and with code space being important and generally using assembler I was suprised by the compiling of the line below

 

trisc = ~trisc;

 

used to toggle IO on portc.

 

the complier generates

COMF gbl_trisc, W

MOVWF gbl_trisc

 

whereas

COMF gbl_trisc, F

 

would be the usual assembler for this

 

Perhaps I am expecting to much but with only 2K of code space every word counts. Does the compler ever generate COMF gbl_trisc, F if so how other than in-line asm can I get a simple complement.

 

Thanks for any reply

Carolyn

Share this post


Link to post
Share on other sites

Thanks for reporting. We will add this in our todo list (won't be able to squize the fix into the coming release though).

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

I have found another efficiency issue, but I didn't want to open a new topic. It is the following:

unsigned long u, v;
v=u>>16;

this generates 136 lines of assembly code, mostly RRF (of course) - a lot of code space, a lot of time, this could be solved by moving some bytes, however.

Share this post


Link to post
Share on other sites

Further testing and writing of my application I have found that my previous example is not the only case of non-usage of the 'F' for simple register instructions

 

take

a = ~a; this becomes

comf a,w

movwf a

 

and even worse

long a;

a = ~a; becomes

 

comf a,w

movwf tmp

comf a+1,w

movwf tmp+1

comf a+2,w

movwf tmp+2

comf a+3,w

movwf tmp+3

movf tmp,w

movwf a

movf tmp+1,w

movwf a+1

movf tmp+2,w

movwf a+2

movf tmp+3,w

movwf a+3

 

whereas it should be

comf a,f

comf a+1,f

comf a+2,f

comf a+3,f

 

Carolyn

Share this post


Link to post
Share on other sites

Sorry first part of message was a repeat of my first post

 

However

 

if (++b1) gives

 

INCF gbl_b1, F

MOVF gbl_b1, F

BTFSC STATUS,Z

GOTO label268436982

 

should be

 

INCF gbl_b1, F

BTFSC STATUS,Z

GOTO label268436982

 

a0=a1=a2=0; is strange gives

 

CLRF gbl_a2

MOVLW 0x00

CLRF gbl_a1

MOVWF gbl_a0

 

Carolyn

Share this post


Link to post
Share on other sites
I have just started using this compiler and with code space being important and generally using assembler I was suprised by the compiling of the line below

 

trisc = ~trisc;

 

used to toggle IO on portc.

 

the complier generates

COMF gbl_trisc, W

MOVWF gbl_trisc

 

whereas

COMF gbl_trisc, F

 

would be the usual assembler for this

 

Perhaps I am expecting to much but with only 2K of code space every word counts. Does the compler ever generate COMF gbl_trisc, F if so how other than in-line asm can I get a simple complement.

 

Thanks for any reply

Carolyn

 

Hi

 

you could use an inline for now.EG

inline void flipBout()
{
asm	comf _trisb,F			
}

Share this post


Link to post
Share on other sites

The .pat script files in C2C where good for mopping up some of these sort of cases.

 

Does BoostC use the script files?

Share this post


Link to post
Share on other sites
Thanks Picxie

 

I am already using in line asm but the idea is to use C as much as posible

 

Carolyn

 

That is C, an inline c function, every time you call function flipBout() the compiler inserts comf trisb,f into code rather thana call to a function.

Not as elegant as trisb = ~trisb; and in the light of the other de efficiencies you have found probably not much help, but then again I've never used 16bit or 32 bit data types on PICs... yet.

 

BTW when you get to 10 posts they no longer revue your posts before putting them on, so you wont get that lag of several hours. much more convenient for discussing things.

Share this post


Link to post
Share on other sites

The ~ optimization problem has been fixed. Still need to look at other issues reported in this thread.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...