# 复 习 一. 计算机中的数和编码 1. 2,10,16进制数及其之间的转换(整数) 按权展开,除x取余 2

## Presentation on theme: "复 习 一. 计算机中的数和编码 1. 2,10,16进制数及其之间的转换(整数) 按权展开,除x取余 2"— Presentation transcript:

3. MCS-51指令系统 A. 寻址方式 (相对寻址中:转移地址=PC当+位移量) B. 专用寄存器 PC,A,SP,DPTR,PSW C
3. MCS-51指令系统 A. 寻址方式 (相对寻址中:转移地址=PC当+位移量) B. 专用寄存器 PC,A,SP,DPTR,PSW C. 指令 (a) 传送: MOV A, Rn MOV Rn, A (direct,#data) MOV direct, A MOV @Ri, A (direct,#data) PUSH direct POP direct MOVX A, @DPTR MOVX @DPTR A MOVC A, @A+PC

XCH A, Rn( direct ) XCHD A, @Ri MOV DPTR, #data16 (b) 算术运算 ADD A, Rn ADDC A, Rn SUBB A, Rn INC A ( Rn, INC DPTR DEC A (Rn, DAA MUL A, B DIV A, B

(C) 逻辑运算 CLR A CPL A RL A RR A RLC A RRC A SWAP A ANL A, Rn ANL direct, A (#data) ORL A, Rn ORL direct, A (#data) XRL A, Rn XRL direct, A (#data)

(d) 位操作 MOV C, bit MOV bit, C CLR C CLR bit CPL C CPL bit SETB C SETB bit ANL C, bit ANL C, /bit ORL C, bit ORL C, /bit

(e) 控制转移 LJMP addr16 AJMP addr11 SJMP rel JMP @A+DPTR JZ rel. JNZ rel
(e) 控制转移 LJMP addr AJMP addr SJMP rel JMP @A+DPTR JZ rel JNZ rel JC rel JNC rel JB bit, rel JNB bit, rel JBC bit, rel

DJNZ Rn, rel DJNZ direct, rel CJNE A, direct, rel CJNE A, #data, rel CJNE Rn, #data, rel CJNE @Ri, #data, rel ACALL addr11 LACLL addr RET RETI NOP D.程序设计举例(看笔记,书)

B. 程序 MAIN: MOV SP, #67H LP2: CLR A MOV TMOD, #01H MOV DPTR, #7F00H MOV TH0, #3CH MOVX @DPTR, A MOV TL0, #B0H LP3: MOV R7, #20H MOV IE, #88H LP4: DJNZ R7, LP MOV R2, #00H SJMP LP SETB R I -T0: MOV TH0, #3CH LP0: CJNE R2, #05H, LP MOV TL0, #B0H LP1: JNC LP INC R MOV A, #66H CJNE R2, #14H, LP MOV DPTR, #7F00H LP5: JC LP MOVX @DPTR, A MOV R2, #00H SJMP LP LP6: RETI

2. 8255A,B口接有2个数码管,C口接有8个开关.试编一程 序,用A,B口显示C口开关闭合值(即Ci口开关闭合,显示 Ci),设8个开关只有一个闭合. A. 电路

B. 程序 ST: MOV DPTR, #BF03H ADD A, #0BH MOV A, #89H MOVC A, @A+PC MOVX DPTR, A MOV DPTR, #BF01H LP0: MOV DPTR, BF02H MOVX @DPTR, A MOVX A, @DPTR DEC DPL MOV R3, #00H MOV A, #C6H MOV R7, #08H MOVX @DPTR, A LP1: JNB ACC.0, LP SJMP LP INC R TAB: DB C0H, F9H,… RR A DJNZ R7, LP MOV R3, #0EH LP2: MOV A, R3

3. 试编一8通道采样程序,当某通道采样值>=E0H时,通 过 P1口的相应位发出报警信号.(即灯亮) A. 电路

B. 程序 ST: MOV R7, 08H MOV R2, #01H MOV R3, #FEH MOV R4, #00H LP0: MOV DPTR, #7FF8H MOVX @DPTR, A MOV R5, #1EH LP1: DJNZ R5, LP MOVX A, @DPTR CJNE A, #E0H, LP LP2: JNC LP MOV A, R4

ANL A, R3 MOV A,R4. MOV R4, A. MOV P1, A SJMP LP4. MOV R7, #F0H
ANL A, R MOV A,R MOV R4, A MOV P1, A SJMP LP4 MOV R7, #F0H LP3: MOV A, R4 LP5: DJNZ R7, LP ORL A, R SJMP ST MOV R4, A LP4: MOV A, R RL A MOV R2, A MOV A, R RL A MOV R3, A INC DPTR DJNZ R7, LP0

Download ppt "复 习 一. 计算机中的数和编码 1. 2,10,16进制数及其之间的转换(整数) 按权展开,除x取余 2"

Similar presentations