Tuesday, 6 November 2007

Assembly cntd...

Typical assembly language instructions:
Made up of
  • Arithmetical instructions.
  • Logical instructions like 'AND', 'OR' and 'NOT'.
  • Rotate instructions.
  • Bit set or reset instructions.

    Examples:

    [add] [al,bl] - [;Add bl to al and store the result in al]
    [sub] [ax, 08h] - [;Subtract 8 (hex) from ax and store the result in ax]
    [mul] [bl] - [;al is multiplied by bl and stored in ax]
    Note: ax is double the width of al and bl
    [div] [cx] - [;The dx-ax register pair is divided by the cx with the quotient being placed in the ax register and the remainder being placed in the dx register]

  • Assembly Language

  • Second generation low-level language
  • Consists of four parts: [Label]-[Op Code]-[Operands]-[Comments]
    eg [Start:]-[mov]-[bx,80h]-[;Load character count]
  • Label: Used as a reference and good for calculating relative jumps.
  • Operation Code: Contains mnemonic which describes operation.
  • Operands: Describe source and destination of the data to be operated on.
  • Comments: Used for convenience of programmer. Helps readability.
  • Advantages: Can be quicker than some high level languages.
    - can access registers and exact memory addresses.

    Addressing Modes:

  • Register addressing
    - Data is transferred from a source register to a destination register
    ----
  • Immediate addressing
    - The data to be addressed is in the op code.
    ----
  • Direct addressing
    - Data is copied from a specified location in memory to the register.
    ----
  • Indirect addressing
    - Uses a number inside the register to point to location in memory.
    ----
  • Indexed addressing
    - Number within a register is used in combination with another number in another register to point to a location in memory.
    ----
  •