Instructions

Introduction

This article will define three main categories of instructions in the x86 architecture. It will give examples in each of these categories and then show simulations on how some instructions are executed.

This article is designed for professional and self-starters who want to gain a detailed understanding of x86 instructions. Learning x86 instructions will help you to understand the make-up of underlying systems which popular programming languages conceal from you.

Instructions in x86

Instructions can be defined as the language used to command a computer architecture. The x86 instructions basically tell the processor what to do. They are generally categorized into:

  • Arithmetic and logic instructions
  • Control-flow instructions
  • Data movement instructions

Arithmetic and logic instructions in x86

These instructions consist of arithmetic and logical operations. Arithmetic operation can be applied on numerical quantities to multiply, add, subtract or divide. The logic operations are basically the operations performed by logic gates and the main operations are AND, OR, XOR and NOT. 

Arithmetic instructions

Basic instruction format

ADD operand1, operand2.

Operand1 is the destination operand and operand2 is the source operand. The destination operand can be either a memory location or a register. Operand2 is the source operand and can be a constant, a register or memory location.

Example 1: 

  • MOV AX, 77H ;Copy the hex value 77 to the accumulator
  • ADD AX, 80H ; Add the constant hex value 80 to the value in the accumulator.

Operand 1: 0111 0111

Operand2: 1000 0000

Content of operand1 after ADD operation: 1111 01111

Note that there is no carry from the lower four bits (low nibble) to the higher four bits (high nibble). The Auxiliary or Adjust flag will not be set. 

Figure 1: Contents of the accumulator (register AX) after ADD operation in example 1 is executed

 

Figure 2. (Read more...)

*** This is a Security Bloggers Network syndicated blog from Infosec Resources authored by Richard Azu. Read the original post at: http://feedproxy.google.com/~r/infosecResources/~3/4xxtkpe-Amg/

Richard Azu

Richard Azu

Richard has over 16 years of experience in Network/Telecom Engineering. Experienced in the deployment of voice and data over the 3 media; radio, copper and fibre, Richard – a system support technician currently with First National Bank Ghana Limited is still looking for ways to derive benefit from the WDM technology in Optics. Using Kali as a springboard, he has developed an interest in digital forensics and penetration testing.

richard-azu has 12 posts and counting.See all posts by richard-azu