Tuesday, July 31, 2018

Labels

Labels act as place markers.
Marks the address (offset) of code and data.
Easier to memorize and more flexible.

mov ax, [0020] → mov ax, val

Rules:


  • Data label:

      must be unique
      example:
                      myArray BYTE 10

  • Code label: 

      ends with a colon
      The target of jump and loop instructions
       example:
          L1: mov ax, bx
                 ...
                 jmp L1

Instruction of x86

An intel instruction is divided into 4 parts:

  1. Label (optional)
  2. Mnemonic (required)
  3. Operand (usually required)
  4. Comment (optional)

Instructions are assembled into machine code by the assembler.
Instructions are executed at runtime by the CPU.

x86 CPU instructions

The general-purpose instructions perform basic data movement, arithmetic, logic, program flow, and string operations which programmers commonly use to write application and system software to run on Intel 64 and IA-32 processors. They operate on data contained in the memory, in the general-purpose registers (EAX, EBX, ECX, EDX, EDI, ESI, EBP, and ESP) and in the EFLAGS register. They also operate on address information contained in the memory, the general-purpose registers, and the segment registers (CS, DS, SS, ES, FS, and GS).

The following are the different CPU instructions:


  • Data Transfer Instructions
  • Binary Arithmetic Instructions
  • Decimal Arithmetic Instructions
  • Logical Instructions
  • Shift and Rotate Instructions
  • Bit and Byte Instructions
  • I/O and String Instructions
  • Control Transfer Instructions
  • High-Level Procedure Instructions
  • Flag Control Instructions
  • Miscellaneous Instructions
  • Random Number Generator Instructions
  • Bit manipulation instructions
  • Segment Register Instructions
  • System Instructions