Assembly Language is a set of mnemonic languages with a 1 to 1 logical mapping of instructions to the machine code of various architectures. Assembly is usually used when the programming task is small and local, as it has very little modularity and is platform-dependent, unlike higher-level languages. Other uses of assembly are in program debugging (in which machine instructions can be executed one at a time), and in reverse-engineering compiled programs by disassembly (in which there is no higher-level code to associate with).
Architecture[edit | edit source]
The architecture is the most important thing to know when programming in Assembly Language. The architecture in question might be the specific hardware that the application is designed to run on, or a virtual machine. A virtual machine is an example of abstract hardware, and usually also has its own version of machine code. The architecture dictates the internal representations used by data types, instructions understood by the CPU, and available resources. Since Assembly Language is a 1 to 1 logical mapping to machine code, the steps taken to implement an algorithm are frequently much smaller and more numerous than those in higher level languages. A typical hardware architecture contains a CPU, registers, and memory.
Hardware[edit | edit source]
The CPU (Central Processing Unit) acts as a kind of brain for the computer system. It usually contains a cache and registers. The cache is typically used to store segments of program code, while registers are used for immediate data access. The CPU successively executes instructions from the cache until it encounters a branch or interrupt.
Registers are a part of the CPU, and are the fastest memory available. The number, size, and use of registers available depends upon the architecture in question. A register is usually considered as an integer, but can be conceptualized as anything from a character to a pointer.
Memory access is a trade-off between speed and size. Accessing memory is much faster than disk I/O, but much slower than accessing a register. Memory contains both program code and variable storage, and has the advantage of being able to store large or complex objects.
Common Instructions[edit | edit source]
An instruction in Assembly Language usually declares both where this data is located, and the format of the expected data. Instructions can be categorized as mathematical, logical, flow control, or memory operations. Common mathematical operations include adding, subtracting, multiplying, dividing, and shifting, while common logical operations are the bitwise operations AND, OR, XOR, and NOT. Flow control operations are most often branches or comparisons, and memory is often loaded, stored, or moved. Each architecture comes with an instruction set which is in machine code (1's and 0's) for the machine but presented to the human programmer in more readable forms. See MIPS architecture - a fine example.
See also[edit | edit source]
- Introduction to Assembly Language
- Operating Systems/x86
- Topic:Electronic engineering
- GitHub: PC Assembly Language Book
- LMU.edu: NASM Tutorial
- TutorialsPoint: Assembly Programming Tutorial
- Virginia.edu: Guide to x86 Assembly
|Go to the School of Computer Science|