Explicit alignment boundaries fail due to linker shifting assembled piece of code off the alignment boundary.
Steps to reproduce the issue:
In the test.lst shows the alignment boundaries are taking into account while assembling:
1 .area CODE
000000 2 .bndry 4
000000 9D [ 1] 3 nop
000004 4 .bndry 4
000004 9D [ 1] 5 nop
When looking at the .rst file showing the linker results, the alignment boundaries are no longer taking into account:
1 .area CODE
008026 2 .bndry 4
008026 9D [ 1] 3 nop
00802A 4 .bndry 4
00802A 9D [ 1] 5 nop
sdcc -v: mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.6.9 #10220 (MINGW32)
Since STM8 fetches flash in absolute aligned chunks of 4 bytes, an quickfix would be to allign every .rel on a 4 bytes alignment boundary, so that timing critical code is executed as expected.
There is a work around for this issue, place explicit 4 byte alignment boundaries to every source file.
For assembly source files this is quite simple, just adding the 4 byte alignment boundary at end of file:
SDCC only allows inline assembly within function scopes in C source files, therefore the 4 byte alignment boundary must be wrapped in a __naked function:
Last edit: Henk 2018-09-25