1,885
edits
Changes
no edit summary
In the program above:
* .start text is a directive (equivalent to the longer directive ".section .starttext") which specifies that the following instructions/data should be placed in the ".starttext" section of the output ELF file.
* .data is a similar directive which specifies that the following instructions/data should be placed in the .data section of the output ELF file. In the case of this program, they could alternately be placed in the .rodata section, which is for read-only data (data which is write-protected in memory), because the string is not modified by the program.
* .global (or .globl) is a directive which makes the following symbol visible to the linker. Otherwise, symbols are normally lost by link time. In this case, the linker needs to know the value of the special symbol _start in order to know where execution is to begin in the program (which is not always at the start of the .text section).
* _start is a label which is equivalent to the memory location of the first instruction in the program.
* msg is a label which is equivalent to the memory location of the first byte of the string "Hello, World!\n"
* .set is a directive which sets a symbol (len) equal to the value of an expression (in this example, ". - msg" meaning the current memory location minus the value of the label "msg"). Note that the GNU assembler accepts <code>a=1</code> as equivalent to <code>.set a , 1</code> -- both are counted as directives regardless of the presence of the <code>.set</code> keyword.
Note that symbols are not variables - they are constants that are calculated at compile-time. However, they may contain an address at which a variable is stored.