Basic Assembly Instructions

Assembly language instructions are the low-level commands that a computer's CPU can execute. They are typically mnemonic representations of machine code instructions, providing a more human-readable way to program.

Arithmetic Instructions

Arithmetic instructions perform basic mathematical operations on data, such as addition, subtraction, multiplication, and division. For example, the following assembly language instruction adds two numbers:

add eax, ebx

This instruction adds the value of the register ebx to the value of the register eax and stores the result in the register eax.

Logical Instructions

Logical instructions perform bitwise operations on data, such as AND, OR, and XOR. For example, the following assembly language instruction performs an AND operation on two numbers:

and eax, ebx

This instruction performs an AND operation on the values of the registers eax and ebx and stores the result in the register eax.

Data Transfer Instructions

Data transfer instructions move data between different memory locations, such as registers and memory. For example, the following assembly language instruction moves the value of the register eax to memory:

mov [esi], eax

This instruction moves the value of the register eax to the memory location addressed by the register esi.

Control Flow Instructions

Control flow instructions control the flow of execution of a program. They allow the programmer to jump to different parts of the program, call functions, and return from functions. For example, the following assembly language instruction jumps to the address stored in the register edi:

jmp edi

This instruction jumps to the address stored in the register edi.

Input/Output Instructions

Input/output instructions allow the program to read data from and write data to input/output devices, such as the keyboard and the monitor. For example, the following assembly language instruction reads a character from the keyboard and stores it in the register al:

in al, 0x60

This instruction reads a character from the keyboard and stores it in the register al.

These instructions collectively allow assembly programmers to manipulate data, perform computations, control program flow, and interact with input/output devices. Assembly language is architecture-specific, so the exact instructions available depend on the CPU architecture being used. Programmers use mnemonics to represent these instructions in a human-readable form, and assemblers convert them into machine code for execution by the CPU.

Conclusion

Assembly language instructions are the basic building blocks of assembly language programs. Assembly language programmers use these instructions to perform a wide variety of tasks, such as arithmetic operations, logical operations, data transfers, control flow, and input/output.