Page 61 - ARM 64 Bit Assembly Language
P. 61

GNU assembly syntax 45

                     Note that the four variables are shown to be in the data segment, and the arysize symbol is
                     marked as an “absolute” symbol, which simply means that it is a number and not an address.
                     It will have no storage location in the running program, but it’s value can be used whereever
                     needed while the file is being assembled. The programmer can now use the symbol arysize
                     to control looping when accessing the array data. If the size of the array is changed by adding
                     or removing constant values, the value of arysize will change automatically, and the pro-
                     grammer will not have to search through the code to change the original value, 5, to some
                     other value in every place it is used.



                     2.3.5 Functions and objects

                     There are a few assembler directives that are used for defining the size and type of labels. This
                     information is stored in the object file along with the code and data, and is used by the linker
                     and/or debugger.
                       .size name,expression
                          The .size directive is used to set the size associated with a symbol. This information
                          helps the linker to exclude unneeded code and/or data when creating an executable file,
                          and helps the debugger to keep track of where it is in the program.
                       .type name,type_description
                          The .type directive sets the type of a symbol name to be either a function or an object.
                          Valid values for type_desription in GNU AArch64 assembly include:
                          %function The symbol is a function name.
                          %gnu_indirect_function The symbol is an indirect function (may be called
                               through a function pointer table).
                          %object The symbol is a data object.
                          %tls_object The symbol is a thread-local data object.
                          %common The symbol is a common (shared) object.
                          %notype The symbol has no type.
                          Note: Some assemblers, including some versions of the GNU assembler, a may require
                          the @ character instead of the % character.

                     The following example shows how a typical function is declared.

                    1         .type  myfunc, %function
                    2         .global myfunc
                    3  myfunc: // an example function named myfunc
                    4
                    5         // The function code goes here
                    6
                    7         .size myfunc,(. - myfunc)
   56   57   58   59   60   61   62   63   64   65   66