Assembly language

(Redirected from Topic:Assembly language)

Assembly language (also called assembler language), often abbreviated asm, 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).

Assembly language example
Assembly language example

Assembly language can be known as any low-level programming language in which there is a very strong correspondence between the program's statements and the architecture's machine code instructions.[1]

Architecture

edit

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.

Common Architectures:

  • x86
  • ARM
  • PPC
  • MIPS
  • 360/370
  • Java Virtual Machine
  • Python Virtual Machine
  • 68000

Hardware

edit

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

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.

Free Online IDEs

edit

Famous free Online IDEs for assembly includes:

  • IDEone: Support Assembler 32-bit gcc 8.3 and nasm 2.14 and Assembler 64-bit nasm 2.14
  • TutorialsPoint

See also

edit

Reference

edit
  1. Wikipedia: Assembly language


Go to the School of Computer Science