單片機(jī)電子琴匯編程序
L EQU 31H
ORG 0000H
SJMP MAIN
ORG 0BH
SJMP INT_T0
ORG 0030H
SJMP MAIN
MAIN: MOV TMOD,#01H
SETB EA
SETB ET0
MOV TH0,#0F9H
MOV TL0,#21H
SETB TR0
MOV R2,#0
LOOP:MOV DPTR,#TAB
MOV A,R2
MOVC A,@A+DPTR
MOV H,A
MOV DPTR,#TAB2
MOV A,R2
MOVC A,@A+DPTR
MOV L,A
CALL DY
INC R2
CJNE R2,#7,LP
MOV R2,#0
LP: SJMP LOOP
DY: MOV R7,#10
D2: MOV R4,#187
D3: MOV R3,#248
DJNZ R3,$
DJNZ R4,D3
DJNZ R7,D2
RET
INT_T0: MOV TH0,H
MOV TL0,L
CPL P0.4
RETI
TAB: DB 0F9H,0F9H,0FAH,0FAH,0FBH,0FBH,0FCH
TAB2: DB 21H,0E1H,8CH,0D8H,68H,0E9H,5BH
END
評(píng)論