0000H FFFFH 0000H FFFFH 00H FFH 7i  u êù? u ? ? u SFR 20H 30H 80H E0H A MSC51i%  ¥? ROM = RAM ? RAM ? 3c MCS51· 7"d · 7¥ì T LOOP: MOV A, R0 ;| R0¥ = ? ? A [S| ] ?T ? ?B?T ? ?=?T ? [? d ]  "¥?T ?  ÷?T ? ?? ?¥ = ?? ^A?¥ 3.2 ? . { ?· 7 1. [ ?F  A1 "¥?T ?¥· 7 MOV A,  data  Aodata MOV A, R n  n=0~7Ao(R n ) MOV A, @R i  i=0,1 Ao((R i )) MOV A, direct  Ao(direct) direct1 =? RAM SFR1? ? MOV A, @R i [ R i ¥ = ?11? ü?1??¥ = ? ?? A? ?b Ao((R i )) MOV A, R0 | R0¥ = ? ?? A ?bAo(R 0 ) MOV A, #20H ; (A) = 20H A¥ = ?1 20H MOV A, 20H ; (A) = (20H) A¥ = ?1 20H?¥ = ? ?i[  F· 7¥?]? è .07"!3  " ← 3 ?H· 7V UV3  ?s?÷?T ? ??í¥1?ü?1??¥ = ?. ?ó" ib1?¥7i ?1 W?7i   40H A 34H 40H R0 34H … … 40H !· 73? - 3 )  ) ) 3?· 7a "  2. [ R n 1 "¥?T ?¥· 7 MOV R n  A  R n o(A)  n=0~7 MOV R n  direct  R n o(direct) MOV R n  data  R n odata 3.[°¤1?1 "¥?T ?¥· 7 MOV direct, A  directo (A) MOV direct, R n  directo (R n )  n=0~7 MOV direct, @R i  directo (( Ri))  i=0,1 MOV direct, direct  directo (direct) MOV direct, #data  directodata 4. [7i W¤1?1 "¥?T ?· 7 MOV @R i  A  ((R i ))o(A) i=0,1 MOV @R i  direct  ((R i ))o(direct) MOV @R i  data  ((R i ))odata ?¨  è 1 MOV P1, #0FEH ; 11111110B V[ P P1.0 ¥?;=5? MOV P1, #0F0H ; 11110000B V[ P P1 g ¥  ? 4??;= 5? P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 5v 8 ? ?5A U P1.0 a P1.1 b P1.2 c P1.3 d P1.4 e P1.5 f P1.6 g P1.7 dp 5v MOV P1, #00H ; A U 8. MOV P1, #0F8H ; A U 7 MOV P1, #88H ; A U A ?¨  è 2 B???¥ú?è ü V[YV “;èò?  ” e?? è V7[ “ Dè ” e? “ <è ”b 3.1 ù?Z T · 7¥ì T LOOP: MOV A, R0 ;| R0¥ = ? ? A [S| ] ?T ? ?B?T ? ?=?T ? [? d ]  "¥?T ?  ÷?T ? ù?Z Tùs  ???T ? ??í1?¥Z Tb ù?Z T9 ?ù? ? ? <?· 7"d9ˉb a ü[/) ?¥ù?Z T? ^?÷?T ?¥b? L=  " ¥?T ?9μù?ù5b 3.1.1 7i ù? MOV A, Rn ?T ?7i ? ? R0~R7AaBaCy êa DPTR 3.1.2 °¤ù? MOV A, 40H ?T ?°¤[?í1?? Tó 9 V[7i  ?? Tó? A B DPTR "? ? MOV A, P0  MOV R0, TH0 3.1.3 7i W¤ù? MOV A, @R1 ?T ? ^YV7i W¤¤?¥ b 3.1.4 ?'ù? MOV A, #40H ?T ?· 7?°¤ób 3.1.5 ?7i FM?7i ù? [ DPTR PC1?7i [ A1M?7i  [ ?MF??¥ 16ê1?1?T ?¥1?b MOVC A, @A+DPTR MOVC A, @A+PC 5. 16ê ? . {· 7 MOV DPTR, #data16 DPTRodata16 DPTR---- ? ·?1 SFR? DPHaDPL MOV DPTR, #2010H M?? MOV DPH, #20H MOV DPL, #10H 6. \?T· 7 é\· 7 PUSH direct ? : (SP)=60H, (A)=30H ,(B)=70H H3? PUSH Acc  (SP)+1=61H1SP, (A) 1 61H PUSH B  (SP)+1=62H1SP, (B) 1 62H 2T : (61H)=30H, (62H)=70H, (SP)=62H (SP+3) (SP+2) (SP) (SP+1) |\· 7 POP direct ? : (SP)=62H, (62H)=70H ,(61H)=30H H3? POP DPH  ((SP)) 1DPH, (SP)1=61H1SP POP DPHL  ((SP)) 1DPL, (SP)1=60H1SP 2T : (DPTR)=7030H, (SP)=60H \¥i%e55éa 7. ?F  AD?? ? . {· 7 MOVX A, @DPTR  Ao((DPTR)) 1?S? 64K MOVX A, @R i  Ao((Ri)) 1?S? 0j255 MOVX @DPTR, A  ((DPTR)) o(A) MOVX @R i , A  ((Ri)) o(A) 8. °V· 7  1 MOVC A, @A+DPTR A o((A)+(DPTR)) è : (DPTR)=0300H,  A" 02H ROM? (0302H)=55H 3? MOVC A, @A+DPTR 2T (A)=55H  2 MOVC A, @A+PC A o((A)+(pc)) PC??·?·_/BH· 7¥1? è? A?¥ = ? 0j9° üZV MOVC A, @A+PC è0 ? 1?   ? ÷?? ORG 0000H 0000 7403 MOV A, #03H 0002 83 MOVC A, @A+PC 0003 00 DB 00H 0004 01 DB 01H 0005 04 DB 04H 0006 09 DB 09H 0007 10 DB 10H 0008 19 DB 19H 0009 24 DB 24H 000A 31 DB 31H 000B 40 DB 40H 000C 51 DB 51H  ¨L?3 ??°  ? END 9. 3??D· 7 XCH A , R n  (A) o1(Ri) XCH A , direct  (A) o1(direct) XCH A , @R i  (A) o1(Ri) è (A)=80H, (R7)=97H 3? XCH A , R 7 2T (A)=97H, (R7)=80H è| ? =3".)?íD)?í¥ ? ?Db 9$)))o ?$ 5 / · 7 ^?p ?p h?? 1MOV A#1000H  Ao1000H 2MOVX A1000H Ao(1000H) ?? RAM 3MOVC A1000H Ao(1000H) ?? ROM 4MOVX 60HA  ?? RAM(60H)oA 5MOV R060H  ? = RAM (61H)o(60H MOV 61H@R0 6. XCH R1R2  R1o1R2 7. MOVX DPTR#2000H  DPTRo2000H 8. MOVX 60H@DPTR  ? = RAMo ?? RAM 10.?3??D· 7 XCHD A, @R i  (A)0-3 o1((Ri )) 0-3 è (R 0 )=60H, (60H)=3EH, (A)=59H 3? XCHD A, @R 0 2T A"5E H  60H" 39 H 3.2.2 ? ??T ?· 7 1. FE· 7 Addtion 2. {éêFE· 7 3. F 1· 7  Increase 4. Eé???· 7 5. {1êhE· 7 Subtraction 6. h 1· 7 Decrease 7. eE· 7 Multiplication 8. "E· 7 Division 1. FE· 7 Addtion ADD A, R n  Ao (A) + (R n ) ADD A, @R i  Ao (A) + ((R i )) ADD A, direct  Ao (A)+(direct) ADD A,  data  Ao (A)+#data S?ê¥?Y C y ------ éêê AC ------ ?éêê OV ------ nê PSW7i  $Z "$ ' 343407i 1 $ZéêS?ê "$£ùéêS?ê ' ¨? P¨¥S?ê 07nS?ê 1  }S?ê "? ? ¥  }?b?¥? ?1  ?1?51b 3434  u 1?)j)  u 1?)j')  u 1?)j)  u 1?)j') 2. {éêFE· 7 ADDC A, R n  Ao(A)+(R n )+(C y ) ADDC A, @R i  Ao(A)+((R i )) +(C y ) ADDC A, direct  Ao (A)+(direct) +(C y ) ADDC A,  data  Ao (A)+#data +(C y ) S?ê¥?YD ADDM] 3. F 1· 7 INC A  Ao(A)+1 INC R i  Rio (A)+1 INC direct  directo (direct)+1 INC @R i  (Ri)o((Ri))+1 INC DPTR  DPTRo(DPTR)+1 S?ê?á 3?Y ?  A" 0FFH , (C y )=0 3? INC A 2T A" 00H , (C y )=0 4. Eé???· 7 DA A ¨o?? BCD ?FE· 7 ? ?hE-aé ? Eé???b  96H 1a ê BCD ?V U Eê1 9, ?ê1 6,  ?  BCD ?F MOV A, #35H ADD A, #46H (A)=7BH, i? ^ 81H ? DA A a  A" 81H 5. {1êhE· 7 Subtraction SUBB A, R n  Ao (A)-(R n )-(C y ) SUBB A, @R i  Ao (A)-((R i )) -(C y ) SUBB A, direct  Ao (A)-(direct) -(C y ) SUBB A,  data  Ao (A)-#data -(C y ) S?ê¥?Y C y ------ éêê AC ------ ?éêê OV ------ nê 6. h 1· 7 Decrease DEC A  Ao(A)1 DEC R i  Rio (A)1 DEC direct  directo (direct)1 DEC @R i  (Ri)o((Ri))1 S?ê?á 3?Y ?  A" 00H , (C y )=0 3? DEC A 2T A" 0FFH , (C y )=0 í DEC DPTR · 7 7. eE· 7  Multiplication MUL AB  (A)?(B) ? 8ê1 A ú 8ê1 B AaB?? ^í?|? ? ?Tv? 255OV"1?5 OV"0 éêS?9 ^ b , C y "0 8. "E· 7 Division DIV AB  (A)?(B) 1A ? ?1 B AaB?? ^í?|? ? ?T" ? B1“0”OV"1?5 OV"0 éêS?9 ^ b , C y "0 3.2.3 ?  ?· 7 1. e? ? ?T· 7 CLR A  Ao “0” CPL A  Ao A SWAP A  A 0~3 A 4~7 è : (A)=3AH, CPL A, (A)=0C5H 0011 1010B 1 1100 0101B (A)=3AH, SWAP A, (A)=0A3H ? 2. ?ì· 7 P?ì· 7  Rotate Accumulator Left RL A è A" 6CH = 0110 1100B RL A (A)=1101 1000B=0D8H a 7 o a 0 C {éêP?ì· 7 Rotate Accumulator Left through Carry flag RLC A è A" 6CH = 0110 1100B (C) =1 RLC A (A)=1101 1001B=0D9H a 7 o a 0 C ·?ì· 7 Rotate Accumulator Right RR A è A" 6CH = 0110 1100B RR A (A)=0011 0110B=36H a 7 o a 0 C {éê·?ì· 7 Rotate A Right with C RRC A è A" 6CH = 0110 1100B (C) =1 RRC A (A)=1011 0110B=0B6H a 7 o a 0 C 2. ? D· 7 ANL A, R n ANL A, direct ANL A,  data ANL A, @R i ANL direct, A ANL direct,  data ? “D ”  “μ 0' 0 ? 111” 0000 0111 ? 1111 1101 0000 0101 B " 05H 3. ? · 7 ORL A, R n ORL A, direct ORL A,  data ORL A, @R i ORL direct, A ORL direct,  data ? “ ”  “μ 1' 1 ? 010” 0000 0110 ?0110 1101 0110 1111 B " 6FH 4. ? s· 7 XRL A, R n XRL A, direct XRL A,  data XRL A, @R i XRL direct, A XRL direct,  data  “s ”  “Ms1 1M]1 0” 0000 0110  0110 1101 0110 1011 B " 6BH ⊕ ⊕ è  A =01??????B?V U ? ?1 1 03?/ ?BF· 73? a A¥′ ?? ? XRL A#0C0H  | ?F  A¥ = ? D7aD6 |Q 0 1?????? ORL A#03H  | ?F  A¥ = ? D1aD0? 1 1 1 0 1 0 0 0 0 ANL A#0E7H  | ?F  A¥ = ? D4aD3 b0 1 0?????? 0 0 0 0 0 0 1 1 1 0 ????1 1 1 1 1 0 0 1 1 1 1 0 ?0 0 ?1 1 3 3?  ?· 7a A =10?00?11Bb 5 1 ??| ?F  A?¥ ? ú 4ê b 0?ê?M$ 5 2 ??|7i  R2?¥ ?  ?ê |Q } ?ê?M$ 3.2.4 e?M ?· 7 1. K· 7  K· 7 AJMP addr11 PCoaddr11KS? 2k éK· 7 LJMP addr16 PCoaddr16KS? 64k W¤K· 7 JMP @A+DPTR PCo A DPTR) MM· 7 SJMP rel PCo(PC)+2 PCo(PC)+rel rel  ?¥M êM 1ê? ? MS? -ja3? rel" "¥1?M· 71?M· 73? ? ? " "¥1? PC? -′ ? I? H V¨S|}9M "¥1? rel ?óIr??9 ?b SJMP NEXT   AJMP NEXT ,SJMP NEXT … NEXT … e1 ÷?· 7¥· 7 )&3& 4+.1)&3& è? 4+.1 1?   ? ÷ ?? ? d ORG 0000H  ? ???  S1? 0000 20 00 30 LJMP MAIN  K _??? ORG 0030H  ? ??  S1? 0030 C3 MAIN: CLR C  MAIN1? ?S| 0031 E6 LOOP: MOV A , @R0 0032 37 ADDC A, @R1 0033 08 INC R0 0034 DA FB DJNZ R1, LOOP  MM 0036 80 03 SJMP NEXT 0038 78 03 MOV R0, #03H 003A 18 NEXT: DEC R0 003B 80FE SJMP $  HERE: SJMP HERE END ; 2 ?S: ???S|D1?-W¥1" 2. HqM· 7 ? JZ rel   A" 0M ? JNZ rel   A? 0M 3. 1??M?M· 7 CJNE A#datarel (A)=#data?? Co0 (A)# #data Co0 (A)!#data Co1 +?oμ! H Co1 CJNE Adirectrel CJNE R n #datarel CJNE @R i #datarel 4. h 1 ?1 0 M· 7 DJNZ Rnrel  Rn o(Rn )1 (Rn ) ?0M (Rn ) "0?? DJNZ directrel è ü H0?? delay MOV R7, #03H delay0 MOV R6, #19H delay1 DJNZ R6, delay1 DJNZ R7, delay0 RET 5. ?¨0??· 7  ?¨· 7 ACALL addr11 é?¨· 7 LCALL addr16 I? H V¨S|}9M "¥1? addr11addr16 ?óIr??9 ?b 6. 0??Rí· 7 RET RET· 7V\? i¥ PC1? LC0??Ríb 7. ?Rí· 7 RETI 8. b?T· 7 NOP 3.2.5 ê?T· 7 1. ? ê. ?· 7 MOV C, bit  bit V°¤ù?ê Co(bit) MOV bitC  C éêê (bit) o C è|ê1? 20H¥Bê ?. ??ê1? 30H? MOV C20H MOV 30HC 2. êM ??· 7 CLR C ; | C"0 CLR bit CPL C ; | C pQi ? C CPL bit ; | bit pQi ? bit SETB C ; | C"1 SETB bit  (bit) o 1 3. êM  ? · 7 ANL C, bit ANL C, bit ORL C, bit ORL C, bit 4. HqM ?· 7 JC rel  ? C=1, M JNC rel  ? C=0, M JB bitrel  ? bit=1, M JNB bitrel  ? bit=0, M JBC bitrel  ? bit=1, Mi bit"0