8051 Instruction Set - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

8051 Instruction Set

Description:

8051 (Instruction) OK: ADD A, R3 ; A A + R3 OK / (Label) ADD (op-Code) ... – PowerPoint PPT presentation

Number of Views:198
Avg rating:3.0/5.0
Slides: 38
Provided by: yst5
Category:
Tags: instruction | set

less

Transcript and Presenter's Notes

Title: 8051 Instruction Set


1
8051??
http//www.win.tue.nl/aeb/comp/8051/set8051.html
http//www.mikroe.com/en/books/8051book/ch3/
http//www.8052.com/tut8051
2
? ?
  • ???????
  • ???????????
  • ????????
  • ??????

3
8051?????
  • ???? ?? ??? ???, ??
  • ??/??(Label)?????????????(ROM)??,????
  • ???(Op-Code)?????????,?????????...???
  • ???, (Operand)????,????????????0??????3??
  • ?????????,????

4
8051???(Instruction)????
  • ???? OK ADD A, R3 ? A ? A R3
  • OK???/??(Label)?
  • ADD?????(op-Code)????(Addition)?
  • A?R3?????(Register)?????? (Operand)?
  • ?? ? A ? R3???? ??A,??? A ? A R3

5
???????????
  • 8051?????(Addressing Mode)?6?
  • ?????????????????????
  • ??
  • ???
  • RAM ??
  • RAM ??
  • RAM ??
  • RAM ??
  • ROM

6
8051????
  • 8051??43????(Op-Code)
  • 8051????(Operand)?6????????(Addressing Mode)
  • ???????????111???????

7
8051????
ACALL - Absolute Call ADD, ADDC - Add Accumulator (With Carry) AJMP - Absolute Jump ANL - Bitwise AND CJNE - Compare and Jump if Not Equal CLR - Clear Register CPL - Complement Register DA - Decimal Adjust DEC - Decrement Register DIV - Divide Accumulator by B DJNZ - Decrement Register and Jump if Not Zero INC - Increment Register JB - Jump if Bit Set JBC - Jump if Bit Set and Clear Bit JC - Jump if Carry Set JMP - Jump to Address JNB - Jump if Bit Not Set JNC - Jump if Carry Not Set JNZ - Jump if Accumulator Not Zero JZ - Jump if Accumulator Zero LCALL - Long Call LJMP - Long Jump MOV - Move Memory MOVC - Move Code Memory MOVX - Move Extended Memory MUL - Multiply Accumulator by B NOP - No Operation ORL - Bitwise OR POP - Pop Value From Stack PUSH - Push Value Onto Stack RET - Return From Subroutine RETI - Return From Interrupt RL - Rotate Accumulator Left RLC - Rotate Accumulator Left Through Carry RR - Rotate Accumulator Right RRC - Rotate Accumulator Right Through Carry SETB - Set Bit SJMP - Short Jump SUBB - Subtract From Accumulator With Borrow SWAP - Swap Accumulator Nibbles XCH - Exchange Bytes XCHD - Exchange Digits XRL - Bitwise Exclusive OR
8
8051?43???????
  • ????(7?)
  • MOV?MOVC?MOVX?PUSH?POP?XCH?XCHD
  • ????(8?)
  • ADD?ADDC?SUBB?MUL?DIV?INC?DEC?DA
  • ??/????(12?)
  • ANL?ORL?XRL?XORL?CLR?CPL?SWAP?RL?RLC?RR?RRC?SETB?
    (??MOV)
  • ????(16?)
  • ACALL?LCALL?AJMP?LJMP?SJMP?RET?RETI?JMP?JC?JNC?JB?
    JNB?JZ?JNZ?CJNE?DJNZ

9
8051????
  • 43?????6????? ? 111???
  • ??????28?
  • ??????24?
  • ??????25?
  • ????????17?
  • ??????17?

10
????(Addressing Mode)
  • ?????(Immediate Addressing)
  • ??????(Register Addressing)
  • ?????(Direct Addressing)
  • ?????(Indirect Addressing)
  • ?????(Indexed Addressing)
  • ?????(Bit Addressing)

11
????????????
12
?Keil?????ROM/RAM
13
?????
??????????????????????,????????????????8???????
?? (1) 10??0255 (2) 16??00HFFH????H, (3)
2????00000000B11111111B????B
14
??????
8051???RAM??????????8????,??R0-R7,???????R0-R7????
?????????
15
?????
  • ???????????????????????A,????A??????????????
  • ???????????(???00H7FH),????????-SFR(???80HFFH)

16
?????
  • ?????????Ri (R0?R1) ,?DPTR,?????????????????
  • ???????????_at_ ?R0, R0?8??????,??? 256 ??????
    (??00H-FFH). DPTR??? 64K?????(??0000H-FFFFH).

17
?????
  • ???????,????????,??????????????
  • ???????? DPTR (???????)? PC (?????),????????????
    A
  • 8051????????ROM ,???????????

18
?????
  • ??SETB??????(bit)?1
  • ??CLR??????(bit)?0
  • 8051???????????
  • ??????????C
  • RAM???????(20H2FH,?128 bit),
  • P0?P1?P2?P3,TCON,TMOD???????

19
??Keil??????
  • ?Keil µVision?????????,??debug??
  • ??????,????(Regs), Memory Window???,?????????????

20
?????
  • ?????????????????(FILO) ???
  • SP????(Stack Pointer)???,?????????????
  • ?????????????,
  • ??PUSH?POP??,?????????
  • ????????,?????????,??????????
  • 8051???????(Reset),????SP07H????SP??50H7FH??,???
    ???????????

21
?????????
  • ?????????,?PUSH 30H, ??????
  • SP-gtSP1,?????1?
  • ?????30H??????,???SP?????
  • ?????????,?POP 31H,??????
  • SP????????, ??31H????
  • SP-gtSP-1,?????1?

22
?????????
23
(No Transcript)
24
8051????
  • 1.????(direct addressing)
  • ADD A, 7FH
  • 2.????(indirect addressing)
  • MOV A, _at_R0
  • 3.?????
  • ADD A, R7 ? ADD A,07H
  • 4.??????(immediate constants)
  • MOV A, 127

25
???(1)
  • ???ACC,??A
  • ???????DPTR,????????(DPH)????????(DPL)???,???????
    ,????16??????,????????????,???2????8????,?????????
    ?(??????????)

26
???(2)
  • ?0?3 (?P0?P1?P2?P3)8051?????????????
  • ???????SBUF,??????????,????????????
  • MOV SBUF,A (????????)
  • MOV A,SBUF (????????)

27
??????(1)
  • ??? Rn ?? R0?R1??R7?????
  • Add A ,Rn ????????
  • Add A,direct ??????????
  • Add A,_at_Ri ??????????
  • Add A,data ????????
  • Addc A,Rn ?? A A Rn C(????)
  • Addc A,direct
  • Addc A,_at_Ri
  • Addc A,data

28
??????(2)
  • Subb A,Rn ???-???-c
  • Subb A,direct ???-???-c
  • Subb A,_at_Ri ???-???-c
  • Subb A,data ???-???-c
  • INC (DEC) A ???(-)1
  • INC (DEC) Rn ???(-)1
  • INC (DEC) direct ?????(-)1
  • INC (DEC) _at_Rn ?????(-)1

29
??????(3)
  • Mul A ,B AB
  • Div A,B A/B

30
??????(1)
  • ANL A ,Rn ???AND????
  • ANL A,direct ?????AND????
  • ANL A,_at_Ri ?????AND????
  • ANL A,data ???AND????
  • ORL A ,Rn ???AND????
  • ORL A,direct ?????OR????
  • ORL A,_at_Ri ?????OR????
  • ORL A,data ???OR????

31
??????(2)
  • XRL A ,Rn ???XOR????
  • XRL A,direct ?????XOR????
  • XRL A,_at_Ri ?????XOR????
  • XRL A,data ???XOR????
  • CLR A ?????
  • RL A ???????
  • RLC A ????c??????
  • RR A ???????
  • RRC A ????c??????
  • CPL A ?A?1????A

32
??????(1)
  • MOV A,Rn ??????????
  • MOV A,direct ????????????
  • MOV A,_at_Ri ????????????
  • MOV A,data ????????
  • MOV Rn,A
  • MOV direct,A
  • MOV _at_Ri,A

33
??????(2)
  • MOVX A,_at_Ri A? ??RAM???(8bit??)
  • MOVX A,_at_DPTR A? ??RAM???(16bit??)
  • MOVX _at_Ri, A ??RAM?(8bit)?? ? A
  • MOVX _at_DPTR, A ??RAM?(16bit)?? ? A
  • MOVC A,_at_ADPTR A??????(ROM)???
  • PUSH direct ??????????RAM
  • POP direct ?RAM??????????
  • XCH A,direct ??????????????
  • XCH A,Rn ????????????

34
????(Jump)??(1)
  • ACALL address - ???????
  • RET - ??????
  • AJMP address - ??????
  • JMP _at_ADPTR - ???????
  • NOP - ???(????)

35
??????(2)
  • CJNE -CCompare??,JJump??-NENot
    Equal???-???????,??? rel
  • CJNE A, direct, rel
  • CJNE A, data, rel
  • CJNE Rn, data, rel
  • CJNE _at_Rn, data, rel
  • DJNZ Rn, rel - Rn?1,????0??rel
  • DJNZ direct, rel - direct?1,????0??rel

36
??????
  • JB bit, rel - ?????bit1 ???rel
  • JNB bit, rel - ?????bit0 ???rel
  • JC rel - ?????C1 ???rel
  • JNC rel - ?????C0 ???rel
  • JZ rel - ?????1 ???
  • JNZ rel - ?????0 ???
  • JBC bit, rel - ?bit1 ???rel, ???bit0
  • ???JC?JNC??C??Carry(??) ,?JBC??C??Clear(???0)

37
??????
  • SETB bit - ?????bit1
  • SETB C - ?????C1
  • CLR bit - ?????bit0
  • CLR C -?????C0
  • CPL bit - ?????bit NOT bit
  • CPL C -?????C NOT C
  • ORL?ANL?MOV ????????bit?C
Write a Comment
User Comments (0)
About PowerShow.com