Page 58 - ARM 64 Bit Assembly Language
P. 58

42 Chapter 2

                   .balign[lw] abs-expr, abs-expr, abs-expr
                       These directives adjust the location counter to a particular storage boundary. The first
                       expression is the byte-multiple for the alignment request. For example .balign 16
                       will insert fill bytes until the location counter is an even multiple of 16. If the location
                       counter is already a multiple of 16, then no fill bytes will be created. The second expres-
                       sion gives the fill value to be stored in the fill bytes. It (and the comma) may be omitted.
                       If it is omitted, then the fill value is assumed to be zero. The third expression is also op-
                       tional. If it is present, it is the maximum number of bytes that should be skipped by this
                       alignment directive.
                       The .balignw and .balignl directives are variants of the .balign directive. The
                       .balignw directive treats the fill pattern as a two byte word value, and .balignl treats
                       the fill pattern as a four byte longword value. For example, “.balignw 4,0x368d”
                       will align to a multiple of four bytes. If it skips two bytes, they will be filled in with the
                       value 0x368d (the exact placement of the bytes depends upon the endianness of the pro-
                       cessor).
                   .skip size, fill
                   .space size, fill
                       Sometimes it is desirable to allocate a large area of memory and initialize it all to the
                       same value. This can be accomplished by using these directives. These directives emit
                       size bytes, each of value fill.Both size and fill are absolute expressions. If the
                       comma and fill are omitted, fill is assumed to be zero. For the ARM processor, the
                       .space and .skip directives are equivalent. This directive is very useful for declaring
                       large arrays in the .bss section.
                  Listing 2.5 shows how the code in Listing 2.4 can be improved by adding an alignment direc-
                  tive at line 6. The directive causes the assembler to emit two zero bytes between the end of
                  the ch variable and the beginning of the ary variable. These extra “padding” bytes cause the
                  following word data to be word aligned, thereby improving performance when the word data
                  is accessed. It is good practice to always put an appropriate alignment directive when the size
                  of the data on the next line is larger than the size of the data on the current line. For example,
                  if the previous line declares string, byte, half-word, or word data, and the current line declares
                  double-word data, then an .align 3 directive should be placed between them. Likewise, if
                  the current line declares word data and the previous line declares string, byte, or half-word
                  data, then an .align 2 directive should be placed between them. For a line declaring half-
                  word data following a line declaring string or byte data, an .align 1 directive should be
                  placed between them.

                  2.3.4 Setting and manipulating symbols

                  The assembler provides support for setting and manipulating symbols which can then be used
                  in other places within the program. The labels that can be assigned to assembly statements
   53   54   55   56   57   58   59   60   61   62   63