Intel MCS-51 - Instruction Set

Instruction Set

The MCS-51 instruction set offers several addressing modes, including

  • direct register, using ACC (the accumulator) and R0-R7
  • direct memory, which access the internal RAM or the SFR's, depending on the address
  • indirect memory, using R0, R1, or DPTR to hold the memory address. The instruction used may vary to access internal RAM, external RAM, or program memory.
  • individual bits of a range of IRAM and some of the SFR's

And some of the common instructions are-

  • mov | e.g., mov a,#30h ; a = 30h
syntax : | mov r2,39h ; r2 = mov destination, source | mov a,r3 | mov p2,a description : Loads the destination with the value at source and source data remains the same
  • add | e.g., add a,r3 ; a=a+r3
description : Adds the destination with the source and keeps it in the destination, and source data remains the same
  • subb | e.g., subb a,r3 ; a=a-r3
description : Subtracts the destination with the source and keeps it in the destination,
  • clr bit | e.g., clr p1.1
description : clears the bit p1.1
  • setb bit | e.g., setb p1.1
description : sets the bit p1.1 to 1
  • inc R0;
description : increments value at R0
  • mul AB;
description : multiplies values at A and B, stores lower significant byte in A and higher significant byte in B
  • div AB;
description : divides values at A and B i.e., A/B, stores Quotient in A and remainder in B

Many of the operations allow any addressing mode for the source or the destination, for example, MOV 020h, 03fh will copy the value in memory location 0x3f in the internal RAM to the memory location 0x20, also in internal RAM.

Because the 8051 is an accumulator-based architecture, all arithmetic operations must use the accumulator, e.g. ADD A, 020h will add the value in memory location 0x20 in the internal RAM to the accumulator.

One does not need to master these instructions to program the 8051. With the availability of good quality C compilers, including open source SDCC, virtually all programs can be written with high-level language.

Read more about this topic:  Intel MCS-51

Famous quotes containing the words instruction and/or set:

    A little instruction in the elements of chartography—a little practice in the use of the compass and the spirit level, a topographical map of the town common, an excursion with a road map—would have given me a fat round earth in place of my paper ghost.
    Mary Antin (1881–1949)

    When you set out for Ithaca
    ask that your way be long.
    Constantine Cavafy (1863–1933)