Jump to content
Sign in to follow this  
Aegis-tec

Boostc Behavior

Recommended Posts

I'm collecting notes on unexpected behavior of BoostC to use as a reference. I'll

post it in a public place as others contribute. For example, here's a snippet of

BoostC code:

 

void interrupt(void)

{

nop ;any user code goes here

}

 

I would have expected the above snippet to compile to something like this:

 

;

;

nop ;user code here

retfie ;all done, return

;

;

 

Here's what actually happens:

 

movwf 0x7F ;store the contents of W in RAM address 7F

swapf status,w ;save the status reg, movf not used so Z bit is not changed

bcf status,rp0 ;the status byte to save is in W make sure we're on page0

bcf status,rp1 ;

movwf 0x20 ;save status reg in RAM

swapf pclath,w ;get PCL hi byte, use swapf used to avoid stepping on value

movwf 0x21 ;save PCLATH in RAM

swapf fsr,w ;save FSR

movwf 0x22 ;save FSR in RAM

bcf pclath,3 ;make sure that GOTO and CALLs jump to first 2048 words

bcf pclath,4

goto anyaddr ;now jump to user code

;

;the user code executes at <anyaddr>

nop ;here's the user code

;

bcf status,rp0 ;the page bits are cleared again, not sure why??

bcf status,rp1 ;

swapf 0x22,w ;restore FSR

movwf FSR

swapf 0x21,w ;restore PCLATH

movwf PCLATH

swapf 0x20,w ;restore status

movwf status

swapf 0x7F,f ;restore w by swapping it first, it was swapped earlier

swapf 0x7F,w ;w is now restored

retfie ;all done

 

 

The code above is a fairly standard system save on interrupt. What if you don't want to save the system state? I often have projects that are very I/O intensive and every Tcyc is counted. Is there a way to suppress this feature?

 

Steve

Share this post


Link to post
Share on other sites
Is there a way to suppress this feature?
Not currently, but is could be added.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Is there a way to suppress this feature?
Not currently, but is could be added.

 

Regards

Dave

 

Dave,

 

This might be better posted in a different section, but please do consider this. Implementing a CRC in a PIC16 often invloves a large table lookup and the table handler is much easier to work with if it can be placed in a specific location. Please let me know if you would like asm code samples.

 

Sincerely,

Steve

Share this post


Link to post
Share on other sites

Steve,

 

This might be better posted in a different section, but please do consider this. Implementing a CRC in a PIC16 often invloves a large table lookup and the table handler is much easier to work with if it can be placed in a specific location. Please let me know if you would like asm code samples.
I think you are answering a different post, or I totally don't understand what you are saying :huh:

 

Regards

Dave

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