Jump to content
Sign in to follow this  
djulien

Prog Space Padding/alignment

Recommended Posts

It would be helpful to have a way to force a section of code to all be in the same code page. For example, maybe a construct such as:

#pragma pagepad 0x20
pcl += offset; //some other C code here...
goto label1;
goto label2;
//  etc.

The idea is that if the code immediately following the #pragma is within 0x20 (in this example) words of the end of the code page, then the linker would insert a jump to the start of the next code page and then place the following code there. However, if there is at least 0x20 words then no padding or code shuffling would take place.

 

This feature would make short jump-tables easier to implement because you would not need to put them in a separate function and force them to a known address with the @ construct. An additional benefit would be that the prog space would not be as fragmented - for example, if you want 10 little jump tables then currently you would need to create 10 separate functions and use the @ construct to place them all at known addresses. This makes it harder for the linker to find a place to put larger functions or sections of code, and can lead to poorer performance due to having to load pclath for jumps. However, with a page pad feature, the linker could rearrange the code however it wanted, and the jump table would still operate correctly because the entries would all be on the same code page.

 

This is partially related to the following thread:

 

http://forum.sourceb...?showtopic=5085

 

I've refered to jump tables as an example, but there are other examples where this would also be helpful. For example, when writing code to save/restore pcl, you don't want that to fall at the very edge of a code page.

 

don

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