Changes

Jump to: navigation, search

Assembler Basics

131 bytes added, 23:29, 28 December 2016
no edit summary
[[Category:Assembly Language]]
When you program in [[Assembler|assembly language]], you're directly programming the "bare metal" hardware. This means that many of the compile-time and run-time checks, error messages, and diagnostics that are present in other languages are not available. The computer will follow your instructions exactly, even if they are completely wrong (like executing data), and when something goes wrong, your program won't terminate until it tries to do something that's not permitted, such as execute an invalid opcode or attempt to access a protected or unmapped region of memory. When that happens, the CPU will signal an exception, and in most cases the operating system will shut down the offending process.
== Format of an Assembly Language program ==
The traditional extension for assembly-language source files is <code>.s</code> (e.g., <code>example.s</code>), or <code>.S</code> for files that need to go through the C preprocessor (<code>cpp</code>).
An assembly-language program consists of:
# Data - Values used by the program for things such as initial variable values and string or numeric constants.
Assembler '''directives''' are used to control the assembly of the code, by specifying output file sections (such as .text or .data in an ELF file) and data formats (such as word size for numeric values), and by defining macros.
Consider this x86_64 assembly language "Hello World" program:

Navigation menu