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

📄 key.asm

📁 calculator code ,use toshibaor nec LSI
💻 ASM
📖 第 1 页 / 共 3 页
字号:
		jp	key_scan99	;/
key_scan_01:
	ld	wa,EP_ACCES
	test	(EP_ACCES>>4).a		;bit -reverse-> jump status
	j	f,key_scan99		;if jump status is 0 -> branch
;V2.13		call	feed_check		
	ld	wa,F_KON
	test	(F_KON>>4).a		;bit -reverse-> jump status
	j	f,key_scan_02		;if jump status is 0 -> branch
;V1.39key_scan_01x:				
		call	mdsw_scan		
		call	update_mdsw		;for remove mode sw chattaring
key_scan_02:
;V4.11		@BBS	(SW_OFF_RT,key_scan90)	;power sw move to OFF mode? yes -> exit
;V4.11		@BBS	(F_OFF,key_scan90)	;if OFF mode? yes -> exit
	ld	wa,IO_MT
	test	(IO_MT>>4).a		;bit -reverse-> jump status
	j	f,key_scan_03		;if jump status is 0 -> branch
	ld	wa,F_DOFF
	test	(F_DOFF>>4).a		;bit -reverse-> jump status
	j	f,key_scan_03		;if jump status is 0 -> branch
		cmp	(OFF_CT),0		
		j	eq,key_scan_030		
		dec	(OFF_CT)		
		jp	key_scan_03		
key_scan_030:
		call	vft_enable		
key_scan_03:		
		ld	b,(P1PRD)	
	ld	wa,F_KON
	test	(F_KON>>4).a		;bit -reverse-> jump status
	j	f,key_scan20		;if jump status is 0 -> branch
		and	b,0y00111111		;
		j	z,key_scan90		;no key press   yes->

;Detect key press...............................
		ld	c,0xff;V1.01
;V3.00		swap	b
		;--------------------------------------------------------------
key_scan12:;V1.01		
;V3.00		shlc	b		;shift current key return
		shrc	b
		inc	c		;count which bit is high in register b
		j	cc,key_scan12	
		;--------------------------------------------------------------
		ld	hl,tbl_rtndt	;\
		ld	b,(hl+c)	;|key return (matrix vertical)-->RET_BK
		ld	(RET_BK),b	;/
		ld	a,(SCAN_CT)	;\
		ld	(SCAN_BK),a	;/key scan (matrix horizontal)-->SCAN_BK 
		ld	(KI_CT),KON_TIM
	ld	wa,F_KON
	set	(F_KON>>4).a
		ld	(BLK_CT),0	
		j	key_scan90

;Key on check...................................
key_scan20:
		ld	a,(SCAN_CT)		;whether the same key keep in pressing
		cmp	a,(SCAN_BK)		;//
		j	ne,key_scan90		;/different scan line?  yes-> exit
	ld	wa,F_KOFF
	test	(F_KOFF>>4).a		;bit -reverse-> jump status
	j	f,key_scan30		;if jump status is 0 -> branch
		and	b,0y00111111		;reg.b = current key return
		j	z,key_scan32		;for make sure
		and	b,(RET_BK)		;previous key on continue?
		j	z,key_scan32		;If chataling?  yes->
		dec	(KI_CT)
		j	nz,key_scan90		
		ld	(KI_CT),KOFF_TIM	;detect key on?
	ld	wa,F_KOFF
	set	(F_KOFF>>4).a
		
;Key code calculation...........................
		ld	c,0xff
key_scan22:	
		shrc	b	;shift current key return
		inc	c		;reg.c = lower 2bit of key code
		j	cc,key_scan22
		ld	a,(SCAN_CT)
;V3.00		shlc	a		;--ax4
;V3.00		shlc	a		;/
;V3.00		or	a,c		;reg.a = key code
		ld	w,6		;V3.00
		mul	w,a		;V3.00
		clr	cf		;V3.00
		add	a,c		;V3.00
		ld	c,a
		ld	hl,key_conver_tbl
		ld	a,(hl+c)
		cmp	(KEY_CT),64	;\
		j	ge,key_scan32	;/key buffer over flow?
		ld	c,(KEY_WPTR)
		and	c,0x3f
		ld	hl,KEY_BUF	;key buffer first address-->hl
		ld	(hl+c),a	;store key code to KEY_BUF
		inc	c
		and	c,0x3f
		ld	(KEY_WPTR),c
		inc	(KEY_CT)
		j	key_scan90
		
;Key off check..................................
key_scan30:
;---------------------------------------------------
		and	b,0y00111111		;reg.b = current key return
		and	b,(RET_BK)		;previous key on continue?
		j	z,key_scan_h9		; key released ->
		;-------------------------------------
;V3.00		@BBC	(RTC_ON,key_scan_set0)	;V1.23
;V3.00		cmp	b,RET_SET
;V3.00		j	eq,key_scan_h1
;V3.00key_scan_set0:					;V1.23
;V3.00		@BBS	(RTC_ON,key_scan90)	;V1.44
;V3.00		@BBC	(SW_V15,key_scan_set1)	;V1.23
;V3.00		cmp	b,RET_IC		;V1.23
;V3.00		j	eq,key_scan_h2		;V1.23
;V3.00key_scan_set1:					;V1.23
;V3.00		;--------------------------
;V3.00		@BBS	(ICON_E,key_scan90)	;V1.08

;V1.04		@BBS	(F_RATE,key_scan90)	;is RATE key holded?
;V3.00		@BBS	(RATE_PROG,key_scan90)	;already enter into rate setting mode?
;V3.00		@BBS	(IC_PROG,key_scan90)	;V1.44
;V3.00key_scan_set1y:						;V1.28
;V3.00		cmp	b,RET_RATE		;is rate key?
;V3.00key_scan_set1z:
;V3.00		j	ne,key_scan90		;yes-->
;V3.00		cmp	(SCAN_CT),SCAN_RATE
;V3.00key_scan_set1f:
;V3.00		j	ne,key_scan90
;V3.00		dec	(DW_CT)
;V3.00		j	ne,key_scan90
;V3.00		@SEB	(RATE_PROG)		;enter into rate setting mode
;V3.00		j	key_scan90
		;--------------------------------
;V3.00key_scan_h0:
;V3.00		cmp	(SCAN_CT),SCAN_FEED
;V3.00		j	ne,key_scan90
;V3.00		@SEB	(F_HLD_FED)
;V3.00		j	key_scan90
		;--------------------------------
;V3.00key_scan_h1:
;V3.00		@BBC	(RTC_ON,key_scan90)	;V1.18
;V3.00		cmp	(SCAN_CT),SCAN_SET	;V1.18
;V3.00		j	ne,key_scan90		;V1.18
;V3.00		@SEB	(F_HLD_SET)		;V1.18
;V3.00		dec	(DW_CT)			;V1.18
;V3.00		j	key_scan90		;V1.18
		;--------------------------------
;V3.00key_scan_h2:					;V1.23
;V3.00		@BBS	(F_ICDSP,key_scan_h2x)	;V1.23
;V3.00		jp	key_scan90		;V1.23
;V3.00key_scan_h2x:					;V1.23
;V3.00		cmp	(SCAN_CT),SCAN_IC	;V1.23
;V3.00		j	ne,key_scan90		;V1.23
;V3.00		@SEB	(F_HLD_SET)		;V1.23
;V3.00		dec	(DW_CT)			;V1.23
;V3.00		j	ne,key_scan90		;V1.23
;V3.00		@SEB	(IC_PROG)		;V1.23
		j	key_scan90		;V1.23
		;--------------------------------
key_scan_h9:
;V1.04		@CLB	(RATE_PROG)		;for rate set
;V3.00		@CLB	(F_HLD_FED)		;for feed key
;V3.00		@CLB	(F_HLD_SET)		;for time set
		dec	(KI_CT)
		j	nz,key_scan90		
;Key check end.................................
key_scan32:
	ld	wa,F_KOFF
	clr	(F_KOFF>>4).a
	ld	wa,F_KON
	clr	(F_KON>>4).a
		ld	(DW_CT),0	;V1.23
;Output next scan signal.......................
key_scan90:
		ld	c,(SCAN_CT)
		inc	c
		cmp	c,8
		j	lt,key_scan92
		call	blink_vfd	;V2.05
key_scan91:					;V1.04
		ld	c,0
key_scan92:
		ld	(SCAN_CT),c
		ld	hl,tbl_scan
		ld	a,(hl+c)
		ld	(P9DR),a
key_scan99:
	pop	iy
	pop	ix
	pop	hl
	pop	de
	pop	bc
	pop	wa
		reti

tbl_rtndt:
;		db	0y00000001
;		db	0y00000010
;		db	0y00000100
;		db	0y00001000
;		db	0y00010000
;		db	0y00100000
;		db	0y01000000
;		db	0y10000000

		;	  PPPPPPPP
		;	  99999999
tbl_scan:	;	  76543210        SCAN_CT
		db	0y00000001		;0
		db	0y00000010		;1
		db	0y00000100		;2
		db	0y00001000		;3
		db	0y00010000		;4
		db	0y00100000		;5
		db	0y01000000		;6
		db	0y10000000		;7



;=====================================================
;detect the mode retan and update the MDSW
;-----------------------------------------------------
;V3.00feed_check:					;V2.13
;V3.00		cmp	(SCAN_CT),2
;V3.00		j	ne,feed_check_end
;V3.00		@BBC	(SLID_RT2,feed_check_end)	
;V3.00		nop
;V3.00		nop
;V3.00		nop
;V3.00		@BBC	(SLID_RT2,feed_check_end)
;V3.00		@SEB	(PAPER_FEED)
;V3.00		ret
;V3.00feed_check_end:
;V3.00		@CLB	(PAPER_FEED)
;V3.00		ret
;------------------------------------------------V2.13

;scan out:	_______HH___________
;return in:	_______HH___________
;
mdsw_scan:
		ld	a,(SCAN_CT)
		ld	cf,(P5DR).0		;check mode return0 (P50)
		ld	(MDSW).a,cf		;set mode switch status
		
		ld	cf,(P5DR).1		;check mode return1 (P51)
		ld	(MDSW+1).a,cf		;set mode switch status
		
		ld	cf,(P5DR).2		;check mode return2 (P52)	
		ld	(MDSW+2).a,cf		;set mode switch status		

		ld	cf,(P5DR).3		;check mode return3 (P53)	
		ld	(MDSW+3).a,cf		;set mode switch status			
		ret

;-------------------------------------------------------------
initial_mdsw_update:
	ld	(SCAN_CT),0
initial_mdsw_update_1:
	ld	c,(SCAN_CT)	;V1.30
	ld	hl,tbl_scan	;v1.30
	ld	a,(hl+c)	;V1.30
	ld	(P9DR),a	;V1.30
	call	mdsw_scan
	inc	(SCAN_CT)
	cmp	(SCAN_CT),8
	j	lt,initial_mdsw_update_1
	ld	(SCAN_CT),0		;V2.13
	ld	a,(MDSW)
	ld	(MDBK),a
	ld	(MDFLG),a
	ld	(MDFLG_RT),a

	ld	a,(MDSW+1)
	ld	(MDBK+1),a
	ld	(MDFLG+1),a
	ld	(MDFLG_RT+1),a

	ld	a,(MDSW+2)
	ld	(MDBK+2),a
	ld	(MDFLG+2),a
	ld	(MDFLG_RT+2),a

	ld	a,(MDSW+3)
	ld	(MDBK+3),a
	ld	(MDFLG+3),a
	ld	(MDFLG_RT+3),a
	call	update_md
	call	calc_dp_pos	;V1.30
	ret
;------------------------------------------------------
;Mode swith update for remove chattaring.................
update_mdsw:
		ld	a,(SCAN_CT)		;mode sw is updated when SCAN_CT=0 only
		j	nz,up_mdsw9
mdsw_update:
		ld	c,4-1			;\
up_mdsw0:					;|
		ld	hl,MDSW			;|mode switch start address->hl	
		ld	a,(hl+c)		;|
		ld	hl,MDBK			;|
		cmp	a,(hl+c)		;|MDBK=MDSW?
		j	ne,up_mdsw2		;|not match compare with MDSW and MDBK-->
		dec	c			;|
		j	f,up_mdsw0		;/
						
		ld	a,(MDCHK)		;\
		j	z,up_mdsw9		;|register MDCHK=0?
		dec	(MDCHK)			;|
		j	nz,up_mdsw9		;/
		ld	c,4-1			;
up_mdsw1:					;\
		ld	hl,MDBK			;|MDFLG_RT update
		ld	a,(hl+c)		;|MDBK-->MDFLG_RT
		ld	hl,MDFLG_RT		;|
		ld	(hl+c),a		;|
		dec	c			;|
		j	f,up_mdsw1		;/
		;---------------calculate the decimal position-----------------
calc_dp_pos:					;V1.30
		ld	c,0		;\
		ld	a,(MDFLG_RT)	;|MDFLG_RT        bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
up_mdsw12:				;|relation dp: F   AM   6    5    4    3     2    1   0
		push	wa		;V1.27
	ld	wa,DP_UPDATE
	set	(DP_UPDATE>>4).a
		pop	wa		;V1.27
		shrc	a		;|
		j	cs,up_mdsw15	;|
		inc	c		;|
		cmp	c,8		;|
		j	lt,up_mdsw12	;|
up_mdsw15:				;|
		ld	hl,tbl_dppos	;|
		ld	a,(hl+c)	;|
		ld	(DP_POS_RT),a	;|	;DP_POS_RT update
		j	up_mdsw9	;/
		;--------------------------------------------------------------
up_mdsw2:
		ld	c,4-1		;\
up_mdsw3:				;|
		ld	hl,MDSW		;|MDBK update
		ld	a,(hl+c)	;|MDSW-->MSBK
		ld	hl,MDBK		;|
		ld	(hl+c),a	;|	
		dec	c		;|
		j	f,up_mdsw3	;/
		ld	(MDCHK),MD_TIM	
up_mdsw9:
		ret

tbl_dppos:
		db	0		;DP0
		db	1		;DP1
		db	2		;DP2
		db	3		;DP3
		db	4		;DP4
		db	5		;DP5
		db	6		;DP6
		db	2		;ADM
		db	0		;FDP(in case of no any DP flags on)

key_conver_tbl:
	db	K_MPL		;0x20
	db	K_MMI		;0x21
	db	K_MST		;0x22
	db	K_MTL		;0x23
	db	K_PER		;0x17
	db	K_DIV		;0x19
	db	K_RATE		;0x28
	db	K_IC		;0x1f
	db	K_TXP		;0x29
	db	K_TXM		;0x2a
	db	K_MUL		;0x18
	db	K_EQU		;0x16
	db	K_PLS		;0x10
	db	K_MIN		;0x11
	db	K_ST		;0x12
	db	K_TL		;0x13
	db	K_ROOT		;0x27
	db	K_MU		;0x1a
	db	0x03		;0x03
	db	0x06		;0x06
	db	0x09		;0x09
	db	K_DP		;0x0c
	db	K_TX2P		;0x14
	db	K_TX2M		;0x15
	db	0x02		;0x02
	db	0x05		;0x05
	db	0x08		;0x08
	db	K_ZERO3		;0x0b
	db	K_BS		;0x1d
	db	K_M2TL		;0x2f
	db	0x01		;0x01
	db	0x04		;0x04
	db	0x07		;0x07
	db	K_ZERO2		;0x0a
	db	K_MGR		;0x26
	db	K_M2ST		;0x2e
	db	K_PERPLS	;0x2b
	db	K_DLT		;0x1b
	db	K_SGN		;0x1c
	db	K_ZERO		;0x00
	db	K_SEL		;0x25
	db	K_M2MI		;0x2d
	db	K_GT		;0x0f
	db	K_CE		;0x0d
	db	K_SHD		;0x1e
	db	K_CEC		;0x0e
	db	K_CST		;0x24
	db	K_M2PL		;0x2c

	end

⌨️ 快捷键说明

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