Changes

Jump to: navigation, search

Assembler Basics

1,413 bytes added, 13:23, 21 January 2016
no edit summary
Note also that the syntax will vary from assembler to assembler and from architecture to architecture.
<!-- == Essentials of an Assembly Language Program on a Linux System ==
== Examples ==On a Linux system, you will need to meet three requirements to get your assembly language program to work:# Code must be placed in the <code>text</code> section of the ELF file.# Data must be placed in either the <code>rodata</code> (read-only data) or <code>data</code> (read/write data) sections of the ELF file.# There must be a globally-defined symbol which the linker (<code>ld</code>) will use to find the entry point to your program. If the code is being directly compiled by the assembler, this symbol must be <code>_start</code> -- but if the code is being compiled by gcc, this symbol must be called <code>main</code>.
See The file extension should be <code>.s</code> for assembler source without directives (for compilation with the examples in your ~/spo600-examplesassembler) or <code>.S</ directory on [[SPO600 aarch64 QEMU on Ireland#Sample Code|Ireland]]code> for assembler with preprocessor directives (for compilation with gcc).
== Compiling an Assembly Language Program using the GNU Assembler == # Run the assembler: <code>gas -g -o ''test''.o ''test''.s</code># Run the linker: <code>ls -o ''test'' ''test''.o</code> Note that the <code>-g</code> option assembled the program with symbolic debugging information included. == Compiling an Assembly Language program using GCC == # Run the preprocessor, assembler, and linker using the gcc command: <code>gcc -g -o ''test''.o ''test''.S</code> Note that the <code>-g</code>option assembled the program with symbolic debugging information included, and that the normal GCC optimization options are not available.
== Instruction Set Architecture Information ==

Navigation menu