ARM Assembler Directives...?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 1530dean
    New Member
    • Aug 2014
    • 3

    ARM Assembler Directives...?

    Hi
    I am struggling to understand an assembler directive "DCD" which is stated as below..!

    "DCD inserts up to three bytes of padding before the first defined word, if necessary, to achieve four-byte alignment."

    I would have thought that by inserting three bytes of padding before the first byte not word would achieve four-byte alignment or am I missing somthing..???

    I have copied below the Usage example from the ARM assembler reference if this helps..?

    Usage
    DCD inserts up to three bytes of padding before the first defined word, if necessary, to achieve
    four-byte alignment.
    Use DCDU if you do not require alignment.
    Examples
    data1 DCD 1,5,20 ; Defines 3 words containing
    ; decimal values 1, 5, and 20
    data2 DCD mem06 + 4 ; Defines 1 word containing 4 +
    ; the address of the label mem06
    AREA MyData, DATA, READWRITE
    DCB 255 ; Now misaligned ...
    data3 DCDU 1,5,20 ; Defines 3 words containing
    ; 1, 5 and 20, not word aligned
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Consider the starting address:
    • 0x0000, no pad bytes needed;
    • 0x0001, three pad bytes needed;
    • 0x0002, two pad bytes needed;
    • 0x0003, one pad byte needed;
    • 0x0004, no pad bytes needed; and so on.

    Comment

    Working...