?? jxiao.asm
字號:
;=============================================
; 終端機程序
; 上次更新時間 2004.07.13
; ID卡 不需下載數據
; 浴室計時消費 江西贛州專用
; 出錯表:ERR 000 帳戶尚未關閉
; ERR 005 卡表空間已滿
; ERR 009 卡中余額為負,不允許消費
;==============================================
org 0000h
;----------------------------------
; 常量定義
;----------------------------------
null equ 35 ;全暗顯示的碼
sleep equ 2 ;
bpnum equ 10 ;
delay equ 15 ;
dslep equ 7 ;
dfcom equ 18 ;顯示'-'
nfcom equ 0a3h ;顯示'.'
;----------------------------------
kb_0 equ 0 ;以下是鍵值
kb_1 equ 1
kb_2 equ 2
kb_3 equ 3
kb_4 equ 4
kb_5 equ 5
kb_6 equ 6
kb_7 equ 7
kb_8 equ 8
kb_9 equ 9
kb_a equ 10
kb_b equ 11
kb_dot equ 12
kb_p equ 13
kb_m equ 14
kb_equ equ 15
kb_cl equ 16
kb_en equ 17
kb_f1 equ 18
kb_f2 equ 19
k_f10 equ 20 ;F1+A+0
k_f11 equ 21 ;F1+A+1
k_f12 equ 22 ;F1+A+2
k_f13 equ 23 ;F1+A+3
k_f14 equ 24 ;F1+A+4
k_f15 equ 25 ;F1+A+5
k_f16 equ 26 ;F1+A+6
k_f1d equ 27 ;F1+A+.
k_f1equ equ 28 ;F1+A+=
k_f1p equ 29 ;F1+Plus
k_f1m equ 30 ;F1+Minus
k_f2p equ 31 ;F2+Plus
k_f2m equ 32h ;F2+Minus
k_f1a equ 33 ;F1+A
;----------------
c_rmm equ 30h ;Read Main Memory Command
c_wmm equ 38h ;Write Main Memory Command
c_rpm equ 34h ;Read Protect Memory Command
c_wpm equ 3ch ;Write Protect Memory Command
c_rsm equ 31h ;Read Sc Memory Command
c_wsm equ 39h ;Write Sc Memory Command
c_cvd equ 33h ;Comp Verify Data Command
;----------------
normal equ 0
idle equ 1 ;0-idle 1-all
keyset equ 0 ;0-keyset0&&key_a 1-keyset1&&key_a 2-keyset2&&key a
;4-keyset0&&key_b 1-keyset1&&key_b 2-keyset2&&key b
secnr equ 0 ;Sector Number
rf_sor equ 80h
rf_rfs equ 40h
rf_nrf equ 02h
rf_ac equ 01h
rf_br equ 01h
rf_pre equ 40h
rf_cen equ 20h
rf_cre equ 10h
rf_ppp equ 06h
rf_al equ 80h
rf_rc equ 02h
c_ant equ 93h ;command of antioll
c_sel equ 93h ;command of select
c_hlt equ 50h ;command of halt
;----------------
f_dt0 equ 0a2h
f_dt1 equ 13h
f_dt2 equ 10h
f_dt3 equ 91h
;----------------
c_beg equ 0e0h ;Reading Card Main Memory Adress
c_r_n equ 32 ;Reading Card Main Memory Numbers
;----------------
err_0 equ 00h ;RF Load_Key Err
err_1 equ 01h ;KeyBoard Error
err_2 equ 02h ;IC Pedestal Error
err_3 equ 03h ;IC Card Bad
err_4 equ 04h ;Sc Verfity Error
;err_5 equ 05h ;RF Read Error
err_6 equ 06h ;Sc Count=0
err_7 equ 07h ;Read Error
err_8 equ 08h ;Illegal Pullout
err_9 equ 09h ;Add or Subb Over
err_10 equ 0ah ;Unregister
err_11 equ 0bh ;Dark Card
err_12 equ 0ch ;Manage Card None Push
err_13 equ 0dh ;Communication Error
err_14 equ 0eh ;Card Accounts Not Equ Receive Accounts
err_15 equ 0fh ;None Normal Card
err_16 equ 10h ;operate in same with same time
menufunc equ 31h ;Sale Menu FuncNum
ratfunc equ 11h ;Sale Ration FuncNum
countfunc equ 21h ;Sale Count FuncNum
norsale equ 01h ;Sale Normal FuncNum
norsave equ 02h ;Save Normal FuncNum
;-----------------------
; Bit Define
;-----------------------
icard_pow equ 90h ;Ic Card Power
icard_rst equ 91h ;Ic Card Reset
icard_clk equ 92h ;Ic Card Clock
icard_dat equ 93h ;Ic Card Data
;-----------------------
clock equ 94h ;Display Clock
store equ 95h ;Display Store
enabl equ 96h ;Display Enabl
ddata equ 97h ;Display Data
;-----------------------
icard_chk equ 0b2h ;Ic Card Check
mifs_rst equ 0b5h ;Rf Reset
;-----------------------
f_rsc equ 00h ;Requst Sc
f_ini equ 01h
f_rde equ 02h ;Requst quota
f_pow equ 03h ;Soft Switch
f_ri equ 04h ;ri Interrupt
f_com equ 05h ;Communication ?
f_cny equ 06h ;管理卡標志
f_rzh equ 07h ;更新終端機中的個信息
f_rsl equ 08h ;發送脫機消費信息
f_sal equ 09h ;要求發送消費信息
f_zh equ 0ah ;要求得到帳號
f_beg equ 0bh ;開始發送脫機消費信息
f_mnu equ 0ch ;食譜消費標志
f_udt equ 0dh ;update the data and time
f_a_s equ 0fh ;1:Sale,0:Deposit
f_n equ 10h ;Entered Key Flag
f_dot equ 11h ;Enter . Key Flag
f_add equ 12h ;Enter + Key Flag
f_sub equ 13h ;Enter - Key Flag
f_equ equ 14h ;Enter = Key Flag
f_m_p equ 15h ;1:miune 0:plus
f_p_m equ 16h ;Copy as f_m_p
f_tj equ 17h ;OffLine
f_rat equ 18h ;Qutoa Flag (Ration)
bit_c equ 19h ;Bit Flag
f_off equ 1ah ;Is Offline Flag
f_sta equ 1bh ;Test Comm Flag
f_typ equ 1eh ;Card Type: 1=IC; 0=RF
f_id equ 1fh
f_f equ 50h ;這是新添加的標志位
f_0 equ 51h ;此標志位是用來判斷按下的是clear 還是enable.
f_sign equ 52h ;信用額度符號
F01 EQU 52H ;
f_askt equ 53h ;請求更新終端機時間。
;========================
; Regeist Define
;========================
;th2 equ 0cdh
;tl2 equ 0cch
;rcap2h equ 0cbh
;rcap2l equ 0cah
;t2con equ 0c8h
shn equ 08h ;Row Regeist
v_key equ 09h ;Key Vaule
v0_key equ 0ah ;Copy of v_key
kdt0 equ 0bh ;Keyboard Scan Code 0
kdt1 equ 0ch ;Keyboard Scan Code 1
kdt2 equ 0dh ;Keyboard Scan Code 2
;
r_mod equ 0eh ;RI Inputerrupt Step
ricon equ 0fh ;RI Receive Data Counter
rir0 equ 10h ;RI Receive Data Address
chksum equ 11h ;RI CheckSum
;
r_nme equ 12h ;Terminal Name Regist
state equ 13h ;Terminal Work State
max_h equ 14h ;
max_l equ 15h
beg_h equ 16h
beg_l equ 17h
end_h equ 18h
end_l equ 19h
rat_0 equ 1ah ;Ration
rat_1 equ 1bh
rat_2 equ 1ch
adr_h equ 1dh ;Address
adr_l equ 1eh
count equ 1fh
;
r1_374 equ 24h ;r_en rf_chk b_chk re184 bp pow a16 a15
r_en equ 27h
rf_chk equ 26h
b_chk equ 25h ;Battery Check
re184 equ 24h ;re184=0:Receive,1:Transmit
bp equ 23h
pow equ 22h ;AC Power On
;
func equ 25h ;0=Fc.17,1=Fc.18,2=Fc.19,3=Fc.20,4=Fc.43
scancount equ 25h ;=func
regt equ 26h ;Temp Regeist
reg1 equ 27h ;Temp Regeist
reg0 equ 28h ;Temp Regeist
rcr0 equ 28h ;=reg0:Copy of R0
rftyp equ 29h
;
s_succ equ 2bh ;0-None Sale;1-Sale Sending;2-Sale Send Complete
;
repeat equ 2ch ;Re-Send Sale/Save Count
lim_cnt equ 2dh ;Limit Count
reclen equ 2dh ;=lim_cnt: Record Length
;
sata equ 2eh
r_err equ 2fh
;
r_sp equ 2fh
;------------------------
reg2 equ 58h ;Temp Regist
reg3 equ 59h ;Temp Regist
reg4 equ 5ah ;Temp Regist
rf0ram equ 50h
rf1ram equ 60h
rf2ram equ 70h
d_addramh equ 60h
d_addraml equ 61h
xorram equ 56h
divh equ 5eh
divl equ 5fh
divram equ 65h
rf3ram equ 68h ;=rf1ram+8
ka0ram equ 60h ;=rf1ram
ka1ram equ 64h ;=rf1ram+4
kb0ram equ 68h ;=rf1ram+8
kb1ram equ 6ch ;=rf1ram+12
;----------------------
icard_sc0 equ 51h ;Comp Sc_0
icard_sc1 equ 52h ;Comp Sc_1
icard_sc2 equ 53h ;Comp Sc_2
icard_sce equ 54h ;ScCompErrCounter
icard_com equ 55h ;IC Read/Write Command
icard_adr equ 56h ;IC Read/Write Address
icard_dta equ 57h ;IC Read/Write Data
icard_ram equ 58h ;
sw0 equ 0fah
HOUR EQU 0FBH ;
MINU EQU 0FCH ;
R_374CP EQU 0FDH ;
DPHCP EQU 0FEH ;
DPLCP EQU 0FFH ;
;----------------------
;----------------------
exp_rm0 equ 78h ;Expense
exp_rm1 equ 79h
exp_rm2 equ 7ah
exp_rm3 equ 7bh
exp_rm4 equ 7ch
exp_rm5 equ 7dh
sur_rm0 equ 7eh ;Surplus
sur_rm1 equ 7fh
sur_rm2 equ 80h
sur_rm3 equ 81h
sur_rm4 equ 82h
sur_rm5 equ 83h
augend0 equ 84h ;Augend
augend1 equ 85h
augend2 equ 86h
augend3 equ 87h
augend4 equ 88h
augend5 equ 89h
lim_rm0 equ 8ah ;Limit Expense
lim_rm1 equ 8bh
lim_rm2 equ 8ch
lim_rm3 equ 8dh
lim_rm4 equ 8eh
lim_rm5 equ 8fh
;
ddsp0 equ 90h ;Display
ddsp01 equ 91h
ddsp02 equ 92h
ddsp03 equ 93h
ddsp04 equ 94h
ddsp05 equ 95h
ddsp06 equ 96h
ddsp07 equ 97h
ddsp1 equ 98h
ddsp11 equ 99h
ddsp12 equ 9ah
ddsp13 equ 9bh
ddsp14 equ 9ch
ddsp15 equ 9dh
ddsp16 equ 9eh
ddsp17 equ 9fh
dflag equ 0b0h ;
d_nme equ 0b1h ;
d_ym equ 0b2h ;Date of Expense
d_dat equ 0b3h ;
d_hor equ 0b4h ;Time of Expense
d_min equ 0b5h
dadr_h equ 0b6h ;Record Number
dadr_l equ 0b7h
d_exp0 equ 0b8h ;Expense
d_exp1 equ 0b9h
d_exp2 equ 0bah
d_sur0 equ 0bbh ;Surplus
d_sur1 equ 0bch
d_sur2 equ 0bdh
madr_h equ 0beh ;Manage Card Record Number
madr_l equ 0bfh
;-----------------------
r_buf equ 0a0h ;0a0h-0bfh:32 Temp Buffer
;
ribuf equ 0c0h ;0c0h-0ffh:64 Receive && Send Buffer
;*********************************
; Address Define
;*********************************
rfdata EQU 8000H
STACO EQU 8001H
EEABL EQU 8002H
BCNTS EQU 8003H
BCNTR EQU 8004H
BAUDR EQU 8005H
TOC EQU 8006H
MODE EQU 8007H
CRCDA EQU 8008H
CRCST EQU 8009H
KEYDA EQU 800AH
KEYST EQU 800BH
KEYAD EQU 800CH
RCODE EQU 800EH
;
d1_374 equ 0a000h ;
d_887 equ 0c000h ;
d_245 equ 0e000h ;
;
rsec equ 0c000h ;DS12887 Second Address
rmin equ 0c002h ;DS12887 Minute Address
rhor equ 0c004h ;DS12887 hour Address
rwek equ 0c006h ;DS12887 Weekday Address
rdat equ 0c007h ;DS12887 Day Address
rmon equ 0c008h ;DS12887 Month Address
ryer equ 0c009h ;DS12887 Year Address
;---
r18a equ 0c00ah ;DS12887 Control A address
r18b equ 0c00bh ;DS12887 Control B address
r18c equ 0c00ch ;DS12887 Control C address
r18d equ 0c00dh ;DS12887 Control D address
;---
d_sc equ 0080h ;Sc && Id Address
d_l_e1 equ 0094h ;Offline Limit Expense Address
d_num1 equ 0098h ;Terminal Name Address
d_stat1 equ 0099h ;State Address
d_max1 equ 009ah ;Maxium Address
d_beg1 equ 009ch ;
d_end1 equ 009eh ;
d_rat1 equ 00a0h ;Ration Address
d_menu1 equ 00a4h ;Menu Address
d_rat equ 0c010h ;Ration Copy
d_menu equ 0c014h ;Menu Copy
d_id equ 0c034h ;User ID Copy
d_sc0 equ 0c03ch ;User Sc Copy
d_sc6 equ 0c042h ;Init Sc Copy
d_l_e equ 0c048h ;Offline Limit Expense Copy
d_num equ 0c04ch ;Terminal Name Copy
d_state equ 0c04dh ;State Copy
d_max equ 0c04eh ;Max Copy
d_beg equ 0c050h
d_end equ 0c052h
;
;
xyer equ 0c069h ;Year Data Update
xmon equ 0c06ah ;Month Update
xdat equ 0c06bh ;Day Update
xwek equ 0c06ch ;WeekDay Update
xhor equ 0c06dh ;Hour Update
xmin equ 0c06eh ;Minute Update
xsec equ 0c06fh ;Second Update
dctr equ 0c070h ;
dyer equ 0c071h ;Year Data
dmon equ 0c072h ;Month
ddat equ 0c073h ;Day
dwek equ 0c074h ;WeekDay
dhor equ 0c075h ;Hour
dmin equ 0c076h ;Minute
dsec equ 0c077h ;Second
sum0 equ 0c078h ;用來存放消費和的地址單元
sum1 equ 0c079h
sum2 equ 0c07ah
sum3 equ 0c07bh
sum4 equ 0c07ch
sum5 equ 0c07dh
sum6 equ 0c07eh
sum7 equ 0c07fh
;
d_card equ 0100h ;ID卡號存放首地址
d_ram equ 0600h ;Address of Person'Information Offset
d_sal equ 8000h ;18000h Address of Offline Sale Offset
;******************************
; Const Define
;******************************
dti_h equ 0f8h ;2.15ms
dti_l equ 0
dt1_h equ 10h ;66.66ms
dt1_l equ 0
p_recl equ 10 ;Person Record Length
mx_nh equ 26 ;2600h*10=95KB 9728條信息
mx_nl equ 0 ;Maxium Number Of Person Record
s_recl equ 16 ;Sale Record Length
mx_sh equ 8 ;800h*16=32Kb 2048條信息
mx_sl equ 0 ;Maxium Number Of Offline Sale Record
;****************************
ljmp main
;----------------
org 0003h ;int0
ljmp icard_move
;----------------
org 000bh ;T0
clr tr0
setb sm2
clr f_ri
sjmp m_t0
;----------------
org 0013h ;INT 1
ljmp timer
m_t0: mov r_mod,#0
reti
;-----------------
org 001bh ;T1
ljmp m_t1
;
;----------------------
; 串口中斷處理子程序
;---------------------
org 0023h
push acc
push 00h
push psw
push 03h
push 04h
push 05h
push 06h
;
setb enabl ;
;
jbc ri,r_rece ;receive or send
jbc ti,r_send
ajmp d_reti
;
r_send: mov a,ricon ; send
jnz r_sen1
push dph
push dpl
;
mov r0,#70
djnz r0,$
clr re184 ;
mov a,r1_374
mov dptr,#d1_374
movx @dptr,a
;
clr f_ri ; clear the receive flag
;
pop dpl
pop dph
ljmp d_reti
r_sen1: mov r0,rir0 ; address of the receive
mov a,@r0
mov sbuf,a
inc rir0
dec ricon ; the counter of receive
ljmp d_reti
r_rece: mov r0,sbuf
clr tr0
;
mov a,r_mod ; the mode of the receive
cjne a,#0,r_md10
mov a,r0 ; receive the name
cjne a,r_nme,r_md01;
r_md00: clr sm2 ;
setb f_ri ;將中斷標志位寫1
mov a,r0
mov r0,#ribuf; 收/發緩沖器
mov @r0,a ;place the receive date
inc r0 ;
mov rir0,r0
inc r_mod
sjmp r_md21
r_md01: cjne a,#0ffh,r_md02
sjmp r_md00
r_md02: ajmp d_reti
r_md10: cjne a,#1,r_md20
mov a,r0 ; receive fuction
mov r0,rir0
mov @r0,a ; save the fuction
;compair the fuction
cjne a,#17,r_md11 ;Write New Card
mov a,#54
sjmp r_md19
r_md11: cjne a,#18,r_md12 ;ReWrite Card
mov a,#54
sjmp r_md19
r_md12: cjne a,#70,r_md13 ;Get ZH
mov a,#52 ;old is 38
sjmp r_md19
r_md13: cjne a,#74,r_md16 ;Update Time
mov a,#38
sjmp r_md19
r_md16: cjne a,#66,r_md17 ;Get Security
mov a,#54
sjmp r_md19
r_md17: cjne a,#76,r_md18
mov a,#54
sjmp r_md19
r_md18: mov a,#14
r_md19: mov ricon,a
rr a
mov chksum,a
dec ricon
dec ricon
inc rir0
inc r_mod
sjmp r_md21
;
r_md20: mov a,r0
mov r0,rir0
mov @r0,a
inc rir0
djnz ricon,r_md21
mov r_mod,#0
setb sm2
ljmp rideal
r_md21: mov th0,#dti_h
mov tl0,#dti_l
setb tr0
;
d_reti: mov c,r_en
mov enabl,c
;
pop 06h
pop 05h
pop 04h
pop 03h
pop psw
pop 00h
pop acc
reti
;*********************************************
;*********************************************
main: mov sp,#r_sp
mov dptr,#d1_374 ;
mov a,#11001000b ;r_en rf_chk b_chk re184 bp pow a16 a15
mov r1_374,a
movx @dptr,a
lcall check_battery
;-----------------------
; Set Sreial Paramete
;-----------------------
mov th2,#0ffh ;115200 57600 38400 28800 19200 9600
mov tl2,#0fah ;ff:fd ff:fa ff:f7 ff:f4 ff:ee ff:dc
mov rcap2h,#0ffh
mov rcap2l,#0fah
mov t2con,#00110100b ;tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/rl2
;------
mov r_mod,#0
mov state,#0
;--------------------
; Initilize Flag
;--------------------
clr f_ri
clr f_zh
clr f_id
clr f_sal
clr f_rsl
clr f_cny
clr f_a_s
clr f_beg
clr f_com
setb f_pow
clr f_mnu
clr f_rat
setb f_rde
setb f_rsc
clr f_rzh
clr f_off
clr f_udt
clr f_sta
mov count,#0
;; setb mifs_rst
setb rf_chk
setb f_f
clr f_0
setb f_askt ;
mov func,#0ffh
mov s_succ,#0
;----------------
; Test Ram
;----------------
lcall v0_ram
jb f0,ram_s
lcall get_code ;Test RamErr
ram_e: lcall clrbp
;
mov r4,#30
lcall d0lay
lcall setbp
lcall d0lay
lcall check_battery
sjmp ram_e
ram_s: lcall inial
;
lcall get_pos_name
;--------------------------
; Test Keyboard && IC Card
;-------------------------
mov regt,#60
test_k: jb icard_chk,ic_err
lcall key_in
mov a,v_key
cjne a,#0ffh,kb_err ;Keyboard Err
lcall check_battery
djnz regt,test_k
sjmp edit_pos_name
;-------------------
; Ic Touch Error
;--------------------
ic_err: mov r_err,#err_2
sjmp err_dp
;-------------------
; Keyborad Error
;--------------------
kb_err: mov r_err,#err_1
err_dp: lcall error_code
lcall clrbp
mov r4,#30
lcall d0lay
lcall setbp
mov r4,#60
lcall d0lay
lcall check_battery
sjmp test_k
;-----------------------
; Edit PosName
;-----------------------
edit_pos_name:
mov regt,#1
mov a,end_h
cjne a,beg_h,ed_p0
mov a,end_l
cjne a,beg_l,ed_p0
dec regt
ed_p0:
lcall get_pos_name
ed_p1: lcall key_in
mov a,v_key
cjne a,#kb_cl,ed_p2
mov regt,#1
ed_p2: cjne a,#k_f12,ed_p8
lcall set_pn ;Edit PostName
mov regt,#1
ed_p8: lcall check_battery
djnz regt,ed_p1
lcall clrsum
;
mov scon,#11110000b ;sm0 sm1 sm2 ren tb8 rb8 ti ri
;------
mov tmod,#11h
mov tcon,#00000001b ;TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
;
mov th1,#dt1_h
mov tl1,#dt1_l
setb tr1
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -