📄 main.mac
字号:
$nolist
;*******************************************************************************
;*******************************************************************************
;* *
;* (C)Copyright, CLOVER China Electronics Co.,LTD. *
;* All Rigits Reserved *
;* add:No.58-F Yang Dong Road, LuoFeng Demonstrative Zone Suzhou, China *
;* Tel: 0512-67261886 Fax:0512-67261882 *
;* http://www.clover.co.jp *
;* *
;*******************************************************************************
;*******************************************************************************
;
; OBS CPD3212T source program
; CPU: TOSHIBA TLC-870/C series TMP86CM74A
; RAM: 2Kbytes(0040h - 083Fh)
; ROM: 32Kbytes(a000h - FFFFh)
;
;
;Main program
?trigger(@)
@include "symdef_ram.inc"
@include "symdef_sub.inc"
@include "macro.inc"
@include "define.inc"
$list
public start,function_end,tenkey_end,no_operation,init_io,resume,shp_sgn_end
public sys_error,resume,function_end9,function_end_0,functionnoclearftenkey,ic_display
extern euro_country_set
extern key_get,init_keybuf,acc_total,enter_stop,ce_key ;check_slftst,init_rtc
extern tenkey,dp_key,gt_key,cec_key,acc_plus,acc_minus,acc_subtl
extern acc_total,sharp_subtl,equal_key,percent_key,perplus_key,multi_key,divide_key
extern markup_key,delta_percent,sign_change,back_space,sharp_date
extern mem_minus,mem_plus,mem_subtl,mem_total,mem2_minus,mem2_plus,mem2_subtl,mem2_total
extern cost_key,sell_key,margin_key
extern tax_plus,tax_minus,tax2_plus,tax2_minus
extern lcd_disable,lcd_enable,tax_save,tax_recall,all_clear,work_clear,work_clear_acc,kychk_clcsm;v3.00 rtc_key,
extern spc_disp,update_md,wk_prn_2L
extern euro_key,local_key,rate_key
extern init_rate_dispaly,keychk_amortize;,what_print_head
extern square_root,item_key,mdsw_update,initial_mdsw_update,fix_euro_to_ten,check_slftst
extern keep_ten_6dig
ROM section code abs=0xa000
MD_TIM equ 20 ;this already defined in key scan sub
;===============================================================================
; Initialize
;===============================================================================
start: ;reset or turn on power switch
ld sp,RAM_BOT ;stack pointer initial
ld (WDTCR2),0x4e ;WDT counter reset
ld (WDTCR1),0y00110000 ;WDT disable
ld (WDTCR2),0xb1 ;WDT disable code
ldw (SYSCR1),0y1000000000000000
; ||
; ||__turn off sub clock
; |__turn on main clock 8MHz
call init_io ;IO initialize
;RAM clear...............................................
ld hl,RAM_TOP ;\
ld a,0 ;|
ram_clr0: ;|
ld (hl),a ;|
inc hl ;|
cmp hl,RAM_BOT ;/
j le,ram_clr0 ;
;V3.00 ld (YEAR),0x05 ;\
;V3.00 ld (MON),0x01 ;|
;V3.00 ld (DAY),0x01 ;|;initialize Time base timer for RTC
j init_hw_wk
resume:
;RAM clear except RTC,TAX rate ..........................
ld hl,RAM_TOP ;\
ld a,0 ;|
ram_clr1: ;|clear RAM from RAM_TOP-->WO_CLR
ld (hl),a ;|
ram_clr2:
inc hl ;|
cmp hl,MDSW ; mdsw-->dp_pos no clear
j lt,ram_clr3 ;
cmp hl,DP_POS ;
j le,ram_clr2 ;
ram_clr3: ;
cmp hl,W1_CLR ;/
j lt,ram_clr1 ;
;-------------------------------------------------------------
and (FLG_ICON),0y00101100 ;just keep ICOM_M and ICOM_GT and F_ICPM flag only
call gt_clear ;V1.30
@CLB (ICON_GT) ;V1.30
call mem1_clear ;V1.39d
@CLB (ICON_M) ;V1.39d
init_hw_wk:
;V3.00 ld (T_Y20),0x20 ;V1.32
@SEB (F_DOFF) ;V2.05 no need display on when power on
pwr_wait:
@BBS (IO_PF,pwr_wait) ;if no AC power provided? yes-> loop
nop ;V2.06 mode switch will be initialed in subroutine "initial_mdsw_update"
nop ;V2.06
nop
@BBS (IO_PF,pwr_wait) ;V1.30
call all_clear ;h/w initialize, work area clear, interrupt enable
call model_select ;select printer model, logic model
;---------------------------------------------------------------
;V3.00 @BBS (RTC_INIT,pwr_wait_z) ;V1.46
;V3.00 call init_rtc ;V1.45
pwr_wait_z: ;V1.45
;---------------------------------------------------------------
di
call initial_mdsw_update ;V1.30;V1.27
ei
ld (MDCHK),0 ;V1.20
call mdsw_update ;V1.20
;V4.13 @BBS (SW_OFF_RT,init_hw_wk9) ;if OFF? yes -> no initial print
@BBS (SW_NP_RT,pwr_wait_1) ;V1.47
;V3.00 @BBC (F_WAKE,pwr_wait_0) ;V1.17
;V3.00 call feed_1
@SEB (F_INIREQ) ;V4.08
@BBS (M_5514T,pwr_wait_0) ;V4.08
@CLB (F_INIREQ) ;V4.08
call prn_init ;V3.00
pwr_wait_0: ;V1.17
@BBC (P_ERR,pwr_wait_1) ;no printer error occured? yes->
call prn_init ;printer initialize
pwr_wait_1:
;//test call check_slftst
call rate_init_check
@BBS (RATE_INI,pwr_wait_2) ;
@BBS (SW_NP_RT,init_hw_wk9) ;
ld (PRE_KEY),K_CEC ;
@BBS (M_5514T,init_hw_wk9) ;V4.08
call wkup_print ;print 'C'
call feed_1
jp init_hw_wk9 ;
pwr_wait_2: ;
call rate_init_flag_print ; out print to indicate all rate initialed
init_hw_wk9:
@BBS (IO_MT,init_hw_wk9)
call eeprom_check ;to check EEPROM initialed?
j cc,no_init_eeprom ;EEPROM initialed?
call ee_rate_init ;write check code into (EE_TEST)
no_init_eeprom:
call init_keybuf ;clear key counter,pointer
@BBC (RATE_INI,init_hw_wk90) ;no need initial, jmp to-->
call ee_rate_init ;yes, initial
@BBS (EP_FAIL,init_hw_wk90) ;
call init_rate_dispaly ;display "r-cc"
wait_key_in:
call wait_50ms
wait_key_in_1:
call check_mdsw ;to check slide
cmp (KEY_CT),0
j z,wait_key_in_1
call all_clear
call init_all_rate
j feed_key_end
init_hw_wk90:
call init_keybuf ;clear key counter,pointer
call init_all_rate
;V4.13 @BBS (SW_OFF_RT,main_loop) ;OFF position? yes -> does not display for avoid display flash in OFF mode
j feed_key_end ;'0' display and go to main loop
;===============================================================================
; Main routine(wait for key entry and jump to each function)
;===============================================================================
main_loop:
;V4.11 @BBS (F_WAKE,enter_stop) ;jump to auto off function
call check_mdsw ;check OFF,NP,RATE key movement
j cs,function_end9
ld a,(KEY_CT) ;Any key in?
j z,main_loop ; no-> loop
;V4.04 ld wa,AUTOOFFTIME
;V4.04 ld (AUTO_OFF_TIM),wa
call update_md ;MDFLG update from MDFLG_RT
;V2.03main_loop_ignore_dp_update:
;V4.11 @BBS (F_OFF,no_operation) ;if OFF mode? yes->ignore key entry
call key_get ;reg.a <- key code
j cc,no_operation ;illegal key code? yes-> ignore
@BBS (P_ERR,error_recov) ;if printer error? yes -> error recovery(under printer error -> ignore FEED also)
call check_perexe_flag_clearornot
cmp (KEYIN),K_IC
j eq,not_ic_key
@BBC (IC_PROG,relate_to_icx)
cmp (KEYIN),K_PLS
j eq,relate_to_ic
cmp (KEYIN),K_MIN
j eq,relate_to_ic
cmp (KEYIN),K_CEC
j eq,relate_to_ic
cmp (KEYIN),K_CE
j eq,relate_to_ic
@CLB (IC_PROG)
relate_to_ic:
ld hl,TENKEY
call edit_disp
call disp_to_dbr
relate_to_icx:
@CLB (F_ICPN)
;V4.13 @CLB (F_ICDSP)
not_ic_key:
main_loop_no_check_rt:
@BBS (F_CALER,error_recov) ;if calculation error? yes -> error recovery
;V3.00 @BBS (RTC_ON,rtc_key) ;RTC display mode? yes ->check entry key code and jump to each function
@BBC (F_RATE,main_kj0)
call obs_key_check
j cs,main_loop
;calculate each key function routin jump address.....
main_kj0:
ld a,(KEYIN)
ld c,0
cmp a,K_TEN ;if key code is Tenkey,00 or 000?
j le,main_kj2 ;yes ->
sub a,K_TEN ;for get function routine jump address
shlc a
ld c,a ;reg.c <- table offset
main_kj2:
ld hl,tbl_function ;get jump address
j (hl+c) ;jump to each function routine
;===============================================================================
; Exit of function routine
;===============================================================================
function_end:
cmp (KEYIN),K_RATE ;V1.04
j eq,function_end_0 ;V1.04
@CLB (F_RATE) ;V1.04
@CLB (RATE_PROG) ;V1.04
@CLB (EURO_PROG) ;V1.09
function_end_0: ;V1.04
ld (TEN_CT),0 ;
ld (DT_CT),0 ;#/D entry counter
ld (DT_DOT_CNT),0 ;
ld (DT_CHR_CNT),0 ;
@CLB (F_DPIN) ;DP entry
@CLB (F_MIN_TRA) ;-,M- entry
;entry point for tenkey.................................
tenkey_end:
ld a,(KEYIN)
ld (PRE_KEY),a ;save current key code -> PRE_KEY
cmp (KEYIN),K_RATE ;V1.13
j eq,shp_sgn_end ;V1.13
@BBS (RATE_PROG,shp_sgn_end) ;V1.13
@CLB (F_RATE) ;V1.13
;entry point for # key and +/- key......................
shp_sgn_end:
call kychk_clcsm ;check function key whether clear C-S-M flags
cmp (KEYIN),K_DP ;V1.07
j le,functionnoclearftenkey ;V1.07
cmp (KEYIN),K_BS ;V1.24
j eq,functionnoclearftenkey ;V1.24
cmp (KEYIN),K_SGN ;V1.36
j eq,functionnoclearftenkey ;V1.36
@CLB (F_TNKEY) ;V1.07
functionnoclearftenkey: ;V1.07
;/TEST call keychk_amortize ;V1.09
@CLB (EURO_DISPLY) ;V3.04
;entry point for FEED key(just check printer error)......................
feed_key_end:
@BBS (P_ERR,sys_error) ;check whether printer error occured during function? yes->
@BBS (F_CALER,sys_error) ;check whether calculation error occured during function? yes->
function_end9:
@BBS (F_TNKEY,function_end91) ;V1.23
;V3.00 @BBS (RTC_ON,no_operation)
function_end91: ;V1.23
ld hl,TENKEY
;V4.13 @BBC (F_ICDSP,function_not_isdsp) ;V1.23
;V4.13 call ic_display ;V1.23
;V4.13 jp function_end99
function_not_isdsp: ;V1.23
call vft_disable ;V2.10
call edit_disp
function_end99:
call disp_to_dbr ;DBR update (DISP -> DBR)
cmp (KEYIN),K_TAX ;V2.07
j eq,no_operation ;V2.07
;V4.13 @CLB (M_TX1) ;V2.07
;V4.13 @CLB (M_TX2) ;V2.07
no_operation: ;V2.07
;V2.05 call vft_enable ;V2.01
@CLB (F_DOFF) ;V2.05 display on enable
@CLB (F_REVCAN) ;V4.07
j main_loop
;==============================================================================
ic_display: ;--------V1.23
;V4.13 call spc_disp
;V4.13 @CLB (ICON_MIN) ;V1.48
;V1.39c ld a,(IC_BK)
;V4.13 ld a,(IC_BK+1) ;V1.39c
;V4.13 and a,0x0f
;V4.13 ld (DISP_LSD),a
;V1.39c ld a,(IC_BK)
;V4.13 ld a,(IC_BK+1) ;V1.39c
;V4.03 shrc a
;V4.03 shrc a
;V4.03 shrc a
;V4.03 shrc a
;V4.13 swap a ;V4.03
;V4.13 and a,0x0f ;V4.03
;V4.13 ld (DISP_LSD-1),a
;V1.39c ld a,(IC_BK+1)
;V4.13 ld a,(IC_BK) ;V1.39c
;V4.13 and a,0x0f
;V4.13 ld (DISP_LSD-2),a
;V4.13 ld (DISP_LSD-3),D_Uo
;V4.13 @BBC (SW_ICPM_RT,icp_disp)
;V4.13 ld (DISP_LSD-3),D_Lo
icp_disp:
ret
;-------------------------------------------
;==========================================
model_select:
ld a,(P0DR)
and a,0y00000011
nop ;V4.02
nop
nop
nop
nop
nop
nop
ld b,(P0DR)
and b,0y00000011
cmp a,b
j ne,model_select
ld (FLG_MODE),a
model_select_1: ;V4.02
ld a,(P3PRD) ;V4.02
and a,0y00000010 ;V4.02
nop ;V4.02
nop ;V4.02
nop ;V4.02
nop ;V4.02
nop ;V4.02
ld b,(P3PRD) ;V4.02
and b,0y00000010 ;V4.02
cmp a,b ;V4.02
j ne,model_select_1 ;V4.02
shlc a ;V4.02
or a,(FLG_MODE) ;V4.02
ld (FLG_MODE),a ;V4.02
test a.2
j t,model_select_2
@SEB (M_FX_M14) ;V4.07
model_select_2:
@SEB (M_FX_SGM)
@SEB (M_FX_AC)
ret
;===============================================================================
init_all_rate:
call ee_to_tax
call tax_to_w2
call w2_to_ten
call keep_ten_6dig
call ten_to_w2
call w2_to_tax
call ee_to_tax2
call tax2_to_w2
call w2_to_ten
call keep_ten_6dig
call ten_to_w2
call w2_to_tax2
call ee_country_read
ld a,(COUNTRY1)
cmp a,12
j lt,init_all_rate_1
clr cf
sub a,12
call ee_to_euro1
jp init_all_rate_10
init_all_rate_1:
ld (COUNTRY_TEN),a
call fix_euro_to_ten
call ten_to_euro1
init_all_rate_10:
ld a,(COUNTRY2)
cmp a,12
j lt,init_all_rate_2
clr cf
sub a,12
call ee_to_euro2
jp init_all_rate_20
init_all_rate_2:
ld (COUNTRY_TEN),a
call fix_euro_to_ten
call ten_to_euro2
init_all_rate_20:
call ten_clear
ret
;===============================================================================
check_perexe_flag_clearornot:
cmp (KEYIN),K_DP
j le,check_perexe_flag_clearornot_end
cmp (KEYIN),K_BS
j eq,check_perexe_flag_clearornot_end
cmp (KEYIN),K_SGN
j eq,check_perexe_flag_clearornot_end
cmp (KEYIN),K_TL
j eq,check_perexe_flag_clearornot_end
cmp (KEYIN),K_PLS
j eq,check_perexe_flag_clearornot_end
cmp (KEYIN),K_MIN
j eq,check_perexe_flag_clearornot_end
cmp (KEYIN),K_MPL
j eq,check_perexe_flag_clearornot_end
cmp (KEYIN),K_MMI
j eq,check_perexe_flag_clearornot_end
@BBS (SW_M2,check_perexe_flag_clearornot_8)
@BBC (F_M2CAL,check_perexe_flag_clearornot_9)
check_perexe_flag_clearornot_8:
;V4.12 cmp (KEYIN),K_M2PL
;V4.12 j eq,check_perexe_flag_clearornot_end
;V4.12 cmp (KEYIN),K_M2MI
;V4.12 j eq,check_perexe_flag_clearornot_end
check_perexe_flag_clearornot_9:
@CLB (F_PEREXE)
check_perexe_flag_clearornot_end:
ret
;===============================================================================
; System error
;===============================================================================
sys_error:
;V1.09 @BBS (ERR_MES,function_end9) ;already print error message yes-> skip print
@SEB (ICON_E) ;set 'E'
@BBS (P_ERR,sys_errpe1);printer error?
call err_print
ld hl,W1
call wk_print
call w1_to_ten
sys_errpe:
call feed_1
sys_errpe1: ;V1.39a
;V3.00 call ten_clear ;display '0'
cmp (KEYIN),K_PERPLS
j ne,sys_errpe2
ld hl,IC_A
ld (SYM),S_SPC ;V1.24
call ic_print
call acc_to_ten
ld hl,TENKEY
ld (SYM),S_ST
call wk_print
call feed_1
sys_errpe2:
j function_end9
;===============================================================================
; Error recovery
;===============================================================================
error_recov:
cmp (KEYIN),K_BS
j ne,error_recov_x ;V4.07
;V4.12 @BBS (F_COUNTRY,error_bs) ;V4.12
;V4.12 @BBS (F_RATE,no_operation) ;V4.07
@BBS (F_RATE,error_rec_bs) ;V4.12
ld (PRE_KEY),0xff ;V4.12
j error_rcv3 ;V4.12
;V4.12 jp error_bs_1 ;V4.12
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -