This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

.align directive for 1 byte alignment



Ok....so....how do you get 1 byte alignment?

 

CCS Assembly Tools Manual says: "Operands for the .align directive must equal a power of 2^0 between 2^15, inclusive"

I use '.align 0' to get 1 byte alignment for packing data in flash.....and it's aligning to words.

Throws the Warning: "WARNING! at line 13: [W0001] Power of 2 required, 1 assumed"

Any help on 1 byte alignment?

example Code below:

 

 .sect  ".cfgdata"   

    .retain

    .align 0

    .byte 0x55

    .word 0x4433

    .word 0x0000

    .word 0x2800

 

  • Kyle Stapp said:
    Ok....so....how do you get 1 byte alignment?

     .align 1

    Kyle Stapp said:
    "Operands for the .align directive must equal a power of 2^0 between 2^15, inclusive"

    I agree that wording is confusing.  It means the valid values for .align are 1, 2, 4, 8, 16, etc.

    Thanks and regards,

    -George

  • I still have the same problem.  '.align 1' doesn't work either.  I actually used that first....and it wasn't working...so then read the manual and tried '.align 0' and that didn't work either...so I posted.

     

    Here's my listing file proving '.align 1' doesn't work either.  The listing for '.align 0' is the same but with the aforementioned warnings included.

     

     

          10 00000000             .sect  ".cfgdata"
          11                              .retain
          12                              
          13                              .align 1
          14 00000000 55                  .byte 0x55
          15 00000004 00004433            .word 0x4433
          16 00000008 00000000            .word 0x0000
          17 0000000c 00002800            .word 0x2800
          18                    
          19 00000010 03                  .byte 0x03  
          20 00000014 00002800            .word 0x2800
          21 00000018 0000AA99            .word 0xaa99
          22 0000001c 00001000            .word 0x1000
          23                    
          24 00000020 02                  .byte 0x02
          25 00000024 00003800            .word 0x3800
          26 00000028 00003800            .word 0x3800
          27 0000002c 0003C800            .word 0x03c800
          28 00000030 FF                  .byte 0xff
    
  • That looks right to me.  What is the difference between this result, and what you want the assembler to do?

    Thanks and regards,

    -George

  • Hrrmm...

    Well.

    I want the byte to take exactly one byte and the other data to be words (like they are) and I want them packed as tightly as the align. To me this means:

          10 00000000             .sect  ".cfgdata"
          11                              .retain
          12                              
          13                              .align 1
          14 00000000 55                  .byte 0x55
          15 00000001 00004433            .word 0x4433
          16 00000005 00000000            .word 0x0000
          17 00000009 00002800            .word 0x2800
          18                    
          19 0000000d 03                  .byte 0x03  
          20 0000000e 00002800            .word 0x2800
          21 00000012 0000AA99            .word 0xaa99
          22 00000016 00001000            .word 0x1000
          23                    
          24 0000001a 02                  .byte 0x02
          25 0000001b 00003800            .word 0x3800
          26 0000001f 00003800            .word 0x3800
          27 00000023 0003C800            .word 0x03c800
          28 00000027 FF                  .byte 0xff
    

    The byte takes the first memory location, incrementing the SPC by only 1. The alignment is 1 so the next word of data starts at 1. Instead...it is aligning everything to words which is not alignment of 1.

    Did I really miss something obvious?

  • The .align directive aligns the SPC from where it is at the point.  It has no effect on later directives.  The .word directive aligns to a 4-byte boundary before it begins placing the data.  There is no way to disable that default alignment.  You probably want this ...

        .align 1
        .byte 0x55, 0x44, 0x33, 0x00, 0x00  ; and so on

    Thanks and regards,

    -George 

  • Well that's a little annoying.  On other systems it doesn't do that :).  I've been able to align and place data types with that alignment fine with no issue before

     

    It does indeed state what you said in the manual...I simply overlooked it.  Appreciate the input.