1、
CLR C ;(CY)=0
SUBB A,R0 ;(A)=(A0)-(RO)-(CY),则(A)=B5H
MOV 20H,A ;A送给20H单元,则(20H)=B5H
即:(A)=B5H (CY )=0 (20H)=B5H (R0)=4AH
程序功能:实现将A减去R0的差送给20H单元。
2、
MOV A, 20H ;20H单元送给A,则(A)=(20H)=5EH
CPL A ;A(=5EH)取反后送回A,则(A)=A1H
ADD A, #01H ;(A)=(A)+1=A2H
MOV 20H, A ;(20H)=(A)=A2H
MOV A, 21H ;(A)=(21H)=B3H
CPL A ;(A)=4CH
ADDC A, #00H ;(A)=(A)+0+CY=4CH (CY=0)
MOV 21H,A ;(21H)=(A)=4CH
SJMP $ ;原地等待
即:(A)=4CH (20H)=A2H (21H)=4CH
程序功能:将20H单元的数取反后加1(求补),再回送20H单元;将21H单元的数取反后加进位位,再回送21H单元。
3、
ORG 1000H
SUB1: MOV A,40H ;(A)=(40H)=03H
MOV DPTR, #TAB ;TAB表格首地址送DPTR,则(DPTR)=2000H
MOVC A,@A+DPTR ;(A)=(A+DPTR)=(03H+2000H)=(2003H)=33H
MOV 40H,A ;(40H)=(A)=33H
RET ;子程序返回
ORG 2000H
TAB: DB 30H,31H,32H,33H,34H
DB 35H,36H,37H,38H,39H
即::(A)=33H (40H)=33H (DPTR)=2000H
程序功能:查找以A为地址偏移量的数据表格内容。