spo600:assembler_basics
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
spo600:assembler_basics [2024/01/12 21:49] – created chris | spo600:assembler_basics [2025/02/11 11:58] (current) – chris | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Assembler Basics | + | ====== Assembler Basics |
When you program in [[Assembly Language|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. | When you program in [[Assembly Language|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. | ||
Line 5: | Line 5: | ||
===== Format of an Assembly Language program | ===== Format of an Assembly Language program | ||
- | The traditional extension for assembly-language source files is '' | + | The traditional extension for assembly-language source files that will be used as input to an assembler |
An assembly-language program consists of: | An assembly-language program consists of: | ||
- [[Symbol|Symbols]] that are constants which correspond to memory addresses, registers, or other values. | - [[Symbol|Symbols]] that are constants which correspond to memory addresses, registers, or other values. | ||
- | - Instructions - Mnemonics for an operations, each followed by zero or more arguments. | + | - |
- Data - Values used by the program for things such as initial variable values and string or numeric constants. | - Data - Values used by the program for things such as initial variable values and string or numeric constants. | ||
Line 62: | Line 62: | ||
===== 6502 Assembly Language in the Emulator | ===== 6502 Assembly Language in the Emulator | ||
- | The [[6502 Emulator]] provides a very simple assembler for [[6502]] code: | + | The [[6502 Emulator]] provides a very simple assembler for [[6502]] code. Each line contains one instruction in assembly language, or one of these directives: |
* Simple text-substitution macros can be defined with '' | * Simple text-substitution macros can be defined with '' | ||
< | < | ||
Line 72: | Line 73: | ||
dcb " | dcb " | ||
dcb " | dcb " | ||
- | * The current assembly pointer starts at $0600 and increments with output bytes; it can be changed with this syntax: | + | * The current assembly pointer starts at $0600 and increments with output bytes; it can be changed with this directive: |
< | < | ||
*=$0800</ | *=$0800</ | ||
- | To create an assembly language program in the emulator, | + | To create an assembly language program in the emulator, |
===== Assembly Language on a Linux System | ===== Assembly Language on a Linux System | ||
On a Linux system, you will need to meet three requirements to get your assembly language program to work: | 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 must be placed in the '' |
- Data must be placed in either the '' | - Data must be placed in either the '' | ||
- There must be a globally-defined symbol which the linker ('' | - There must be a globally-defined symbol which the linker ('' | ||
Line 89: | Line 90: | ||
==== Compiling an Assembly Language Program using the GNU Assembler | ==== Compiling an Assembly Language Program using the GNU Assembler | ||
- | - Run the assembler: '' | + | - Run the assembler: '' |
- | - Run the linker: '' | + | - Run the linker: '' |
- | Note that the '' | + | Note that the '' |
==== Compiling an Assembly Language Program using the NASM Assembler | ==== Compiling an Assembly Language Program using the NASM Assembler | ||
Line 100: | Line 101: | ||
Notes: | Notes: | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
==== Compiling an Assembly Language program using GCC ==== | ==== Compiling an Assembly Language program using GCC ==== |
spo600/assembler_basics.1705096167.txt.gz · Last modified: 2024/04/16 18:10 (external edit)