Instructions 

Definition:

An instruction in assembly language is a symbolic representation of a single machine instruction. In its simplest form, an instruction consists of a mnemonic and a list of operands.

  • A mnemonic is a short alphabetic code that assists the CPU in remembering an instruction. This mnemonic can be followed by a list of operands
  • Each instruction in assembly language is coded into one or more bytes
  • The first byte is generally an OpCode, i.e. a numeric code representing a particular instruction
  • Additional bytes may affect the action of the instruction or provide information about the data needed by the instruction.


    Instruction Types:

    There exist around 150 instructions for the 8086 processor. These instructions may be classified into different classes. The following table summarizes the different classes of instructions, together woth examples of each class.

    Instruction Type Definiton Examples
    Data transfer instructions Transfer information between registers and memory locations or I/O ports MOV, XCHG, LEA,PUSH,POP
    Arithmetic instructions Perform arithmetic operations on binary or binary-coded-decimal (BCD) numbers ADD, SUB, INC, DEC
    Bit manipulation instructions Perform shift, rotate, and logical operations on memory locations and registers SHL, SHR, SAR, ROL
    Control transfer instructions Control sequence of program execution. Include jumps and procedure transfers JL, JE, JNE, JGE
    String handling instructions Move, compare, and scan strings of data OVSB, MOVSW, CMPS, CMPSB
    Processor control instructions Set and clear status flags, and change the processor execution state STC, STD, STI, CLC
    Interrupt instructions Interrupt processor to service a specific condition INT, INTO, IRET
    Miscellaneous instructions NOP, WAIT

    Table 2: 8086 Instructions

    Instruction Semantics:

    The following rules have to be strictly followed in order to write correct code.

    1 - Both operands have to be of the same size:

    Instruction Correct Reason
    MOV AX, BL No Operands of different sizes
    MOV AL, BL Yes Operands of same sizes
    MOV AH, BL Yes Operands of same sizes
    MOV BL, CX No Operands of different sizes

    Table 3: Register-Regsiter Transfer Instructions

    2 - Both operands cannot be memory operands simultaneously:

    Instruction Correct Reason
    MOV i , j No Both operands are memory variables
    MOV AL, i Yes Move memory variable to register
    MOV j, CL Yes Move register to memory variable

    Table 4: Memory-Register Transfer Instructions

    3 - First operand, or destination, cannot be an immediate value:

    Instruction Correct Reason
    ADD 2, AX No Move register to constant
    ADD AX, 2 yes Move constant to register

    Table 5: Constant to Regsiter Transfer Instructions