0% found this document useful (0 votes)
147 views13 pages

8051 Instruction Set: Facebooktwitterlinkedinredditpinterestshare

The document provides a summary of the 8051 instruction set. It lists common data handling, logical, and arithmetic instructions along with their addressing modes, number of bytes occupied, and number of cycles used. The complete instruction set of the 8051 microcontroller is described for easy reference.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views13 pages

8051 Instruction Set: Facebooktwitterlinkedinredditpinterestshare

The document provides a summary of the 8051 instruction set. It lists common data handling, logical, and arithmetic instructions along with their addressing modes, number of bytes occupied, and number of cycles used. The complete instruction set of the 8051 microcontroller is described for easy reference.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

8051 Instruction Set

January 2, 2013 By Himanshu Choudhary


FacebookTwitterLinkedInRedditPinterestShare
Here one can find complete instruction set of 8051 microcontroller. Complete
information regarding each instruction like operational explanation, addressing mode,
no. of byte occupied, no. of cycles used etc is given. So just, go through it. It’s a ready
reference.

Consider the code snippet


Line1. MOV SI, 1000H
Line2. MOV AX, 0
Line3. MOV BX, 1
Line4. MOV CX, 5
Line5. ADD AX,BX
Line6. BACK: MOV [SI], AX
Line7. INC SI
Line8. MOV [SI], BX
Line9. INC SI
Line10. LOOP BACK
What are the Value of SI ?

 MOV AH,09H;

LEA DX,MSG;

INT 21H;

Line1. MOV AH, 01H

Line2. INT 21H

Line3. SUB AL, 30H

Line4. MOV AX, 1234H

Line5. RET

Line6. P1 ENDP

Line1. MOV DX, 0AH

Line2. MOV BX, 00H

Line3. CMP BX, DX

Line4. JG NOTFOUND
Line5. MOV AX, BX

Line6. ADD AX, DX

Line7. SHR AX, 01H

Line8. NOTFOUND: END

When you execute this code what is the value of AX?

Line1. RPT1: MOV AH, 01H

Line2. INT 21H

Line3. MOV A[SI], AL

Line4. INC SI

Line5. CMP AL, 0DH

Line6. JNE RPT1

When you execute this code what is the output?

Line1. .DATA

Line2. MSG1 DB 'STRINGS ARE EQAUL'

Line3. .CODE

Line4. MOV AX,@DATA

Line5. MOV DS, AX

Line6. MOV AH, 09H

Line7. LEA DX, MSG1

Line8. INT 21H

When you execute this code what is the out put?

MOV DX, 0AH

MOV BX, 00H

CMP BL, DX

When you execute above instruction what is the error ?

Write a set of 8086 instructions to perform the following task

S[0] = 0
S[1] = 1

S[2] = 1

S[3] = 2

S[4] = 3

Write a set of 8086 instructions to read number 15?

The complete 8051 Instruction Set or all 8051 instructions are broadly classify in to

four groups data moving, logical, arithmetic and branching.

Data moving / handling Instructions:

Mnemonics Operational Addressin No. of No. of

description g mode bytes cycles

occupied used

Mov a,#num Copy the immediate immediate 2 1

data num in to acc

Mov Rx,a Copy the data from acc register 1 1

to Rx

Mov a,Rx Copy the data from Rx register 1 1

to acc

Mov Copy the immediate immediate 2 1

Rx,#num data num in to Rx

Mov a,add Copy the data from direct 2 1

direct address add to

acc

Mov add,a Copy the data from acc direct 2 1

to direct address add

Mov Copy the immediate direct 3 2

add,#num data num in to direct

address

Mov Copy the data from direct 3 2


add1,add2 add2 to add1

Mov Rx,add Copy the data from direct 2 2

direct address add to Rx

Mov add,Rx Copy the data from Rx direct 2 2

to direct address add

Mov @Rp,a Copy the data in acc to Indirect 1 1

address in Rp

Mov a,@Rp Copy the data that is at Indirect 1 1

address in Rp to acc

Mov Copy the data that is at Indirect 2 2

add,@Rp address in Rp to add

Mov Copy the data in add to Indirect 2 2

@Rp,add address in Rp

Mov Copy the immediate Indirect 2 1

@Rp,#num byte num to the address

in Rp

Movx a,@Rp Copy the content of Indirect 1 2

external add in Rp to

acc

Movx Copy the content of Indirect 1 2

a,@DPTR external add in DPTR to

acc

Movx @Rp,a Copy the content of acc Indirect 1 2

to the external add in Rp

Movx Copy the content of acc Indirect 1 2

@DPTR,a to the external add in

DPTR

Movc The address is formed indirect 1 2

a,@a+DPTR by adding acc and


DPTR and its content is

copied to acc

Movc a, The address is formed indirect 1 2

@a+PC by adding acc and PC

and its content is copied

to acc

Push add Increment SP and copy Direct 2 2

the data from source

add to internal RAM

address contained in SP

Pop add copy the data from direct 2 2

internal RAM address

contained in SP to

destination add and

decrement SP

Xch a, Rx Exchange the data Register 1 1

between acc and Rx

Xch a, add Exchange the data Direct 2 1

between acc and given

add

Xch a,@Rp Exchange the data Indirect 1 1

between acc and

address in Rp

Xchd a, @Rp Exchange only lower indirect 1 1

nibble of acc and

address in Rp
Logical Instructions
Logical Instructions: –

Mnemonics Operational Addressin No. of No. of


description g mode bytes cycles

occupied used

Anl a, #num AND each bit of acc with Immediate 2 1

same bit of immediate

num, stores result in acc

Anl a, add AND each bit of acc with Direct 2 1

same bit of content in

add, stores result in acc

Anl a, Rx AND each bit of acc with Register 1 1

same bit of content of

Rx, stores result in acc

Anl a, @Rp AND each bit of acc with Indirect 1 1

same bit of content of

add given by Rp, stores

result in acc

Anl add, a AND each bit of acc with Direct 2 1

same bit of direct add

num, stores result in add

Anl add, AND each bit of direct direct 3 2

#num add with same bit of

immediate num, stores

result in add

orl a, #num OR each bit of acc with Immediate 2 1

same bit of immediate

num, stores result in acc

orl a, add OR each bit of acc with Direct 2 1

same bit of content in

add, stores result in acc

orl a, Rx OR each bit of acc with Register 1 1


same bit of content of

Rx, stores result in acc

orl a, @Rp OR each bit of acc with Indirect 1 1

same bit of content of

add given by Rp, stores

result in acc

orl  add, a OR each bit of acc with Direct 2 1

same bit of direct add

num, stores result in add

orl add, OR each bit of direct add direct 3 2

#num with same bit of

immediate num, stores

result in add

Xrl a, #num XOR each bit of acc with Immediate 2 1

same bit of immediate

num, stores result in acc

Xrl a, add XOR each bit of acc with Direct 2 1

same bit of content in

add, stores result in acc

Xrl a, Rx XOR each bit of acc with Register 1 1

same bit of content of

Rx, stores result in acc

Xrl  a, @Rp XOR each bit of acc with Indirect 1 1

same bit of content of

add given by Rp, stores

result in acc

Xrl add, a XOR each bit of acc with Direct 2 1

same bit of direct add

num, stores result in add


Xrl add, XOR each bit of direct direct 3 2

#num add with same bit of

immediate num, stores

result in add

Clr a Clear each bit of acc Direct 1 1

Cpl a Complement each bit of direct 1 1

acc

Anl c, b AND carry with given bit — 2 2

b, stores result in carry

Anl c, /b AND carry with — 2 2

complement of given bit

b, stores result in carry

Orl c, b OR carry with given bit — 2 2

b, stores result in carry

Orl c, /b OR carry with — 2 2

complement of given bit

b, stores result in carry

Cpl c Complement carry flag — 1 1

Cpl b Complement bit b — 2 1

Clr c Clear carry flag — 1 1

Clr b Clear given bit b — 2 1

Mov c, b Copy bit b to carry — 2 1

Mov b, c Copy carry to bit b — 2 2

Setb c Set carry flag — 1 1

Setb b Set bit b — 2 1

Rl a Rotate acc one bit left — 1 1

Rr a Rotate acc one bit right — 1 1

Rlc a Rotate acc one bit left — 1 1

with carry
Rrc a Rotate acc one bit right — 1 1

with carry

Swap a Exchange upper and — 1 1

lower nibble of acc


Arithmetic Instructions
Arithmetic Instructions: –

Mnemonics Operational description Addressing No. of No. of

mode bytes cycles

occupied used

Inc a Add 1 to acc Register 1 1

Inc Rr Add 1 to register Rr Register 1 1

Inc add Add 1 to the content of Direct 2 1

add

Inc @rp Add 1 to the content of the indirect 1 1

address in Rp

Inc DPTR Add 1 to DPTR Register 1 2

dec a Subtract 1 from acc Register 1 1

dec Rr Subtract 1 from Rr Register 1 1

dec add Subtract 1 from content of Direct 2 1

add

dec @rp Subtract 1 from the indirect 1 1

content of address

Add a, Add the immediate num immediate 2 1

#num with acc and stores result

in acc

Add a, Rx Add the data in Rx with Register 1 1

acc and stores result in

acc
Add a, add Add the data in add with Direct 2 1

acc and stores result in

acc

Add a, Add the data at the Indirect 1 1

@Rp address in Rp with acc

and stores result in acc

Addc Add the immediate num immediate 2 1

a,#num with acc and carry, stores

result in acc

Addc a, Rx Add the data in Rx with Register 1 1

acc and carry, stores

result in acc

Addc a, Add the data in add with Direct 2 1

add acc and carry, stores

result in acc

Addc a, Add the data at the Indirect 1 1

@Rp address in Rp with acc

and carry, stores result in

acc

Subb a, Subtract immediate num immediate 2 1

#num and carry from acc; stores

the result in acc

Subb a, Subtract the content of Register 1 1

add add and carry from acc;

stores the result in acc

Subb a, Rx Subtract the data in Rx Direct 2 1

and carry from acc; stores

the result in acc


Subb a, Subtract the data at the Indirect 1 1

@Rp address in Rp and carry

from acc; stores the result

in acc

Mul ab Multiply acc and register — 1 4

B. store the lower byte of

result in acc and higher

byte in B

div ab divide acc by register B. — 1 4

store quotient in acc and

remainder in B

Da a After addition of two — 1 1

packed BCD numbers,

adjust the sum to decimal

format
Branching Instructions
Branching Instructions: –

Mnemonic Operational description No of bytes No. of

occupied cycles

used

Jc label Jump to label if carry is set to 1 2 2

Jnc label Jump to label if carry is cleared to 0 2 2

Jb b,label Jump to label if given bit is set to 1 3 2

Jnb Jump to label if given bit is cleared to 3 2

b,label 0

Jbc Jump to label if given bit is set. Clear 3 2

b,label the bit

Cjne a, Compare the content of accumulator 3 2

add, label with the content of given address and


if not equal jump to label

Cjne a, Compare the content of accumulator 3 2

#num, with immediate number and if not

label equal jump to label

Cjne Rx, Compare the content of Rx with the 3 2

#num, immediate number and if not equal

label jump to label

Cjne Compare the content of location in Rp 3 2

@Rp, with immediate number and if not

#num, equal jump to label

label

Djnz Rx, Decrement the content of Rx and 2 2

label jump to the label if it is not zero

Djnz add, Decrement the content of address and 3 2

label jump to the label if it is not zero

Jz label Jump to the label if content of 2 2

accumulator is 0

Jnz label Jump to the label if content of 2 2

accumulator is not 0

Jmp Jump to the address created by 1 2

@a+dptr adding the contents on accumulator

and dptr

Ajmp Take a jump to absolute short range 2 2

sadd address sadd

Ljmp ladd Take a jump to absolute long range 3 2

address sadd

Sjmp radd Take a jump to relative address radd 2 2

nop Short form of no operation means do 1 1


nothing and go to next instruction

Acall Pushes the content of Acc on stack 2 2

sadd and load it will absolute short range

address sadd

Lcall ladd Pushes the content of Acc on stack 3 2

and load it will absolute long range

address sadd

Ret returns from subroutine by restoring 1 2

the Acc from stack using pop

operation

reti Returns from interrupt subroutine by 1 2

restoring Acc from stack using pop

operation

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy