8051 8051 1 immediate constants MOV A 127

• Slides: 47

8051 指令

8051定址模式 1. 立即常數定址（immediate constants） MOV A, #127 (A)=127 常數 127 A 2. 直接定址（direct addressing） MOV A, 7 FH Cpu內記憶體 7 FH (A)=(7 FH)=65 H A

8051定址模式 • 3. 間接定址（indirect addressing） (a) MOV A, @R 0; 搬移cpu內MEM (A)=((R 0)) (b) MOVX A, @DPTR; 搬移外部MEM (A)=((DPTR))=77 H DPTR R 0 45 H 1245 H Cpu內記憶體 45 H 77 H A 外部記憶體 1245 H 77 H A

8051定址模式 4. 暫存器定址 (register addressing) MOV A, R 7 (A)=(R 7)=7 AH R 7=7 AH A

8051定址模式 5. 索引定址 (index addressing) MOVC A, @A+PC; 搬移ROM資料 (A)=((A)+(PC)) A=23 H PC=1234 H 1257 H 66 H A ROM: (A)+(PC)=1257 H (A)=66 H

8051定址模式 5. 索引定址 (index addressing) MOVX A, @A+DPTR; 搬移外部RAM資料 A)+(PC (A)=((A)+(DPTR))=77 H A=23 H 1257 H 66 H DPTR=1234 H A 外部RAM: (A)+(DPTR)=1257 H (A)=66 H

8051指令

l Given (A)=10 INC A ; (A)=(A)+1=11 • Given (A)=20 DEC A ; (A)=(A)-1=19 l Given (R 1)=20 DEC R 1 ; ( R 1)=(R 1)-1=20 -1=19 l Given (A)=30, (R 2)=10, CY=0 SUBB A, R 2 ; (A)=(A)-(R 2)-(CY)=30 -10 -0=20

• Given (A)=10110010, (R 1)=11110000, (30 H)=22 H [1] ANL A, R 1 ; (A)=(A) and (R 1) (A): 10110010 (R 1): 11110000 ----------10110000 [2] ORL A, #11100000 B ; (A): 10110010 D 0 H: 11100000 -------------11110010=F 0 H

• AND A, 30 H 10110010 ----------0010=22 H • ORL A, @R 1 A or ((R 1))=A or (30 H) =A or 22 H=B 2 H 10110010 --------10110010=B 2 H

l Given (A)=10 H, (R 1)=33 H XRL A, #FFH ; (A)=EFH l XRL A, R 1 ; 00010000 0011 ---------00100011=23 H

RL A ; (A)=(A)*2 l A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 0 = A 6 A 5 A 4 A 3 A 2 A 1 A 0 0 l (A)=23 H=00100011 RL A=001000110=46 H

RR A; (A)=(A)/2 l 0 A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 =0 A 7 A 6 A 5 A 4 A 3 A 2 A 1 l (A)=23 H=00100011 RR A=00011=0001=11 H

RLC A; (A)=2*(A)+(CY) l CY A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 CY = A 6 A 5 A 4 A 3 A 2 A 1 A 0 CY * (CY)=A 7 l Given ( CY)=1, (A)=23 H=00100011 RLC A (CY) 00100011 (CY)=01000111=47 H, (CY)=0

RRC A l (CY) A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 (CY) (A) =CY A 7 A 6 A 5 A 4 A 3 A 2 A 1 l (CY) = A 0 l (CY) =1, (A)=23 H=00100011 RRC A (CY) 00100011 (CY) (A)=10010001=91 H (CY) =1

CALL---RET. . . CALL DRLAY MOV A, #56 H. . . DRLAY: MOV R 0, #56 H. . RET.