📄 business_fn.asm
字号:
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 ->
ld wa,F_TNKEY
test (F_TNKEY>>4).a ;bit -reverse-> jump status
j f,sell_key2 ;if jump status is 0 -> branch
;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)
test (FLG_MODE).2
j t,sell_key2
;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:
test (FLG_MODE).2
j t,sell_key2_1
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
ld wa,C_CST
test (C_CST>>4).a ;bit -reverse-> jump status
j f,sell_key4 ;if jump status is 0 -> branch
ld wa,C_MAR
test (C_MAR>>4).a ;bit -reverse-> jump status
j f,sell_key4 ;if jump status is 0 -> branch
;just after x -sell calculation or normal sell entry............
ld (FLG_C),0 ;clear all constant flags
ld wa,C_SEL
set (C_SEL>>4).a
ld wa,E_CST
test (E_CST>>4).a ;bit -reverse-> jump status
j f,cs_sl_calc ;if jump status is 0 -> branch
ld wa,E_MAR
test (E_MAR>>4).a ;bit -reverse-> jump status
j f,sl_mg_calc ;if jump status is 0 -> branch
;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
ld wa,E_SEL
set (E_SEL>>4).a
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:
ld wa,F_REVCAN
set (F_REVCAN>>4).a
call csm_dalt_calc ;V1.26
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,cs_sl_calc9 ;if jump status is 0 -> branch
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) %
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,cs_sl_calc9 ;if jump status is 0 -> branch
xor (W1_S),0x01;V1.32 ;W1(cost/sell) sign change
call w2_clear
ld (W2_LSD),0x01 ;set 1 to W2
call exchg_w12 ;V1.32;V1.28 :V1.36
call calc_add ;V1.32 ;W1 <- 1 - cost/sell ;V1.36
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,cs_sl_calc9 ;if jump status is 0 -> branch
call w2_clear
ld (W2_LSD-1),0x01 ;set 100 to W2
call calc_mult ;V1.34
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,cs_sl_calc9 ;if jump status is 0 -> branch
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
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,csm_dalt_calc_end ;if jump status is 0 -> branch
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 ->
ld wa,F_TNKEY
test (F_TNKEY>>4).a ;bit -reverse-> jump status
j f,margin_key2 ;if jump status is 0 -> branch
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)
test (FLG_MODE).2
j t,margin_key2
;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:
test (FLG_MODE).2
j t,margin_key2_1
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
ld wa,C_CST
test (C_CST>>4).a ;bit -reverse-> jump status
j f,margin_key4 ;if jump status is 0 -> branch
ld wa,C_SEL
test (C_SEL>>4).a ;bit -reverse-> jump status
j f,margin_key4 ;if jump status is 0 -> branch
;just after x -margin calculation or normal margin entry............
ld (FLG_C),0 ;clear all constant flags
ld wa,C_MAR
set (C_MAR>>4).a
ld wa,E_CST
test (E_CST>>4).a ;bit -reverse-> jump status
j f,cs_mg_calc ;if jump status is 0 -> branch
ld wa,E_SEL
test (E_SEL>>4).a ;bit -reverse-> jump status
j f,sl_mg_calc ;if jump status is 0 -> branch
;set margin %......
margin_key4:
ld (FLG_C),0 ;clear all constant flags
ld (FLG_E),0 ;clear all calculate instruction flags
ld wa,E_MAR
set (E_MAR>>4).a
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
ld wa,F_REVCAN
set (F_REVCAN>>4).a
call marg_to_w1
call w2_clear
ld (W2_LSD-1),0x01 ;set 100 to W2
call calc_div ;W1 <- margin/100
xor (W1_S),0x01 ;W1(margin/100) sign change
call w2_clear
ld (W2_LSD),0x01 ;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)
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,cs_mg_calc9 ;if jump status is 0 -> branch
ld hl,W1
call wk_round ;
call w1_to_w2
call w2_to_sell
call csm_dalt_calc ;V1.26
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,cs_mg_calc9 ;if jump status is 0 -> branch
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
ld wa,F_REVCAN
set (F_REVCAN>>4).a
call marg_to_w1
call w2_clear
ld (W2_LSD-1),0x01 ;set 100 to W2
call calc_div ;W1 <- margin/100
xor (W1_S),0x01 ;W1(margin/100) sign change
call w2_clear
ld (W2_LSD),0x01 ;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)
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,sl_mg_calc9 ;if jump status is 0 -> branch
ld hl,W1
call wk_round ;
call w1_to_w2
call w2_to_cost
call csm_dalt_calc ;V1.26
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,sl_mg_calc9 ;if jump status is 0 -> branch
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:
ld wa,F_CALER
test (F_CALER>>4).a ;bit -reverse-> jump status
j f,csm_flag_clear_end ;if jump status is 0 -> branch
and (FLG_E),0y00001111
and (FLG_C),0y00001111
ld wa,CSM_RECALL
set (CSM_RECALL>>4).a
csm_flag_clear_end:
ret
;V1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -