📄 business_fn.mac
字号:
;===============================================
kychk_sttl:
;V4.12 @IS_5514_OFF(kychk_sttl8) ;V4.12
;V4.12 cmp a,K_IC ;V4.12
;V4.12 j eq,kychk_sttl9 ;V4.12
;V4.12 cmp a,K_SHD ;V4.12
;V4.12 j eq,kychk_sttl9 ;V4.12
;V4.12kychk_sttl8: ;V4.12
cmp a,K_ST
j eq,kychk_sttl9
cmp a,K_TL
j eq,kychk_sttl9
cmp a,K_MST
j eq,kychk_sttl9
cmp a,K_MTL
j eq,kychk_sttl9
;V4.01 cmp a,K_M2ST
;V4.01 j eq,kychk_sttl9
;V4.01 cmp a,K_M2TL
;V4.01 j eq,kychk_sttl9
;V4.01 cmp a,K_GT
;V4.01 j eq,kychk_sttl9
;also allow to calculate C-S-M if previouse entery as below key code (even display value is 0 or not changed)
cmp a,K_SGN ;after change sign -> calculate
j eq,kychk_sttl9
cmp a,K_BS ;after tenkey - BS key -> calculate
j eq,kychk_sttl9
cmp a,K_ZERO ;after 0 key -> calculate
kychk_sttl9:
ret
;===============================================
; check key (COST,SELL,MARGIN,CEC)
;===============================================
kychk_csm:
cmp a,K_CST
j eq,kychk_csm9
cmp a,K_SEL
j eq,kychk_csm9
cmp a,K_MGR
j eq,kychk_csm9
cmp a,K_CEC ;
kychk_csm9:
ret
;===============================================
; check key (ST,TL,MST,MTL,GT)
;===============================================
kychk_clcsm:
ld a,(KEYIN)
@IS_5514_OFF(kychk_clcsm_1) ;V4.12
cmp a,K_SHD ;V4.12
j eq,kch_clcsm9 ;V4.12
cmp a,K_IC ;V4.12
j eq,kch_clcsm9 ;V4.12
kychk_clcsm_1: ;V4.12
cmp a,K_DP
j le,kch_clcsm9
;V1.40 jp kch_clcsm99 ;V1.28;V1.40
cmp a,K_CE ;V1.28;V1.40
j eq,kch_clcsm9 ;V1.28;V1.40
cmp a,K_SGN ;V1.28;V1.40
j eq,kch_clcsm9 ;V1.28;V1.40
cmp a,K_BS ;V1.28;V1.40
j eq,kch_clcsm9 ;V1.28;V1.40
cmp a,K_ST ;V1.28;V1.40
j eq,kch_clcsm9 ;V1.28;V1.40
cmp a,K_TL ;V1.28;V1.40
j eq,kch_clcsm9 ;V1.28;V1.40
cmp a,K_MST ;V1.28;V1.40
j eq,kch_clcsm9 ;V1.28;V1.40
cmp a,K_MTL ;V1.28;V1.40
j eq,kch_clcsm9 ;V1.28;V1.40
;V4.01 cmp a,K_M2ST ;V1.28;V1.40
;V4.01 j eq,kch_clcsm9 ;V1.28;V1.40
;V4.01 cmp a,K_M2TL ;V1.28;V1.40
;V4.01 j eq,kch_clcsm9 ;V1.28;V1.40
;V4.01 cmp a,K_GT ;V1.28;V1.40
;V4.01 j eq,kch_clcsm9 ;V1.28;V1.40
cmp a,K_CST ;V1.28;V1.40
j eq,kch_clcsm99 ;V1.28;V1.40
cmp a,K_SEL ;V1.28;V1.40
j eq,kch_clcsm99 ;V1.28;V1.40
cmp a,K_MGR ;V1.28;V1.40
j eq,kch_clcsm99 ;V1.28;V1.40
;V1.40kch_clcsm9:
and (FLG_C),0y00001111 ;clear C-S-M constant flags
and (FLG_E),0y00001111 ;V1.28;V1.40 ;clear C-S-M calculate instruction flags
;V1.40;V1.28 jp kch_clcsm99
kch_clcsm9:;V1.28;V1.40
;V1.28 @CLB (CSM_RECALL) ;V1.28
kch_clcsm99:
ret
;------------------------------------------------
;K_MONTH equ 0x40 ;V1.25 exten key code
;K_PAYMENT equ 0x41 ;V1.25 exten key code
;K_INTEREST equ 0x42 ;V1.25 exten key code
;K_AMOUNT equ 0x43 ;V1.25 exten key code
;V3.14keychk_amortize: ;V1.09
;V3.14 @BBC (M_FINANCE,keychk_amortize_end)
;V3.14 ld a,(KEYIN)
;V3.14 cmp (KEYIN),K_MONTH
;V3.14 j eq,keychk_amortize_end
;V3.14 cmp (KEYIN),K_PAYMENT
;V3.14 j eq,keychk_amortize_end
;V3.14 cmp (KEYIN),K_INTEREST
;V3.14 j eq,keychk_amortize_end
;V3.14 cmp (KEYIN),K_AMOUNT
;V3.14 j eq,keychk_amortize_end
;V3.14 @CLB (F_FNRECALL)
;V3.14 @CLB (F_MODIFIED) ;V1.13
;V3.14keychk_amortize_end:
;V3.14 ret
;===============================================================================
; SELL key
;===============================================================================
sell_key:
;V4.01 @BBC (M_FINANCE,sell_operation) ;V1.17a
;V4.01sell_key_x:
;V4.01 jp no_operation ;V1.17a
sell_operation: ;V1.17a
;V1.26 cmp (TEN_CT),0 ;with tenkey?
;V1.26 j ne,sell_key2 ; yes ->
@BBS (F_TNKEY,sell_key2) ;V1.26
;no tenkey entry.......
ld a,(PRE_KEY) ;check previouse key(reg.a)
call kychk_sttl ;V1.17a;V1.40 ;check ST,TL,MST,MTL,GT key
j eq,sell_key2 ;V1.17a;V1.40 ;Z=1: yes -> set price ot execute calculation
ld w,(FLG_C) ;check constant flags
and w,0y11110000 ;C_MAR,C_SEL,C_CST on? ;V1.41
;V1.42 and w,0y01110000 ;C_MAR,C_SEL,C_CST on? V1.42
j z,sell_key0 ; no(after entry C,S,M or nothing entry) ->
call kychk_csm ;check cost, sell, margin or cce key
j eq,sell_rcall ;Z=1: yes -> recall function
ld (FLG_C),0 ;clear all constant flags
ld (FLG_E),0 ;clear all calculate instruction flags
j sell_key2 ; -> set price
sell_key0:
ld w,(FLG_E) ;V1.17a ;check entry flags
and w,0y01110000 ;V1.17a ;E_MAR,E_SEL,E_CST on?
j z,sell_key2 ;V1.17a ;no any entry flags yes-> set selling price(display value)
@IS_5514_OFF(sell_key2) ;V4.12
;V3.03 call kychk_csm ;V1.17a ;check cost, sell, margin or cce key
cmp a,K_SEL ;V4.12
j eq,no_operation ;V3.03;V1.17a ;Z=1: yes -> no operation
;V3.03 ld (FLG_E),0 ;V1.17a ;clear all calculate instruction flags
;V1.28 @BBS (M_V1297,sell_key_x) ;V1.26
j sell_key2 ;V1.28;V1.40 ; -> set price
;V1.40 j sell_key_x ;V1.28
;recall previouse selling price....
sell_rcall:
call sell_to_w2
ld (SYM),S_SELL ;sell symbol
ld hl,W2
call wk_print ;V1.17b
;V1.17b call wk_prn_2L ;W2(input value) print with check 2line print
call feed_1
call w2_to_ten ;for display recall value(W2)
ld (FLG_E),0
j function_end
;with tenkey entry.......
sell_key2:
@IS_5514_OFF(sell_key2_1) ;V4.09
call ten_to_w2dp ;V4.09
jp sell_key2_2 ;V4.09
sell_key2_1: ;v4.09
call ten_to_w2 ;tenkey -> W2(no DP adjustment)
sell_key2_2:
call w2_to_sell ;input -> sell backup
ld (SYM),S_SELL ;sell symbol
ld hl,W2
call wk_print ;V1.17b
;V1.17b call wk_prn_2L ;W2(input value) print with check 2line print
@BBS (C_CST,sell_key4) ;just after x -cost calculation? yes-> set selling price only
@BBS (C_MAR,sell_key4) ;just after x -margin calculation? yes-> set selling price only
;just after x -sell calculation or normal sell entry............
ld (FLG_C),0 ;clear all constant flags
@SEB (C_SEL) ;set sell constant calc. flag
@BBS (E_CST,cs_sl_calc) ; -> COST-SELL calculation
@BBS (E_MAR,sl_mg_calc) ; -> SELL-MARGIN calculation
;set selling prince......
sell_key4:
;V2.00 @SEB (LCD_SELL) ;V1.18
ld (FLG_C),0 ;clear all constant flags
ld (FLG_E),0 ;clear all calculate instruction flags
@SEB (E_SEL) ;set sell entry
call w2_to_ten ;for display input value(W2)
j function_end
;===============================================
; Calculate COST - SELL -> MARGIN
;===============================================
;
; MARGIN = 100 * (1 - COST/SELL)
;
;媽F_OVRFLW 僼儔僌乮妱傝嶼偱僆乕僶乕僼儘乕偵側偭偨傜寢壥傪僋儕傾偡傞乯張棟偼昁梫偐?
;
;
cs_sl_calc:
@SEB (F_REVCAN) ;V4.08
call csm_dalt_calc ;V1.26
@BBS (F_CALER,cs_sl_calc9)
call cost_to_w1;V1.32 ;V1.36
;V1.36 @S100_W2 ;V1.34
;V1.36 call calc_mult ;V1.34
call sell_to_w2
call calc_div ;W1 <- (cost / sell) %
@BBS (F_CALER,cs_sl_calc9) ;V1.31
xor (W1_S),0x01;V1.32 ;W1(cost/sell) sign change
@S1_W2 ;V1.32 ;set 1 to W2 :V1.36
call exchg_w12 ;V1.32;V1.28 :V1.36
call calc_add ;V1.32 ;W1 <- 1 - cost/sell ;V1.36
@BBS (F_CALER,cs_sl_calc9) ;V1.36
@S100_W2 ;V1.34 ;set 100 to W2 ;V1.36
call calc_mult ;V1.34
@BBS (F_CALER,cs_sl_calc9)
ld hl,W1
call wk_round ;
call w1_to_w2
call w2_to_marg
ld (SYM),S_MARG ;
call wk_print
call feed_1
call w1_to_ten ;for calculated answer(W1)
call csm_flag_clear ;V1.26;V1.40;V1.42
j function_end
cs_sl_calc8:
sub (W1_DP),2
cs_sl_calc9:
;V3.04 ld (FLG_C),0 ;clear all constant flags
;v3.04 ld (FLG_E),0 ;clear all calculate instruction flags
ld (SYM),S_AST ;for error print
j function_end
;-----V1.26 calculate for dalta= sell-cost
csm_dalt_calc:
call cost_to_w2
call sell_to_w1
xor (W2_S),1 ;V1.26
call calc_add ;V1.26
@BBS (F_CALER,csm_dalt_calc_end) ;v1.28
ld hl,W1 ;v1.26
call wk_round ;V1.26
ld (SYM),S_DLAS ;V1.26
call wk_print ;V1.26
csm_dalt_calc_end:
ret
;===============================================================================
; MARGIN key
;===============================================================================
margin_key:
;V4.01 @BBC (M_FINANCE,marg_operation) ;V1.17a
;V4.01margin_key_x:
;V4.01 jp no_operation ;V1.17a
marg_operation: ;V1.17a
;V1.26 cmp (TEN_CT),0 ;with tenkey?
;V1.26 j ne,margin_key2 ; yes ->
@BBS (F_TNKEY,margin_key2) ;V1.26
marg_operation_1:
;no tenkey entry.......
ld a,(PRE_KEY) ;check previouse key(reg.a)
call kychk_sttl ;V1.17a;V1.40 ;check ST,TL,MST,MTL,GT key
j eq,margin_key2 ;V1.17a;V1.40 ;Z=1: yes -> set price ot execute calculation
ld w,(FLG_C) ;check constant flags
and w,0y11110000 ;C_MAR,C_SEL,C_CST on? V1.41
;V1.42 and w,0y01110000 ;C_MAR,C_SEL,C_CST on? V1.42
j z,margin_key0 ; no(after entry C,S,M or nothing entry) ->
call kychk_csm ;check cost, sell, margin or cce key
j eq,margin_rcall ;Z=1: yes -> recall function
ld (FLG_C),0 ;clear all constant flags
ld (FLG_E),0 ;clear all calculate instruction flags
j margin_key2 ; -> set price
margin_key0:
ld w,(FLG_E) ;V1.29;V1.40 ;check entry flags
and w,0y01110000 ;V1.29;V1.40 ;E_MAR,E_SEL,E_CST on?
j z,margin_key2 ;V.129;V1.40 ;no any entry flags yes-> set margin price(display value)
@IS_5514_OFF(margin_key2) ;V4.12
;V3.03 call kychk_csm ;V1.17a;V1.40 ;check cost, sell, margin or cce key
cmp a,K_MGR ;V4.12
j eq,no_operation ;V3.03;V1.17a;V1.40 ;Z=1: yes -> no operation
;V3.03 ld (FLG_E),0 ;V1.17a;V1.40 ;clear all calculate instruction flags
j margin_key2;V1.28;V1.40
;V1.40 j margin_key_x ;V1.28
margin_key1:
j no_operation ;others are ignore
;recall previouse margin %....
margin_rcall:
call marg_to_w2
ld (SYM),S_MARG ;margin symbol
;V2.03 @BBC (M_V1297,margin_recall_1) ;V1.26
;V2.03 ld (SYM),S_PERMARG ;V1.26
;V2.03margin_recall_1: ;V1.26
ld hl,W2
call wk_print ;W2(input value) print
call feed_1
call w2_to_ten ;for display recall value(W2)
ld (FLG_E),0
j function_end
;with tenkey entry.......
margin_key2:
@IS_5514_OFF(margin_key2_1) ;V4.09
call ten_to_w2dp ;V4.09
jp margin_key2_2 ;V4.09
margin_key2_1: ;v4.09
call ten_to_w2 ;tenkey -> W2(no DP adjustment)
margin_key2_2:
call w2_to_marg ;input -> margin backup
ld (SYM),S_MARG ;margin symbol
ld hl,W2
call wk_print ;W2(input value) print
@BBS (C_CST,margin_key4) ;just after x -cost calculation? yes-> set margin% only
@BBS (C_SEL,margin_key4) ;just after x -sell calculation? yes-> set margin% only
;just after x -margin calculation or normal margin entry............
ld (FLG_C),0 ;clear all constant flags
@SEB (C_MAR) ;set margin constant calc. flag
@BBS (E_CST,cs_mg_calc) ; -> cost - margin calculation
@BBS (E_SEL,sl_mg_calc) ; -> sell - margin calculation
;set margin %......
margin_key4:
ld (FLG_C),0 ;clear all constant flags
ld (FLG_E),0 ;clear all calculate instruction flags
@SEB (E_MAR) ;set margin entry
call w2_to_ten ;for display input value(W2)
j function_end
;===============================================
; Calculate COST - MARGIN -> SELL
;===============================================
;
; SELL = COST / (1-MARGIN/100)
;
cs_mg_calc:
;V2.00 @SEB (LCD_SELL) ;V1.18
@SEB (F_REVCAN) ;V4.08
call marg_to_w1
@S100_W2 ;set 100 to W2
call calc_div ;W1 <- margin/100
xor (W1_S),0x01 ;W1(margin/100) sign change
@S1_W2 ;set 1 to W2
call exchg_w12 ;V1.28
call calc_add ;W1 <- 1 - (margin/100)
call w1_to_w2
call cost_to_w1
call calc_div ;W1 <- cost / (1-margin/100)
@BBS (F_CALER,cs_mg_calc9)
ld hl,W1
call wk_round ;
call w1_to_w2
call w2_to_sell
call csm_dalt_calc ;V1.26
@BBS (F_CALER,cs_mg_calc9) ;V4.11
call sell_to_w2 ;V1.26
ld hl,W2 ;V1.26
ld (SYM),S_SELL ;
j sl_mg_prn
cs_mg_calc9:
;V3.04 ld (FLG_C),0 ;clear all constant flags
;V3.04 ld (FLG_E),0 ;clear all calculate instruction flags
ld (SYM),S_AST ;for error print
j function_end
;===============================================
; Calculate SELL - MARGIN -> COST
;===============================================
;
; COST = SELL * (1-MARGIN/100)
;
sl_mg_calc:
;V2.00 @SEB (LCD_COST) ;V1.18
@SEB (F_REVCAN) ;V4.08
call marg_to_w1
@S100_W2 ;set 100 to W2
call calc_div ;W1 <- margin/100
xor (W1_S),0x01 ;W1(margin/100) sign change
@S1_W2 ;set 1 to W2
call exchg_w12 ;V1.28
call calc_add ;W1 <- 1 - (margin/100)
call w1_to_w2
call sell_to_w1
call calc_mult ;W1 <- sell * (1-margin/100)
@BBS (F_CALER,sl_mg_calc9)
ld hl,W1
call wk_round ;
call w1_to_w2
call w2_to_cost
call csm_dalt_calc ;V1.26
@BBS (F_CALER,sl_mg_calc9) ;V4.11
call cost_to_w2 ;V1.26
ld hl,W2 ;V1.26
ld (SYM),S_COST ;
sl_mg_prn:
call wk_print ;V1.17b
;V1.17b call wk_prn_2L ;check W1 contents for 2line print
call feed_1
call w2_to_ten ;for calculated answer(W2)
call csm_flag_clear ;V1.26;V1.40;V1.42
j function_end
sl_mg_calc9:
;V3.04 ld (FLG_C),0 ;clear all constant flags
;V3.04 ld (FLG_E),0 ;clear all calculate instruction flags
ld (SYM),S_AST ;for error print
j function_end
;V1.26--------------------------------
csm_flag_clear:
@BBS (F_CALER,csm_flag_clear_end)
and (FLG_E),0y00001111
and (FLG_C),0y00001111
@SEB (CSM_RECALL)
csm_flag_clear_end:
ret
;V1.26---------------------------------
;===============================================
; Print sub routine
;===============================================
;check work reg. contents is minus for 2line print control....
;V3.14wk_prn_2L:
;V3.14 ld a,(hl+OFF_S) ;-value?
;V3.14 j z,wk_prn_25 ;Work reg. is 'Minus'? no->
;V3.14 ld a,(SYM)
;V3.14 push wa ;save symbol
;V3.14 push hl ;save pointer
;V3.14 ld (SYM),S_SPC ;
;V3.14 call wk_print ;Work reg.print with minus sign
;V3.14 pop hl ;recover pointer
;V3.14 pop wa ;recover symbol
;V3.14 ld (SYM),a
;V3.14 call sym_print_br ;print symbol and set P_RED by refer work reg.(hl)
;V3.14 j wk_prn_26
;V3.14wk_prn_25:
;V3.14 call wk_print ;Work reg. print
;V3.14wk_prn_26:
;V3.14 ret
;====================================================================
;EURO convert function
;====================================================================
euro_key:
euro_key_start:
ld (KEYIN),K_EURO
@BBS (F_COUNTRY,euro_rate_recall_x) ;V3.05
@BBS (EURO_PROG,euro_rate_confirm)
@BBC (F_RATE,euro_convert)
euro_rate_recall:
local_rate_recall:
@BBS (F_TNKEY,euro_rate_recall_x)
@BBC (F_COUNTRY,euro_rate_recall_0)
euro_rate_recall_x:
;V4.12a @SEB (F_CALER)
;V4.12a @SEB (ICON_E)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -