Changes

Jump to: navigation, search

Assembler Basics

703 bytes added, 15:10, 8 January 2020
no edit summary
A In GNU assembler, a symbol may be set in one of three ways:
# Using the <code>.set</code> directive (in the example above, len line)
# Using an assignment using an equals sign (in the example above, stdout line), which the GNU assembler treats as an alternative syntax for the <code>.set</code> directive
Note also that the syntax will vary from assembler to assembler and from architecture to architecture.
== Essentials 6502 Assembly Language in the Emulator == The [[6502 Emulator]] provides a very simple assembler:* Simple text-substitution macros can be defined with <code>define ''name'' ''value''</code> like this: define SCREEN $f000* The DCB (Declare Constant Byte) directive can be used to create a group of an bytes in memory. Byte values are comma-separated and may be double-quoted single printable characters (except space), decimal values, or hexadecimal values prefixed with $, like this: dcb 12,34,56 dcb $33,$66,$CC,$FF dcb "A" dcb "T","e","s","t",$20,"4",".",0* The current assembly pointer starts at $0600 and increments with output bytes; it can be changed with this syntax: *=$0800 == Assembly Language Program on a Linux System ==
On a Linux system, you will need to meet three requirements to get your assembly language program to work:
The file extension should be <code>.s</code> for assembler source without directives (for compilation with the assembler) or <code>.S</code> for assembler with preprocessor directives (for compilation with gcc).
=== Compiling an Assembly Language Program using the GNU Assembler ===
# Run the assembler: <code>as -g -o ''test''.o ''test''.s</code>
Note that the <code>-g</code> option assembles the program with symbolic debugging information included.
=== Compiling an Assembly Language Program using the NASM Assembler ===
# Run the assembler: <code>nasm -g -f elf64 -o ''test''.o ''test''.s</code>
# The <code>-g</code> option assembles 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 assembles the program with symbolic debugging information included, and that the normal GCC optimization options are not available.
=== Instruction Set Architecture Information ===
To get started with specific [[Instruction Set Architecture|instruction set architectures]], see:
* [[aarch64 Register and Instruction Quick Start]]
=== Resources ===
* [https://sourceware.org/binutils/docs/as/ Using as, The GNU Assembler] (GAS manual)

Navigation menu