I'm wondering about the following: I have some data included in my flash image, ascii bytes terminated by 0. In case the length of the string is even, the adding of the terminating 0
would make the next .hword start on an odd boundary. So I fill in a .align 2 in any case.
This gives the following picture:
.hword 0x2da0,0x6f6c ; .byte 105,110,105,116,0; .align 2 @ init .hword 0x2d98,0x6f68 ; .byte 98,111,111,116,97,112,112,63,0; .align 2 @ bootapp? .hword 0x2d90,0x6ef8 ; .byte 46,98,97,110,110,101,114,0; .align 2 @ .banner
0000af20 3f 34 34 3b 38 74 07 65 2a 2a 3b 2e 35 35 38 08 |?44;8t.e**;.558.|0000af30 2e 33 34 33 04 00 00 00 a0 2d 6c 6f 69 6e 69 74 |.343.....-loinit|0000af40 00 00 00 bf 98 2d 68 6f 62 6f 6f 74 61 70 70 3f |.....-hobootapp?|0000af50 00 00 00 bf 90 2d f8 6e 2e 62 61 6e 6e 65 72 00 |.....-.n.banner.|0000af60 88 2d f0 6e 56 45 52 53 00 00 00 bf 80 2d 8c 6e |.-.nVERS.....-.n|
You can see that init (even) becomes odd withe the 0 appended. The .align 2 seems to add 3 bytes (!) 00 00 bf. Why doesn't it just fill in 1 byte to land on an even address? BTW, why "bf"?
How can I achieve that not a whole half word is being wasted?
My guess is that `.align` is interpreting the `2` as a power of two, as in 2^2 = 4. Try `.balign 2`.
Hey
This forum is for questions about how to use the community. Please take a look at https://community.arm.com/support-forums/ and let me know which support forum I can move this question to.
Thanks!
Oli from the Community team
Oh, sorry, don't know how it happened. Excuses. I think it would best fit into the Compiler and Libraries (Toolchain) forum
Christoph
No worries, I have just moved the post for you :)
Thanks. .align 1 did the job as well but .balign 2 is also fine.
`.align 1` makes since, as 2^1=2 and all that, but personally, I find `.balign` more intuitive. Anyway, happy it worked out!