SPKEQUP3.7; 蜂鳴器所在端口COUNT50EQU39H
SECEQUR0
MINEQUR1
SEGEQUP2
NUMEQUP0
SEG7EQU30H
SEG6EQU31H
SEG5EQU32H
SEG4EQU33H
SEG3EQU36H
SEG1EQU 3AH
DLAYEQU34H
H_CNT1EQU37H
H_CNT2EQU38H
FLAGBIT 00H
KEYVALEQU40H
XUN1EQU41H
XUN2EQU42H
MUSICEQU43H
ORG0000H
LJMPMAIN
ORG0003H
LJMP PLY_PAU
ORG0013H
LJMP STOP
ORG000BH;定時(shí)0中斷服務(wù)程序
LJMP COUNT
;------------------------------------------------------
ORG100H
MAIN:MOVSP,#60H;初始化堆棧
MOVSEC,#0H;初始化秒
MOVMIN,#0H;初始化分
MOVCOUNT50,#50;一秒定時(shí)
CLRFLAG
MOVIE,#8FH
MOVTMOD,#11H
MOVTH0,#0A5H
MOVTL0,#0FFH
MOVTH1,#0EDH
MOVTL1,#0FFH
SETBIT0
SETBIT1
MOVKEYVAL,#00H
MOVMUSIC,#01H
MOVDPTR,#TABLE1
MOV37H,#0FFH
MOV38H,#05H
;**************歡迎界面**********************
HELLO:MOV30H,#7FH
MOV31H,#0BFH
MOV32H,#0DFH
MOV33H,#0EFH
MOV36H,#0F7H
MOV 3AH,#0FDH
MOVP2,SEG3;H
MOVP0,#89H
LCALL LDELAY
MOVP2,SEG4;E
MOVP0,#86H
LCALL LDELAY
MOVP2,SEG5;L
MOVP0,#0C7H
LCALL LDELAY
MOVP2,SEG6;L
MOVP0,#0C7H
LCALL LDELAY
MOVP2,SEG7;O
MOVP0,#0C0H
LCALL LDELAY
MOVA,KEYVAL
JNZKEYJDG
DJNZ H_CNT1, HELLO
DJNZ H_CNT2,HELLO
;==========================================================
SETBTR0
LJMP SING
KEYGET:LCALL KEY
MOVA,KEYVAL
JZKEYGET
KEYJDG:CJNE A,#12H,SECON
FIRST1:MOVDPTR,#TABLE1
MOVMUSIC,#01H
MOVKEYVAL,#00H
;SETBFLAG
MOVSEC,#00H
MOVMIN,#00H
MOVCOUNT50,#50
SETBTR0
LJMP SING
SECON:CJNE A,#11H,THIR
SECON1:MOVDPTR,#TABLE2
MOVMUSIC,#02H
MOVKEYVAL,#00H
;SETBFLAG
MOVSEC,#00H
MOVMIN,#00H
MOVCOUNT50,#50
SETBTR0
LJMP SING
THIR:CJNE A,#0FH,FORTH
THIR1:MOVDPTR,#TABLE3
MOVMUSIC,#03H
MOVKEYVAL,#00H
;SETBFLAG
MOVSEC,#00H
MOVMIN,#00H
MOVCOUNT50,#50
SETBTR0
LJMP SING
FORTH:CJNE A,#0BH,UP
FORTH1:MOVDPTR,#TABLE4
MOVMUSIC,#04H
MOVKEYVAL,#00H
;SETBFLAG
MOVSEC,#00H
MOVMIN,#00H
MOVCOUNT50,#50
SETBTR0
LJMP SING
UP:CJNE A,#02H,DOWN
MOVKEYVAL,#00H
MOVR5,MUSIC
CJNE R5,#00H,N1
LJMP KEYGET
N1:CJNE R5,#01H,N2
LJMP FORTH1
N2:CJNE R5,#02H,N3
LJMP FIRST1
N3:CJNE R5,#03H,N4
LJMP SECON1
N4:LJMP THIR1
DOWN:; LCALL VLDELAY
MOVR5,MUSIC
MOVKEYVAL,#00H
CJNE R5,#00H,M1
LJMP KEYGET
M1:CJNE R5,#01H,M2
LJMP SECON1
M2:CJNE R5,#02H,M3
LJMP THIR1
M3:CJNE R5,#03H,M4
LJMP FORTH1
M4:LJMP FIRST1
;-----------------------------------------------------------
KEY: PUSH ACC
MOVP1,#0F0H;置列線為0,行線為1 ;^^^^^^^^^^^^
MOVA,P1
ANLA,#0F0H
MOVB,A
MOVP1,#0FH;置列線為1,行線為0
MOVA,P1
ANLA,#0FH
ORLA,B
CJNE A,#0FFH,UUU
AJMP QICH
UUU:CLRC
SUBB A,#0DCH
JNCHAHA
QICH:CLRA
HAHA:MOVKEYVAL,A
POP ACC
RET
;-------------------------------------------------------------
;-------------------------------------------------------------
;**************定時(shí)中斷服務(wù)程序***********************
COUNT:MOVTH0,#0A5H
MOVTL0,#0FFH
LCALL KEY
JNBFLAG,RETURN
DJNZ COUNT50,RETURN ;是否到一秒
;*****一秒處理****************
MOVCOUNT50,#50
INCSEC
CJNE SEC,#60,RETURN
MOVSEC,#0H
INCMIN
CJNE MIN,#100,RETURN ;一百分鐘以后自動(dòng)清零
MOVMIN,#00H
RETURN: LCALL DISPLAY
RETI
;**************************************************
;**************顯示子程序*******************
DISPLAY:PUSHACC
PUSHB
PUSH DPH
PUSH DPL
MOVA,MIN
MOVB,#0AH
DIVAB
MOVSEG,SEG4
LCALL TODIS
LCALL DELAY
MOVSEG,SEG5
MOVA,B
MOVDPTR,#TABLE
MOVC A,@A+DPTR
ANL A,#7FH
MOVNUM,A
LCALL DELAY
MOVA,SEC
MOVB,#10
DIVAB
MOVSEG,SEG6
LCALL TODIS
LCALL DELAY
MOVSEG,SEG7
MOVA,B
LCALL TODIS
LCALL DELAY
MOVA,MUSIC
MOVSEG,SEG1
LCALL TODIS
POP DPL
POP DPH
POPB
POPACC
RET
評論