ORG 0000H
LJMP MAIN
ORG 0030H
MAIN: ORL p0,#0FH ;在读P0口时先对P0口写1
MOV A,p0
ANL A,#0FH
MOV DPTR,#LED7 ;根据从P0口读到的数据查表,TAB中存放数码管的显示码表
MOVC A,@A+DPTR
MOV p1,A ;把码表值送数码管显示
AJMP MAIN
;共阳数码管显示码表
LED7: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
DB 80H,90H,88H,83H,86H,0A1H,86H,8EH
你这是例题吧