It is currently Tue Nov 13, 2018 9:05 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6
Author Message
PostPosted: Wed Oct 31, 2018 1:38 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6948
Location: Canada
tokumaru wrote:
rainwarrior wrote:
that's separately guaranteed for me with either .align directives or segment alignment (or both).

Doesn't that result in wasted ROM space?

Not really... at least I've never found it significant. However, your proposed alternative is just setting the address with .org, right? Doesn't this have the exact same padding problem?

.align will create padding, but only as much as needed. You can always rearrange stuff around the code to take up that padding. (In general I don't actually start worrying about the small amount of bytes lost to padding until I actually run out of space, though.)

If you have a short routine, you can use .align 32, or .align 16, etc. to get the guarantee you need with less potential padding.

You can also put all your alignment requiring routines in one segment (or after one .align). Like the real problem is just branch crossings, right? Guarantee those with an assert, and you can put as many pages worth of code as you want after a single guaranteed page alignment, and just manually stick a few bytes in between your routines whenever one of those asserts triggers.

Sort of an extension of that idea, you can use generally asserts instead of .align to guarantee it for compilation without any implicit padding, and just add it as needed.


Top
 Profile  
 
PostPosted: Wed Oct 31, 2018 1:54 am 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 415
Yeah I use asserts too a lot and never had an issue with alignment.

You can use this macro instead of .align to verify you're not wasting too much space:

Code:
.macro align size max_segmentation
  .local label
  label:
  .align size
  .if (* - label) > (max_segmentation)
    .error ".align creates excess segmentation."
  .endif
.endmacro


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group