Você está na página 1de 15

8085

8086

8051

DATA TRANSFER INSTRUCTIONS:


Move a byte or word
1.MOV Rd,Rs copies the contents of source 1.MOV Reg, Reg
Reg,
M
from the specified
M,Rs register/memory into the
M, Reg
source to the
Rd,M destination register/memory
Reg,
Imm
specified
destination.
Example: MOV B,C
M,
Imm
MOV B,M
Example: MOV CX, 037AH
MOV AX, BX
2.MVI Reg,Data the 8-bit data is stored in
MOV DL, [BX]; Copy byte from
M,Data
the destination register/
memory at BX to DL, BX contains the offset of
memory
byte in DS.
Example: MVI B,92H
MVI M,3AH
3.LDA 16-bit
Addr

the contents of a memory


location, specified by a 16-bit
address are copied to the
accumulator.
Example: LDA 2050H
4.LDAX B/D the contents of the designated
Reg register pair are copied to the
Pair accumulator.
Example: LDAX B

2. PUSH Reg
M

Move the specified word to


the top of the stack by
decrementing SP by 2.
Example: PUSH BX
PUSH DS
PUSH TABLE[BX]; decrement SP by 2
and copy word from memory in DS at
EA= TABLE + [BX] to stack.
3. POP Reg
M

5.LXI reg pair, loads 16-bit data in the


16-bit
designated register pair.
Data
Example: LXI B,2050H
Loads 50H in C & 20H in B.

Move a word from top of stack


to specified location and
increments SP by 2.
Example: POP DX
POP DS
POP TABLE [BX]; copy a word from
top of stack to memory in DS with
EA= TABLE + [BX]

6.LHLD 16-bit
copies the contents of the
Address memory location pointed

4. XCHG Reg, Reg Exchange bytes or words


Reg, M
in the specified location.

1.MOV A,<scr>
copy the contents of
<dest>,A
source to destination.
<dest>,<scr>
( <scr>/<dest>:
DPTR,#data16 direct,@Ri,#data,Rn )
Example: MOV A,R3
MOV @R0,A
MOV R5,#32
MOV DPTR,#1234
2. MOVC A,@A+DPTR Moves the code byte
Relative to the DPTR
to the accumulator
(address=A+DPTR)
Example: MOVC A,@A+DPTR
DB 66h
DB 77h
DB 88h
DB 99h
Before execution
After execution
DPTR=1000
A=0
A=66h
A=1
A=77h
A=2
A=88h
A=3
A=99h
Note: DB (Define Byte) is a directive in
assembly language used to define constant.
3.MOVC A,@A+PC Moves the code byte
relative to the PC to the
accumulator
(address=A+PC)

out by the 16-bit address in


register L & copies the contents
of next memory location in
register H.
Example: LHLD 2050H
Memory contents
register contents
before instruction
after instruction
2050-90
H-01
2051-01
L-90

Example: XCHG AX, DX


XCHG BL, CH
5. XLAT none Translate a byte in AL using a
look-up table in the data
segment accessed by BX.

the contents of accumulator


are copied to the specified
memory location.
Example: STA 9000H

6. IN AL, Port 8 move a byte or word from


AX, Port 8 specified input port to
AL, DX
accumulator.
AX, DX
Example: IN AL, 0C8H
(Initialize DX point to a port before using it in
the instruction)

8.STAX B/D contents of accumulator are


reg copied into the memory
pair location specified by the
contents of reg. pair.
Example: STAX B

7. OUT Port8, AL move a byte or word from


Port8, AX accumulator to specified
DX, AL
output port.
DX, AX
Example: OUT 3BH, AL

9.SHLD 16-bit contents of reg L are stored


addr in memory location specified
by 16-bit addr & contents of H
reg. are stored in the next
memory location.
Example: SHLD 2050H

8. LEA Reg, M Load the effective address of


the operand in the memory in
the specified register.
Example: LEA BX, PRICE; Load BX with offset of
PRICE in DS

7.STA 16-bit
Addr

10.XCHG none contents of reg H is


exchanged with that of reg D
& reg L with reg E.
11.SPHL none

loads the contents of H & L


registers into stack pointer

9.LDS Reg, M Load the DS register and the


specified register with the
pointer from the memory.
Example: LDS BX, [4326] - copy the contents of
the memory at 4326H in DS to BL, contents of
4327H to BH. Copy contents of 4328H and
4329H in DS to DS register.

Example: INC A
MOVC A,@A+PC
RET
DB 66h
DB 77h
DB 88h
DB 99h
After the subroutine "Table" has been
executed, one of four values is stored in the
accumulator:
Before execution
After execution
A=0
A=66h
A=1
A=77h
A=2
A=88h
A=3
A=99h
4.MOVX A,@Ri
Move the contents in the
A,@DPTR external RAM to the
@Ri,A
specified location or
@DPTR,A vice-versa.
Example: MOVX A,@R0
Register Address: SUM=12h
Before execution: SUM=58h R0=12h
After execution: A=58h
Note: SUM Register is stored in external RAM
which is 256 bytes in size.
5.PUSH direct Pushes the direct byte onto
the stack
Example: PUSH DPL
PUSH DPH
Before execution: Address Value
SP==> 030h 20h

register.
H: higher-order address
L: lower-order address
12.XTHL none contents of L register are
exchanged with the stack
location pointed out by SP.
Contents of H register are
exchanged with the next stack
location.
13.PCHL none contents of H-L pair are copied
into the program counter.
H: higher-order byte
L: lower-order byte
14.PUSH reg. contents of reg. pair
Pair designated are copied into
the stack.
15.POP reg.
pair

16.IN 8-bit
port
addr

contents specified by the SP


are copied to the designated
register pair.
contents of designated
input port are read and loaded
into the accumulator.

10.LES Reg, M Load the ES register and the


specified register with the
pointer from the memory.
Example: LES BX, [4326]
11. LAHF none Load AH with the low byte
content of the flag register.
12.SAHF none Store AH in the low byte
content of the flag register.
13.PUSHF none Move the flag register
content to the top of the
stack.
14.POPF none Move the word from the top
of the stack to the flag
register.

DPTR=0123h (DPH=01, DPL=23h)


After execution: Address Value
030h 20h
031h 23h
SP==> 032h 01h
6.POP direct Pops the direct byte from the
stack/td>
Example: POP DPH
POP DPL
Before execution: Address Value
030h 20h
031h 23h
SP==> 032h 01h
DPTR=0123h (DPH=01, DPL=23h)
After execution: Address Value
SP==> 030h 20h
031h 23h
032h 01h
7.XCH A,Rn
Exchanges the source with
A,direct the accumulator.
A,@Ri
Example: XCH A,R3
Before execution: A=C6h, R3=29h
After execution: R3=C6h, A=29h
8.XCHD A,@Ri

17.OUT 8-bit contents of accumulator are


port copied into the output port
addr specified.

Exchanges the low-order


nibble indirect RAM with
the accumulator
Example: XCHD A,@R0
Register address: SUM=E3
Before execution: R0=E3 SUM=29h A=A8h,
After execution: A=A9h, SUM=28h

ARITHMETIC INSTRUCTIONS:
1.ADD Reg Add the contents of register/
M memory to accumulator.
2.ADC Reg Add the contents of register/
M
memory & the Carry flag to
the contents of accumulator.
3.ADI 8-bit Add the 8-bit data to the
data contents of accumulator.
4.ACI 8-bit Add the 8-bit data and the Carry
data flag to accumulator.
5.DAD Reg. Add the 16-bit contents of the
pair specified register pair to the
contents of HL register.
6.SUB Reg Subtract the contents of register/
M memory from accumulator.
7.SBB Reg Subtract the contents of register/
M
memory & the Carry flag from
the contents of accumulator.
8.SUI 8-bit Subtract the 8-bit data from the
data contents of accumulator.
9.SBI 8-bit Subtract the 8-bit data and the
data Carry flag from accumulator.
10.INR Reg Increment the contents of
M register/memory by 1.

1.ADD Reg,Reg Add the contents of source


Reg,M to the contents of
M,Reg destination.
Reg,Imm
M,Imm
2.ADC Reg,Reg Add the contents of source
Reg,M to the contents of
M,Reg destination with carry.
Reg,Imm
M,Imm
3.INC Reg Increment the contents of
M
register/memory by 1.
4.AAA none ASCII(unpacked BCD) adjust
after addition. The AL register is
the implied source and
destination operand.
Example:
MOV AH,0 Clear AH for MSD
MOV AL,6 BCD 6 in AL
ADD AL,5 Add BCD 5 to digit in AL
AAA
AH=1, AL=1 representing BCD 11.
5.DAA none Decimal (BCD) adjust after
addition. The AL register is the
implied source and destination
operand.
Example:
ADD AL,BL Before: AL=79H,BL=35H
After : AL=AEH,BL=35H

1. ADD A,Rn
A,direct
A,@Ri
A,#data

Add the contents of


source to destination.

2. ADDC A,Rn
A,direct
A,@Ri
A,#data

Add the contents of


source to destination
with carry flag.

3. SUBB A,Rn
A,direct
A,@Ri
A,#data

Subtract the contents of


source from destination
with borrow.

4.INC A
Rx
Rn
@Ri
DPTR

Increment the contents of


operand by 1.

5.DEC A
Rx
Rn
@Ri

Decrement the contents of


operand by 1.

6.MUL AB

Multiply A and B.

7.DIV

Divide A by B.

AB

8.DA A Decimal adjustment of the


accumulator according to BCD code.

11.INX Reg Increment the contents of


pair register pair by 1.
12.DCR Reg Decrement the contents of
M register/memory by 1.
13.DCX Reg Decrement the contents of
pair register pair by 1.
14.DAA none Decimal -Adjust Accumulator.
The contents of the
accumulator are changed
from a binary value to two
4-bit BCD digits.

DAA

Before: AL=AEH,BL=35H
After : AL=14H,BL=35H
6.SUB Reg,Reg Subtract the contents of
Reg,M source with the contents of
M,Reg destination.
Reg,Imm
M,Imm
7.SBB Reg,Reg Subtract the contents of
Reg,M source from the contents of
M,Reg destination with borrow.
Reg,Imm
M,Imm
8.DEC Reg Decrement the contents of
M
register/memory by 1.
9.NEG Reg Change the sign of the specified
M byte or word by taking 2's
complement.
Example: AX = 2CBh
NEG AX ;after executing NEG result
AX =FD35h.
10.CMP Reg,Reg Compare specified bytes
Reg,M
or words.
M,Reg
Reg,Imm
M,Imm
11.AAS none ASCII(unpacked BCD) adjust
after subtraction.
Example: MOV AX,0901H ;BCD 91
SUB AL, 9 ;Minus 9

AAS ; Give AX =0802 h (BCD 82)


12.DAS none Decimal (BCD) adjust after
subtraction.
Example: MOV BL, 28H
MOV AL, 83H
SUB AL,BL; AL=5BH
DAS ; adjust as AL=55H
13.MUL Reg Multiply the unsigned operand
M
with that in register AX.
14.IMUL Reg Multiply the signed operand
M
with that in register AX.
15.AAM none ASCII adjust after
multiplication.
16.DIV Reg Divide the unsigned word in AX
M by the unsigned byte in the
register/memory or the unsigned
double word in DX-AX by the
unsigned word in the
register/memory.
17.IDIV Reg Divide the signed word in AX
M by the signed byte in the
register/memory or the signed
double word in DX-AX by the
signed word in the register/
memory.
18.AAD none ASCII adjust before division.

19.CBW none Convert the signed byte in AL


into the signed word in AX.
It extends AL into AX by
repeating the top bit of AL in
every bit of AH.
Example:
Before :AL = 00000000 10011011
= - 155 decimal
CBW
Result : AX = 11111111 10011011
= - 155 decimal
20.CWD none Convert the signed byte in AX
into the signed double word
in DX-AX.
Example: DX = 00000000 00000000
AX = 11110000 11000111 = - 3897 decimal
CWD
Result: DX = 11111111 11111111
AX = 11110000 11000111 = -3897 decimal .

LOGICAL INSTRUCTIONS:
1.CMP Reg contents of register/memory are
M compared with that of
accumulator.
If (A)<(Reg/M):carry flag is set and zero flag
is reset.
If (A)=(Reg/M):Zero flag is set and carry flag
is reset.
If (A)>(Reg/M):carry & zero flags are reset.

BIT MANIPULATION INSTRUCTIONS:

LOGICAL INSTRUCTIONS:

1.NOT Reg Take 1's complement of the byte


M or word.

1. ANL A,Rn
AND source with
A,direct
destination.
A,@Ri
A,#data
direct,A
direct,#data
Example: ANL MASK,C3H
Before execution: X = C3H (11000011)
MASK = 55H (01010101)
After execution: MASK = 41H (01000001)

2.AND Reg,Reg
Reg,M
M,Reg
Reg,Imm
M,Imm

AND two bytes or words.

2.CPI 8-bit
Data
3.ANA Reg
M

The 8-bit data is compared with


the contents of accumulator.
contents of accumulator is
logically ANDed with the contents
of Reg/M and the result is placed
in the accumulator.

4.ANI 8-bit contents of accumulator is


data logically ANDed with the 8-bit
Data.
5.ORA Reg contents of accumulator is
M logically ORed with the contents
of Reg/M.

3.OR

Reg,Reg
Reg,M
M,Reg
Reg,Imm
M,Imm

4.XOR Reg,Reg
Reg,M
M,Reg
Reg,Imm
M,Imm

OR two bytes or words.

XOR two bytes or words.

2. ORL A,Rn
OR source with
A,direct
destination.
A,@Ri
A,#data
direct,A
direct,#data
Example: ORL A,@R1
Register address: TEMP = FAH
Before execution: R1 = FAH
TEMP = C2H (11000010)
A = 54H (01010100)
After execution: A = D6H (11010110)

5.TEST Reg,Reg AND two bytes or words


Reg,M
to update flags; operands 3. XRL A,Rn
XOR source with
Reg,Imm are not changed. It is often
A,direct
destination.
6.ORI 8-bit contents of accumulator is
M,Imm
used to set flags before a
A,@Ri
data logically ORed with the 8-bit Data.
condition jump instruction.
A,#data
Example:TEST AL, BH
direct,A
7.XRA Reg contents of accumulator is
AND BH with AL. no result is stored .
direct,#data
M logically Exclusively ORed with the
Update PF, SF, ZF.
Example: XRL A,R3
contents of Reg/M.
Before execution: A = C3H (11000011)
6.SHL/ Reg,1/CL Shift bits of byte or word
R3 = 55H (01010101)
8.XRI 8-bit contents of accumulator is
SAL M,1/CL left either by 1 bit or by the After execution: A = 96H (10010110)
data logically Exclusively ORed with the
no.of bits specified by CL.
8-bit data.
As a bit is shifted out of LSB 4. CPL A Complements the accumulator.
position a 0 is kept at LSB .
(1 = 0; 0 = 1)
9.RLC none Each binary bit of accumulator is
CF will contain MSB bit.
rotated left by one position. Bit
5.SWAP A
Swap nibbles within the
D7 is placed in the position of D0 7.SHR Reg,1/CL Shift bits of byte or word
Accumulator.
as well as in the carry flag.
M,1/CL right either by 1 bit or by the Example: SWAP A
no.of bits specified by CL.As
Before execution: A = E1H (11100001)
10.RRC none Each binary bit of accumulator is
a bit is shifted out of MSB
After execution: A = 1EH (00011110)
rotated right by one position. Bit
position a 0 is kept at MSB.
D0 is placed in the position of D7
CF will contain LSB bit.
6. RL A Rotate bits in the accumulator left.

as well as in the carry flag.


11.RAL none Each binary bit of accumulator
is rotated left by one position
through the carry flag. Bit
D7 is placed in the bit in the
carry flag & the carry flag is
placed in D0.
12.RAR none Each binary bit of accumulator
is rotated right by one position
through the carry flag. Bit
D0 is placed in the bit in the
carry flag & the carry flag is
placed in D7.
13.CMA none contents of accumulator is
complemented.
14.CMC none carry flag is complemented.
15.STC none carry flag is set to 1.

8.SAR Reg,1/CL Shift bits of byte or word


M,1/CL right either by 1 bit or by
the no.of bits specified
by CL. As bit is shifted out, a
copy of old MSB is taken in
MSB position and LSB is
shifted to CF.
Example: BH = 11110011=- 13 decimal, CF = 1
SAR BH, 1
BH = 11111001 = - 7 decimal, CF = 1
9.ROL Reg,1/CL Rotate the bits of byte or
M,1/CL word left either by 1 bit or
by the no.of bits specified by
CL.The MSB is moved to LSB
& to the carry flag.
Example: BX = 01011100 11010011
CL = 8 bits to rotate
ROL BH, CL
CF =0, BX =11010011 01011100
10.ROR Reg,1/CL Rotate the bits of byte or
M,1/CL word right either by 1 bit or
by the no.of bits specified by
CL.The LSB is moved to MSB
& to the carry flag.
11.RCL Reg,1/CL Rotate the bits of byte or
M,1/CL word left either by 1 bit or
by the no.of bits specified by
CL.The MSB is moved to CF
& CF to LSB.

7.RLC A

Rotates bits in the accumulator left


through carry.

8. RR A Rotates bits in the accumulator right.


9. RRC A

Rotates bits in the accumulator


right through carry.

BIT MANIPULATION INSTRUCTIONS:


1. CLR C/bit Clears the carry flag/direct bit.
Example: CLR P0.3
Before execution: P0.3 = 1
After execution: P0.3 = 0
2. SETB C/bit Sets the carry flag/direct bit.
Example: SETB P1.0
Before execution: P1.0 = 34H (00110100)
Pin1 is configured as an output
After execution: P1.0 = 35H (00110101)
Pin1 is configured as an input
3. CPL C/bit Complements the carry flag/
direct bit.
4. ANL C,bit AND direct bit to the carry flag.
5. ANL C,/bit AND complements of direct bit
to the carry flag
Example: ANL C,/ACC.7
Before execution: ACC = 43h (01000011) C = 1
After execution: ACC = 43h (01000011) C = 1
6. ORL C,bit

OR direct bit to the carry flag.

BRANCHING INSTRUCTIONS:
1.JMP 16-bit Jump unconditionally. The
addr program sequence is transferred
to the memory location
specified by the 16-bit address.
2.Jx 16-bit address Jump unconditionally.
JC :Jump on Carry
CY=1
JNC:Jump on No Carry
CY=0
JP :Jump on Positive
S=0
JM :Jump on Minus
S=1
JPE:Jump on Parity Even
P=1
JPO:Jump on Parity Odd. P=0
JZ :Jump on Zero.
Z=1
JNZ:Jump on No Zero.
Z=0
3.CALL 16-bit Unconditional Subroutine Call.
addr The program sequence is
transferred to the memory
location specified by the 16-bit

12.RCR Reg,1/CL Rotate the bits of byte or


M,1/CL word right either by 1 bit or
by the no.of bits specified by
CL.The LSB is moved to CF
& CF to MSB.
Example: CF = 1, BL = 00111000
RCR BL, 1
Result: BL = 10011100, CF =0

7. ORL C,/bit OR complements of direct bit to


the carry flag.
Example: ORL C,ACC.3
Before execution: ACC = C6H (11001010) C = 0
After execution: C = 0

1.JMP Disp16
Jump to the specified
Disp8
address to get the next
Reg
instruction for execution.
Mem
Offset 16,seg16

1.ACALL addr11 Absolute subroutine call.


Example: 0122
0123 ACALL SUBRTN
0124
.
.
0345 SUBRTN
0346
Before execution: PC=0123h
After execution: PC=0345h

2. JA/JNBE 8-bit Jump if above /jump if not


addr below or equal .
3. JAE/JNB 8-bit Jump if above or equal /
addr jump if not below.
4. JBE/JNA 8-bit Jump if below or equal /
addr Jump if not above.
5. JE/JZ 8-bit
addr

Jump if equal /Jump if 0


( Jump if the zero flag is 1 )

6. JG/JNLE 8-bit Jump if greater /jump if not


addr lesser than or equal.
7. JGE/JNL 8-bit

Jump if greater or equal /

8. MOV C,bit Moves the direct bit/carry flag


bit,C to the carry flag/direct bit.
Example: MOV C, P1.4
After execution: If P1.4 = 0 C = 0
If P1.4 = 1 C = 1

2.LCALL addr16 Long subroutine call.


Example: 0123 LCALL SUBRTN
.
.
1234 SUBRTN
3.RET none Return from subroutine.
4.RETI none Return from interrupt
subroutine.

address.
4.Cx 16-bit address Conditional Call to
Subroutine.
CC : Call on Carry
CY=1
CNC: Call on No Carry
CY=0
CP : Call on Positive
S=0
CM : Call on Minus
S=1
CPE : Call on Parity Even P=1
CPO: Call on Parity Odd. P=0
CZ : Call on Zero.
Z=1
CNZ: Call on No Zero.
Z=0
5.RET none The program sequence is
transferred from the subroutine
to the calling program .
6.Rx none Return conditionally.
RC : Return on Carry
CY=1
RNC: Return on No Carry
CY=0
RP : Return on Positive
S=0
RM : Return on Minus
S=1
RPE : Return on Parity Even P=1
RPO: Return on Parity Odd. P=0
RZ : Return on Zero.
Z=1
RNZ: Return on No Zero.
Z=0
7.RST 0-7 Restart.Used to transfer program
execution to one of the 8 locations.
RST 0 0000H
RST 1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H

addr

Jump if not lesser than.

8. JL/JNGE 8-bit Jump if lesser than /Jump if


addr not greater than or equal.
9. JLE/JNG 8-bit Jump if lesser than or equal
addr /jump if not greater than.
10. JNC 8-bit
addr

Jump if the carry flag is zero.

11. JNE/JNZ 8-bit


addr

Jump if not equal /Jump


if not 0 (Jump if the Zero
flag is Zero )

5.AJMP addr11 Absolute jump.


6.LJMP

addr16 Long jump.

7.SJMP rel Short jump. It enables jump to


the new address which should
be in the range of -128 to +127
locations relative to the first
following instruction.
Example:0322
0323 SJMP PUSH_BUTTON
0324
.
.
0345 PUSH_BUTTON

12. JNO 8-bit Jump if the overflow flag is 0.


addr

8.JC rel Jump if carry flag is set.Short jump.

13. JNP/JPO 8-bit Jump if the parity flag is 0.


addr

9.JNC rel Jump if carry flag is not set. Short


jump.

14. JNS 8-bit Jump if the sign flag is zero.


addr

10.JB bit,rel Jump if direct bit is set. Short


jump.
Example:0322
0323 JB P0.5,PUSH_BUTTON
0324
.
.
0345 PUSH_BUTTON
Before execution: PC=0323h
After execution: If P0.5=0: PC=0324h
If P0.5=1: PC=0345h

15. JO 8-bit Jump if the overflow flag is 1.


addr
16. JP/JPE 8-bit Jump if the parity flag is 1.
addr
17. JS 8-bit addr Jump if the sign flag is 1.
18. JB/JNAE 8-bit Jump if below /Jump if
addr not above or equal.

11.JNB bit,rel Jump if direct bit is not set.

RST 6
RST 7

0030H
0038H

19.LOOP 8-bit Execute the loop CX times.


addr
Example:
MOV BX, OFFSET PRICE
MOV CX, 40
NEXT: MOV AL, [BX]
ADD AL, 07H
DAA
MOV [BX], AL
LOOP NEXT
20.LOOPE/ 8-bit Execute the loop when CX
LOOPZ addr is not 0 & ZF is 1.
21.LOOPNE/ 8-bit Execute the loop when
LOOPNZ addr CX is not 0 & ZF is 0.
22.JCXZ addr Jump to the specified address
if CX is 0.

CONTROL INSTRUCTIONS:
1.NOP none No operation.Used to fill in time
delays or to delete and insert
instructions while
troubleshooting.
2.HLT none Halt and enter wait state.
An interrupt or reset is necessary
to exit from the Halt state.
3.DI none Disable Interrupts.

1.CALL Disp16 Call a subroutine present in


Reg
the same segment or in
M
another segment.
Offset16,Seg16
2.RET none Return from the subroutine to
the main program.
3.INT N Call the interrupt service procedure
of interrupt type N.

12.JBC bit,rel Jump if direct bit is set and


clears bit. Short jump.
Example:0322
0323 JBC P0.5,PUSH_BUTTON
0324
.
.
0345 PUSH_BUTTON
Before execution: PC=0323h
After execution:
If TEST0.4=1: PC=0345h, TEST0.4=0
If TEST0.4=0: PC=0324h, TEST0,4=0
13.JMP @A+DPTR Jump indirect relative to
the DPTR.
It causes a jump to the address calculated by
adding value stored in the accumulator to the
16-bit number in the DPTR Register. It is used
with complex program branching where the
accumulator affects jump address, for
example when reading a table.
Example:0223 JMP @A+DPTR
1402 AJMP LABEL1
1403
1404 AJMP LABEL2
1405
1406 AJMP LABEL3
Before execution: PC=223 DPTR=1400h
After execution: PC = 1402h if A=2
PC = 1404h if A=4
PC = 1406h if A=6

All the interrupts except the TRAP


are disabled.
4.EI none Enable Interrupts.
5.RIM none Read Interrupt Mask.
Reads the status of interrupts
7.5,6.5,5.5 and serial data input
bit. It loads 8 bits in the
accumulator.
6.SIM none Set Interrupt Mask.
Implements interrupts(7.5,6.5,
5.5) & serial data output.

4.INTO none Call the interrupt service


procedure of overflow
interrupt(type 4) if the
overflow flag is 1.
5.IRET none Return from the interrupt
service procedure to the main
program.
6.HLT none Halt until interrupt or reset is
activated.
7.WAIT none Wait until signal on the TEST
pin goes low.
8.ESC none Escape to the external
coprocessor such as 8089/8087.
9.LOCK(prefix) An instruction prefix that
prevents another processor
from taking the system bus
when the instruction is
executed.
10.NOP none No Operation.
11.STC none
12.CLC none
13.CMC none
14.STD none
15.CLD none
16.STI none
17.CLI none

Set the carry flag to 1.


Clear the carry flag to 0.
Complement the content of CF
Set the direction flag to 1.
Clear the direction flag to 0.
Set the interrupt flag to 1.
Clear the interrupt flag to 0.

14.JZ rel Jump if accumulator is zero. Short


Jump.
15.JNZ rel Jump if accumulator is not zero.
Short jump.
16. CJNE A,direct,rel Compare the
A,#data,rel
operands and jump
Rn,#data,rel if not equal.
@Ri,#data,rel Short jump.
Example:0322
0323 JUMP4
0324
.
.
0345 CJNE @R0,44,JUMP4
0346
Before execution: Register Address SUM=F3h
PC=0345h R0=F3h
After execution: If SUM44h: PC=0323h
If SUM=44h: PC=0346h
17. DJNZ Rn,rel
Decrement and jump if
direct,rel not zero. Short jump.
Example:0322
0323 LABEL1
0324
.
.
0345 DJNZ R1,LABEL1
0346
Before execution: PC=0345h
After execution: If R10: PC=0323h
If R1=0: PC=0346h

STRING INSTRUCTIONS:
1.MOVSB/ none Move the byte or word
MOVSW
string from the data
segment to the extra
segment.
2.COMPS/ none Compare two string bytes
COMPW
or two string words.
3.SCASB/
SCASW

none Compare a string byte


with a byte in AL or
compare a string word
with a word in AX.

4.LODSB/ none Load a string byte/word


LODSW
from the data segment to
AL/AX.
Example:
CLD Clear direction flag so SI is auto
incremented
MOV SI, OFFSET SOURCE_STRING
point SI at start of the string
LODS SOUCE_STRING Copy byte or word
from string to AL or AX
5.STOSB/
STOSW

none Store the string byte/word


from AL/AX into the extra
segment.

6.REP(prefix)

Repeat a string instruction CX


times.

18.NOP none No Operation.

7.REPE/ REPZ
(prefix)

Repeat a string instruction


when the zero flag is 1 and CX
is not 0.

8.REPNE/REPNZ Repeat a string instruction


(prefix)
when the zero flag is 0 and
CX is not 0.

Description of all 8051 instructions


Here is a list of the operands and their meanings:

A - accumulator;
Rn - is one of working registers (R0-R7) in the currently active RAM memory bank;
Direct - is any 8-bit address register of RAM. It can be any general-purpose register or a SFR (I/O port, control register etc.);
@Ri - is indirect internal or external RAM location addressed by register R0 or R1;
#data - is an 8-bit constant included in instruction (0-255);
#data16 - is a 16-bit constant included as bytes 2 and 3 in instruction (0-65535);
addr16 - is a 16-bit address. May be anywhere within 64KB of program memory;
addr11 - is an 11-bit address. May be within the same 2KB page of program memory as the first byte of the following instruction;
rel - is the address of a close memory location (from -128 to +127 relative to the first byte of the following instruction). On the basis of it,
assembler computes the value to add or subtract from the number currently stored in the program counter;
bit - is any bit-addressable I/O pin, control or status bit; and
C - is carry flag of the status register (register PSW).

Você também pode gostar