⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic_fn.mac

📁 calculator code ,use toshibaor nec LSI
💻 MAC
📖 第 1 页 / 共 5 页
字号:
com_w2_0p4:
	@BBC	(M10,com_w2_0p5)
	ld	(W1_DP),9
com_w2_0p5:
	xor	(W1_S),1
	call	calc_add
	@BBS	(M14,com_w2_0p7)
	@BBS	(M10,com_w2_0p8)
com_w2_0p6:
	cmp	(W1_DP),11
	jp	com_w2_0p9
com_w2_0p7:
	cmp	(W1_DP),13
	jp	com_w2_0p9
com_w2_0p8:
	cmp	(W1_DP),9
com_w2_0p9:
	j	lt,com_w2_0pa
	and	(W1_LSD),0y11111110	;V1.30
com_w2_0pa:
	ld	hl,W1
	call	_zerock
	ret
	;---------------------
root_tab_a:
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00	;2^0 =1
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00	;2^1 =2
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00	;2^2 =4
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00	;2^3 =8
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x16,0x00	;2^4 =16
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x00	;2^5 =32
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x00	;2^6 =64
	db	0x00,0x00,0x00,0x00,0x00,0x01,0x28,0x00	;2^7 =128
	db	0x00,0x00,0x00,0x00,0x00,0x02,0x56,0x00	;2^8 =256
	db	0x00,0x00,0x00,0x00,0x00,0x05,0x12,0x00	;2^9 =512
	db	0x00,0x00,0x00,0x00,0x00,0x10,0x24,0x00	;2^10=1024
	db	0x00,0x00,0x00,0x00,0x00,0x20,0x48,0x00	;2^11=2048
	db	0x00,0x00,0x00,0x00,0x00,0x40,0x96,0x00	;2^12=4096
	db	0x00,0x00,0x00,0x00,0x00,0x81,0x92,0x00	;2^13=8192
	db	0x00,0x00,0x00,0x00,0x01,0x63,0x84,0x00	;2^14=16384

root_tab_b:
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00	;2^0    =1. 
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01	;2^(-1) =0.5
	db	0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x02	;2(-2)  =0.25
	db	0x00,0x00,0x00,0x00,0x00,0x01,0x25,0x03	;2^(-3) =0.125 
	db	0x00,0x00,0x00,0x00,0x00,0x06,0x25,0x04	;2^(-4) =0.0625 
	db	0x00,0x00,0x00,0x00,0x00,0x31,0x25,0x05	;2^(-5) =0.03125 
	db	0x00,0x00,0x00,0x00,0x01,0x56,0x25,0x06	;2^(-6) =0.015625 
	db	0x00,0x00,0x00,0x00,0x07,0x81,0x25,0x07	;2^(-7) =0.0078125 
	db	0x00,0x00,0x00,0x00,0x39,0x06,0x25,0x08	;2^(-8) =0.00390625 
	db	0x00,0x00,0x00,0x01,0x95,0x31,0x25,0x09	;2^(-9) =0.001953125
	db	0x00,0x00,0x00,0x09,0x76,0x56,0x25,0x0a	;2^(-10)=0.0009765625
	db	0x00,0x00,0x00,0x48,0x82,0x81,0x25,0x0b	;2^(-11)=0.00048828125
	db	0x00,0x00,0x24,0x41,0x40,0x06,0x25,0x0c	;2^(-12)=0.000244140625
	db	0x00,0x00,0x12,0x20,0x70,0x31,0x25,0x0d	;2^(-13)=0.0001220703125
	db	0x00,0x00,0x61,0x03,0x51,0x56,0x25,0x0e	;2^(-14)=0.00006103515625 
;===============================================================================
;		x
;===============================================================================
multi_key:
;===============================================================================
;		div
;===============================================================================
divide_key:
;V1.33		ld	a,(TEN_CT)		;no tenkey?
;V1.33		j	nz,div_key00		; with tenkey ->
		@BBS	(F_TNKEY,div_key00)	;V1.33
;if no tenkey entry, check x,div, repeat entry........
		cmp	(PRE_KEY),K_MUL		;if previouse key is X ?
		j	eq,div_key10		; yes -> use W2(previouse multiplicand value) for repeat entry
		cmp	(PRE_KEY),K_DIV		;if previouse key is div ?
		j	eq,div_key10		; yes -> use W2(previouse dividend value) for repeat entry
div_key00:
		cmp	(KEYIN),K_MUL		;V1.16
		j	eq,div_key001		;V1.16
;V4.13		@BBC	(SW_ADM12,div_key001)	;V1.16
;V4.13		call	add_mode		;V1.16
;V4.13		j	cs,div_key10		;V1.16
div_key001:					;V1.16
		@IS_5514_OFF(div_key002);V4.09
		call	ten_to_w2dp	;V4.09
		jp	div_key003	;v4.09
div_key002:				;V4.09
		call	ten_to_w2		;tenkey -> W2(no DP adjustment)
div_key003:				;V4.09
		jp	div_key101	;V1.17
div_key10:
		call	w2_to_ten	;V1.17
		call	ten_to_w2	;V1.17
div_key101:
		ld	(SYM),S_MUL
		cmp	(KEYIN),K_MUL
		j	eq,div_key11
		ld	(SYM),S_DIV
div_key11:
		ld	hl,W2
		call	wk_print		;W2(input value) print
;V1.26		ld	(FLG_C),0		;clear all constant calculation flags
;V1.40		and	(FLG_C),0y11110000	;V1.26|clear all flag except CSM
		ld	(FLG_C),0		;V1.40
		@BBC	(ERR_CLR,div_key12)	;just after clear calculation error?  no->
		@CLB	(E_MUL)			;stop chain calculation
		@CLB	(E_DIV)			;
div_key12:
		call	calc_sub		;calculation if Mul or Div flag is set before?
		ld	(FLG_E),0		;clear all calculate instruction flags
		cmp	(KEYIN),K_MUL
		j	eq,div_key13
		@SEB	(E_DIV)			;set divide calculate instruction
		j	div_key14
div_key13:
		@SEB	(E_MUL)			;set multiple calculate instruction
div_key14:
		@BBS	(F_CALER,div_key29)	;if error occured?  yes->
		@SEB	(MEQ_ENB)		;set M+= or M-= calculation enable for after calculation error
;V1.17		@BBC	(SW_ADM,div_key18)	;V1.17
;V1.17		@BBC	(SW_ADM12,div_key18)	;V1.16
;V1.17		ld	hl,W1			;V1.16
;V1.17		call	check_dp_over2		;V1.16
		call	w1_to_ten	;V1.17
		call	ten_to_w1	;V1.17
		call	w1_to_const		;calculated answer -> keep to CONST
		call	w1_to_ten		;for display calculated answer(W1)

div_key19:
		j	function_end
div_key29:
		ld	(SYM),S_AST		;for error print
		call	w2_to_const		;if error occur, set input value to constant
		j	function_end

;===============================================================================
;		MU
;===============================================================================
markup_key:
		call	ten_to_w2dp		;tenkey -> W2(no DP adjustment)
		ld	(SYM),S_MKUP
		ld	hl,W2
		call	wk_print		;W2(input value) print
;V1.26		ld	(FLG_C),0		;clear all constant calculation flags
;v1.40		and	(FLG_C),0y11110000	;V1.26|clear all flag except CSM
		ld	(FLG_C),0		;V1.40
;V1.28		ld	(FLG_E),0		;clear all calculate instruction flags
;V1.40		and	(FLG_E),0y01110000	;V1.28
		ld	(FLG_E),0		;v1.40
		@SEB	(E_MUP)			;set mark up calculate instruction
		call	w2_to_const		;input value save to CONST(for constant calculation)
		call	w2_to_ten		;for display input value(W2)
		j	function_end

;===============================================================================
;		delta%
;===============================================================================
delta_percent:
		@BBS	(EURO_DISPLY,no_operation)	;V3.04
		@IS_5514_OFF(delta_percent_1)	;V4.09
		call	ten_to_w2dp		;V4.09
		jp	delta_percent_2		;V4.09
delta_percent_1:				;V4.09
		call	ten_to_w2		;tenkey -> W2(no DP adjustment)
delta_percent_2:
		ld	(SYM),S_DLTA			;V1.34 Dlta%

		ld	hl,W2
		call	wk_print		;W2(input value) print
;V1.26		ld	(FLG_C),0		;clear all constant calculation flags
;V1.40		and	(FLG_C),0y11110000	;V1.26|clear all flag except CSM
		ld	(FLG_C),0		;V1.40
;V1.28		ld	(FLG_E),0		;clear all calculate instruction flags
;v1.40		and	(FLG_E),0y01110000	;V1.28
		ld	(FLG_E),0		;V1.40
		@SEB	(E_DLT)			;set mark up calculate instruction
		call	w2_to_const		;input value save to CONST(for constant calculation)
		call	w2_to_ten		;for display input value(W2)
		j	function_end

;===============================================================================
;		+/-
;===============================================================================
sign_change:
		@BBS	(F_DPIN,sign_change1)	;V1.35if already enter '.' key?  yes -> skip tenkey zero check
;V3.04		call	ten_zerock		;V1.35
;V3.04		j	nz,sign_change1		;V1.35if TENKEY is zero?  no-> accept +/- key
;V1.52		ld	a,(TEN_DP)		;V1.36
;V1.52		j	ne,sign_change1		;V1.36
;V3.04		j	no_operation		;V1.35
;V1.13;check for [DP] - [#} - [+/-] - [#] entry (accept +/- key)......
sign_change0:
;V1.31		@BBS	(F_TNKEY,sign_change1)	;V1.30
;V1.31		@BBS	(F_DPIN,sign_change1)	;V1.30
;V3.04		call	ten_zerock		;V1.30 V1.36
;V3.04	j	z,sign_change8			;V1.30 V1.36
sign_change1:					;V1.30
		cmp	(PRE_KEY),K_PLS
		j	eq,no_operation
		cmp	(PRE_KEY),K_MIN
		j	eq,no_operation
		@CLB	(RATE_PROG)	;V1.38a
		@CLB	(EURO_PROG)	;V1.38a
		@CLB	(F_RATE)	;V1.38a
		xor	(TEN_S),0x01		;invert tenkey sign
;V4.13		@SEB	(F_FNEABL)	;V1.09
;V4.12		@IS_5514_OFF(sign_change9)	;V4.12
;V4.12		@SEB	(F_TNKEY)		;V4.12
;V4.12		cmp	(PRE_KEY),K_SHD		;#/D key?
;V4.12		j	eq,sign_change9		;-> doesn't update PRE_KEY for keep #/D repeat
;V1.35 		ld	a,(KEYIN)
;V1.35 		ld	(PRE_KEY),a		;save current key code -> PRE_KEY
sign_change9:
;V1.35b		j	functionnoclearftenkey		;exit of # key and +/- key
		j	tenkey_end		;V1.35b

sign_change8:
		j	no_operation		;


;===============================================================================
;		BS
;===============================================================================
back_space:
		@BBC	(F_RATE,back_space_obs)
		inc	(COUNTRY_TEN)			;V4.11
		@BBS	(EURO_PROG,back_space_0x)	;V4.11
		ld	(COUNTRY_TEN),0			;V4.11
back_space_0x:						;V4.11
		@SEB	(EURO_PROG)
		@BBS	(F_TNKEY,back_space_x)	;V4.07
		cmp	(COUNTRY_TEN),17
		j	lt,back_space_obs_0
		ld	(COUNTRY_TEN),0
		jp	back_space_obs_0
back_space_x:					;v4.07
		call	ten_zerock			;V4.12
		j	z,rate_ten_key_01		;V4.12
		@BBS	(F_COUNTRY,back_space_x0)	;V4.07
		cmp	(COUNTRY_TEN),17	;V4.07
		j	lt,back_space_x1	;V4.07
back_space_x0:
		@CLB	(F_COUNTRY)		;V4.07
		ld	(COUNTRY_TEN),12	;V4.07
back_space_x1:
		cmp	(COUNTRY_TEN),12	;V4.12
		j	ge,back_space_x2	;V4.12
		ld	(COUNTRY_TEN),12	;V4.12
back_space_x2:					;V4.12
		ld	hl,TENKEY		;V4.07
		call	euro_display		;V4.07
;V4.12		inc	(COUNTRY_TEN)		;V4.07
;V4.12		cmp	(COUNTRY_TEN),17	;V4.07
;V4.12		j	lt,back_space_x2	;V4.07
;V4.12		ld	(COUNTRY_TEN),12	;V4.07
;V4.12back_space_x2:					;V4.07
		jp	no_operation		;V4.07	


back_space_obs_0:
		cmp	(COUNTRY_TEN),12
		j	ge,back_space_obs_1
		call	fix_euro_to_ten
		jp	back_space_obs_2
back_space_obs_1:
;V4.11		ld	a,(COUNTRY)
		ld	a,(COUNTRY_TEN)	;V4.11
		clr	cf
		sub	a,12
		call	ee_to_ten
back_space_obs_2:
		ld	hl,TENKEY
		call	euro_display
;V4.11		inc	(COUNTRY_TEN)
		cmp	(COUNTRY_TEN),17
		j	lt,back_space_obs_3
		ld	(COUNTRY_TEN),0
back_space_obs_3:
		@CLB	(RATE_PROG)
		@CLB	(F_TNKEY)
		@CLB	(F_DPIN)
		@CLB	(F_COUNTRY)	;V4.12
		ld	(TEN_CT),0	;
		ld	(DT_CT),0	;
		ld	(DT_DOT_CNT),0	;
		ld	(DT_CHR_CNT),0	;
		jp	no_operation
		;-----------------------------------
back_space_obs:
;V4.18		@BBC	(F_TNKEY,no_operation)	;V4.18
;v4.18		call	bs_dt_buf		;for #/D entry
;V4.17		ld	a,(TEN_CT)
		call	ten_zerock	;V4.17
;V4.12		j	z,no_operation		;tenkey entry? (no tenkey and DP key  yes-> ignore)
		j	nz,back_space_y	;v4.12
		test	(TEN_S).0	;V4.12
		j	t,no_operation	;V4.12
		ld	(TEN_S),0	;V4.12
		j	back_space6	;V4.12
back_space_y:
		@BBC	(F_TNKEY,no_operation)	;V1.36;V2.12
		call	bs_dt_buf	;V4.18	;for #/D entry
		ld	a,(TEN_CT)	
		cmp	a,1
		j	gt,back_space0		;if tenkey entry is over than 1  yes-> normal back space
;in case of first DP entry.........
		@BBC	(F_DPIN,back_space0)	;DP already entered?  no-> normal back space
		call	ten_zerock
		j	nz,back_space0		;if TENKEY is not zero?  yes-> normal back space
		call	ten_clear	;V1.36a
;V4.07		@CLB	(F_DPIN)	;V1.36a
;V4.07		ld	(DT_CT),0	;V1.36a
;V4.07		call	spc_dt		;V1.36a
		j	back_space1		;first enter is '0'?  yes-> clear F_DPIN and TEN_CT
;in case of first DP entry.........

back_space0:
		ld	hl,TENKEY
		call	stg_sfr47		;TENKEY right shift by nibble
		cmp	(DT_CHR_CNT),0		;V1.31
		j	eq,back_space0_1	;V1.31
		dec	(DT_CHR_CNT)		;V1.31
back_space0_1:
		ld	a,(TEN_DP)
		j	nz,back_space2		;DP is not zero  yes-> decrement DP also
back_space1:
		@CLB	(F_DPIN)		;clear DP key entry flag when TEN_DP=0
		j	back_space3
back_space2:
		dec	(TEN_DP)
back_space3:
		dec	(TEN_CT)		;decrement teneky counter
		j	nz,back_space6		;tenkey counter not 0?  yes->exit
		call	ten_clear		;for clear TEN_S
back_space6:
		j	tenkey_end	

;sub routine for #/D.........................
bs_dt_buf:
		call	ten_zerock		;
		j	nz,bs_dt_0		;if TENKEY is not zero?  yes-> right shift until numeric data will find
bs_dt_x:
		cmp	(DT_CT),0		;no entry data?
		j	eq,bs_dt_9		; yes ->
		call	sft_r_dt		;DT_BUF right shift by nibble
		j	bs_dt_9
bs_dt_0:
;V4.17		cmp	(DT_CT),MAX_DIGIT_DT	;if alredy over flow #/D entry count?  yes -> counter decrement only
;V4.17		j	gt,bs_dt_2
		cmp	(DT_CT),MAX_DIGIT_DT+2	;V4.17
		j	gt,bs_dt_2		;V4.17
bs_dt_1:
;V4.12		ld	a,(DT_BUF_LSD)
;V4.12		and	a,0x0f			;check last digit
;V4.12		cmp	a,C_DP			;DP code?
;V4.12		j	ne,bs_dt_x		; no -> shift and exit
;V4.12		cmp	(DT_CT),0		;no entry data?
;V4.12		j	eq,bs_dt_9		; yes ->
		call	sft_r_dt		;DT_BUF right shift by nibble
;V4.12		j	bs_dt_1			;  -> continue shift
;V4.17		j	bs_dt_9		;V4.12
		j	bs_dt_99	;V4.17
bs_dt_2:
		dec	(DT_CT)
bs_dt_9:
		ld	a,(DT_BUF_LSD)	;V1.24
		and	a,0x0f		;V1.24	;check last digit
		cmp	a,0x0c		;V1.24is scapegoat for 0?
		j	eq,bs_dt_x	;V1.24
bs_dt_99:
		ret

;DT_BUF right shift by nibble......
sft_r_dt:
		ld	hl,DT_BUF
		call	stg_sfr49		;shift right by nibble
		or	(DT_BUF_MSD),C_SPC<<4	;padding space on left most digit
		dec	(DT_CT)
sft_r_dt9:
		ret
		
;===============================================================================
;		#/S 
;===============================================================================
sharp_subtl:
		ld	a,(DT_CT)		;#/D number entry counter
		j	z,sharp_subtl0		;with tenkey entry?  no-> jump to subtotal
		ld	(KEYIN),K_SHD		;current key code change to #
		j	sharp_dt0
sharp_subtl0:
		ld	(KEYIN),K_ST		;current key code change to ST
		j	acc_subtl
;===============================================================================
;		#/D
;===============================================================================
sharp_date_obs:
		@BBS	(EURO_PROG,no_operation)
		@BBS	(F_COUNTRY,no_operation)
		ld	(SYM),S_TAX
		call	tax_to_w2
		call	w2_to_ten
		call	keep_ten_6dig
		call	ten_to_w2
		call	w2_print
		ld	(SYM),0x39
		call	tax2_to_w2
		call	w2_to_ten
		call	keep_ten_6dig
		call	ten_to_w2
		call	w2_print
		ld	a,(COUNTRY1)
		ld	(COUNTRY_TEN),a
		call	euro1_to_w2
		call	w2_to_ten
		call	keep_ten_6dig
		call	ten_to_w2
		ld	hl,W2
		call	euro_print
		ld	a,(COUNTRY2)
		ld	(COUNTRY_TEN),a
		call	euro2_to_w2
		call	w2_to_ten
		call	keep_ten_6dig
		call	ten_to_w2
		ld	hl,W2
		call	euro_print
		call	feed_1
		call	ten_clear	;V3.05
		jp	function_end
;-----------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -