想問一下這組 組合語言它是用哪種寫法
ERROR_COUNT EQU 20H
ERROR_TIME EQU 21H
ADDR EQU 37H
CNT EQU 38H
SEC EQU 39H
TIME_LO EQU 3AH
TIME_MI EQU 3BH
TIME_HI EQU 3CH
TIME_HI_1 EQU 3DH
TIMER_HI EQU 3EH
TIMER_MI EQU 3FH
TIMER_LO EQU 40H
TIME1 EQU 30H ;;INPUT FIRST
TIME2 EQU 31H
TIME3 EQU 32H
TIME4 EQU 33H
TIME5 EQU 34H
TIME6 EQU 35H
SHOW_TIMER EQU 41H
;;SET PASS
PASS1 EQU 42H ;;LOWEST
PASS2 EQU 43H
PASS3 EQU 44H
PASS4 EQU 45H ;;HIGHEST
;;INPUT PASS
IN_PASS1 EQU 46H ;;LOWEST
IN_PASS2 EQU 47H
IN_PASS3 EQU 48H
IN_PASS4 EQU 49H ;;HIGHEST
FLAG1 EQU 22H
;;FLAG1 BIT DEFINE
NUMBER_FG REG FLAG1.0
SHOW_TIME_FG REG FLAG1.1
CHECK_PASS_FG REG FLAG1.2
ERROR_COUNT_FG REG FLAG1.3
;;8051 PIN DEFINE
EN REG P2.7
RW REG P2.6
RS REG P2.5
RELAY REG P2.4
CS REG P2.3
SK REG P2.2
DI REG P2.1
DO REG P2.0
ORG 00H ;;重開機起始位址
JMP POWER_ON_START
ORG 0BH ;;計時中斷 0
JMP TIME_INT0
ORG 13H ;;外部中斷 1
JMP EXT_INT1_OUT2
TIME_INT0
PUSH A
DJNZ TIME_LO,TIME_INT0_OUT
MOV TIME_LO,#250
;;50 MS WILL GO HERE
;;WAIT 2 SEC
DJNZ SHOW_TIMER,SHOW_TIME_OUTX
CLR SHOW_TIME_FG
SHOW_TIME_OUTX
DJNZ TIME_MI,TIME_INT0_OUT
MOV TIME_MI,#20
;;1 SEC WILL GO HERE
INC TIMER_LO ;;秒 加 1
CLR C
MOV A,#59 ;;超過 59 秒 , 則清除為 0
SUBB A,TIMER_LO
JNC TIMER_OUT
MOV TIMER_LO,#00H
INC TIMER_MI ;;分 加 1
CLR C
MOV A,#59 ;;超過 59 分 , 則清除為 0
SUBB A,TIMER_MI
JNC TIMER_OUT
MOV TIMER_MI,#00H
INC TIMER_HI ;;時 加 1
CLR C
MOV A,#23 ;;超過 23 時 , 則清除為 0
SUBB A,TIMER_HI
JNC TIMER_OUT
MOV TIMER_HI,#00H
TIMER_OUT
DJNZ ERROR_TIME,NO_UP_11
CLR ERROR_COUNT_FG
MOV ERROR_COUNT,#00H
NO_UP_11
DJNZ TIME_HI,TIME_INT0_OUT
MOV TIME_HI,#60
;;1 MINUTE WILL GO HERE
DJNZ TIME_HI_1,TIME_INT0_OUT
MOV TIME_HI_1,#60
;;1 HOUR WILL GO HERE
;;SETB IE.2 ;;START EXT_INT1
TIME_INT0_OUT
POP A
RETI
EXT_INT1
PUSH A
PUSH B
POP B
POP A
EXT_INT1_OUT2
RETI
;****************
;* MAIN PROGRAM *
;****************
POWER_ON_START
MOV SP,#60H ;;堆疊指標 到 60H
CLR SK
CLR RELAY
;;開機 重設 LCD
MOV A,#38H
ACALL W_INS
MOV A,#38H
ACALL W_INS
MOV A,#38H
ACALL W_INS
MOV A,#38H
ACALL W_INS
MOV A,#08H ;FUNCTION SET
ACALL W_INS
MOV A,#01H ;CLEAR DISPLAY
ACALL W_INS
MOV A,#06H ;INPUT MODE SET
ACALL W_INS
MOV A,#0CH ;DISPLAY ON/OFF
ACALL W_INS
;;開機 重設 TIMER 中斷
MOV TCON,#00000100B
MOV TMOD,#00000010B
MOV IE,#10000010B
MOV TH0,#256-200 ;;200 US
MOV TL0,#256-200 ;;200 US
MOV TIME_HI_1,#60 ;;1 HOUR
MOV TIME_HI,#60 ;;1 MINUTE
MOV TIME_MI,#20 ;;1 SEC
MOV TIME_LO,#250 ;;50 MS
SETB TR0
MOV ERROR_COUNT,#00H
MOV ERROR_TIME,#60 ;;三此錯誤 須等 60 秒
MOV TIMER_HI,#00H ;;時鐘 設為 0 HOUR
MOV TIMER_MI,#00H ;;時鐘 設為 0 MINUTE
MOV TIMER_LO,#00H ;;時鐘 設為 0 SECOND
MOV FLAG1,#00H
MOV SHOW_TIMER,#40
MOV ADDR,#4
MOV R0,#42H
CALL READ
MOV R0,#42H
MOV A,@R0
CJNE A,#5AH,COLD_START
;;暖開機到此
JMP POWER_ON_START1
;;冷開機到此
COLD_START
MOV ADDR,#4
MOV R0,#42H
MOV A,#5AH
MOV @R0,A
CALL ERASE
CALL WEN
CALL WRITE
CALL WDS
;;密碼 預設為 0000
MOV PASS1,#00H
MOV PASS2,#00H
MOV PASS3,#00H
MOV PASS4,#00H
CALL W_CODE
POWER_ON_START1
;;LCD TABLE1 DB 'A.TIME B.SETTIME'
;;LCD TABLE2 DB 'C.INKEY D.SETKEY'
PUSH A
MOV A,#80H
ACALL W_INS
MOV CNT,#16
MOV DPTR,#TABLE1
ACALL W_STR
MOV A,#C0H
ACALL W_INS
MOV CNT,#16 ;;LCD 16 X 2 ==> 16 BYTE
MOV DPTR,#TABLE2
ACALL W_STR
POP A
CALL SCAN
MOV A,R5
CJNE A,#16,CHECK_SHOW_TIME
JMP POWER_ON_START1
CHECK_SHOW_TIME
CJNE A,#0AH,CHECK_SETTING_TIME
;;顯示時間
SHOW_TIME
CALL CLRLCD
MOV SHOW_TIMER,#40
SETB SHOW_TIME_FG
SHOW_TIME_1
;;SHOW_TIME_FG = 0 時 , 返回主程式
JNB SHOW_TIME_FG,POWER_ON_START1
;;LCD 第一行顯示 TIME
PUSH A
MOV A,#80H
ACALL W_INS
MOV CNT,#16
MOV DPTR,#TABLE3
ACALL W_STR
POP A
MOV A,#C4H
ACALL W_INS
MOV A,TIMER_HI ;;時
MOV B,#10
DIV AB ;;A 商 , B 餘
ADD A,#30H ;;CHANGE INTO ASCII
CALL W_DATA
MOV A,B
ADD A,#30H
CALL W_DATA
MOV A,#':'
CALL W_DATA
MOV A,TIMER_MI ;;分
MOV B,#10
DIV AB ;;A 商 , B 餘
ADD A,#30H
CALL W_DATA
MOV A,B
ADD A,#30H
CALL W_DATA
MOV A,#':'
CALL W_DATA
MOV A,TIMER_LO ;;秒
MOV B,#10
DIV AB ;;A 商 , B 餘
ADD A,#30H
CALL W_DATA
MOV A,B
ADD A,#30H
CALL W_DATA
J ..
訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容