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

📄 usbkbd.asm

📁 AMI 主板的BIOS源码。
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	jnz	gc_41		; Control key on
;-------------------------------;
;	BaseCase PAUSE key	;
;-------------------------------;
	mov	al,0e1h
	call	put_char_buffer	; E1
	mov	tl0,14h
	call	make_code_1	; 14
	mov	tl0,77h
	call	make_code_1	; 77
	mov	al,0e1h
	call	put_char_buffer	; E1
	mov	tl0,14h
	call	break_code_1	; F0,14
	mov	tl0,77h
	call	break_code_1	; F0,77
	jmp	gc_over
;-------------------------------;
;	CtrlCase PAUSE key	;
;-------------------------------;
gc_41:
	mov	tl0,7eh		; PAUSE scan code set 2
	call	make_code_2	; E0,7E
	call	break_code_2	; E0,F0,7E
	jmp	gc_over
;-------------------------------;
gc_40:
	cmp	al,prtsc
	jnz	gc_45
	mov	tl0,7ch		; PRTSC scan code set 2
	test	flag_byte,alt_key_bitx
	jnz	gc_46
	test	flag_byte,ctl_key_bitx+left_shift_bitx+right_shift_bitx
	jnz	gc_43
;-------------------------------;
;	BaseCase PRTSC key	;
;-------------------------------;
;	NumLockCase NUM key pad	;
;-------------------------------;
;(E0,12,E0,xx)(E0,F0,xx,E0,F0,12)
;-------------------------------;
gc_57:
	cmp	make_break_flag,'m'
	jnz	gc_58		; break code
	mov	al,tl0		; save scan code set-2
	push	ax
	mov	tl0,12h
	call	make_code_2	; E0,12
	pop	ax
	mov	tl0,al		; restore scan code set-2
gc_53:
	call	make_code_2	; E0,TL0
	jmp	gc_over
gc_58:
	call	break_code_2	; E0,F0,TL0
	mov	tl0,12h
gc_54:
	call	break_code_2	; E0,F0,12
	jmp	gc_over
;-------------------------------;
;	AltCase PRTSC key	;
;-------------------------------;
gc_46:
	mov	tl0,84h		; ALT PRTSC scan code set-2
;-------------------------------;
;	regular MAKE/BREAK	;
;-------------------------------;
;	(xx)(F0,xx)		;
;-------------------------------;
gc_59:
	cmp	make_break_flag,'m'; 0/2 = make/break
	jnz	gc_60
	call	make_code_1	; TL0
	jmp	gc_over
gc_60:
	call	break_code_1	; F0,TL0
	jmp	gc_over
;-------NUMERIC KEY-------------;
gc_45:
	call	check_get_num_key_pad
	jc	gc_48		; not inside num key pad
	and	tl0,7fh
	test	flag_byte,num_lock_bitx+left_shift_bitx+right_shift_bitx
	jz	gc_43		; (E0,xx)(E0,F0,xx)
	test	flag_byte,num_lock_bitx
	jnz	gc_57		; (E0,12,E0,xx)(E0,F0,xx,E0,F0,12)
;-------------------------------;
;	ShiftCase NUM KEY pad	;
;-------------------------------;
;(E0,F0,12/59,E0,xx)(E0,F0,xx,E0,12/59)
;-------------------------------;
gc_52:
	cmp	make_break_flag,'m'; 0/2 = make/break
	jnz	gc_51		; break code
	mov	al,tl0		; save scan code set-2
	push	ax
	call	break_code_left	; E0,F0,12
	call	break_code_right; E0,F0,59
	pop	ax
	mov	tl0,al		; restore scan code set-2
	call	make_code_2	; E0,TL0
	jmp	gc_over
gc_51:
	call	break_code_2	; E0,F0,TL0
	call	make_code_right	; E0,59
	call	make_code_left	; E0,12
	jmp	gc_over
;-------EXTENDED KEY------------;
gc_48:
	call	check_get_extd_key
	jc	gc_55		; not inside extended key
	and	tl0,7fh
;------ MAKE/BREAK EXTENDED ----;
;-------------------------------;
;	Ctrl/ShiftCase PRTSC	;
;-------------------------------;
;	BaseCase NUM KEY pad	;
;-------------------------------;
;	(E0,xx)(E0,F0,xx)	;
;-------------------------------;
gc_43:
	cmp	make_break_flag,'m'
	jnz	gc_54		; break code
	jmp	gc_53		; make code
;-------------------------------;
gc_55:
	cmp	tl0,slash	; scan code set 2
	jnz	gc_59		; regular key
;-------------------------------;
;	extended '/' key	;
;-------------------------------;
	mov	tl0,4ah		; '/' key scan code set 2
	test	flag_byte,left_shift_bitx+right_shift_bitx
	jz	gc_43		; (E0,xx)(E0,F0,xx)
	jmp	gc_52		; (E0,F0,12/59,E0,XX)(E0,F0,XX,E0,12/59)
;-------------------------------;
gc_over:
	popa
	ret
;-------------------------------;
;	CHECK_ALT_CTRL_SHIFT	;
;-------------------------------;
; registers used (ch,cl)	;
;-------------------------------;
; input: (al) = scan code 2	;
; output: (zf) = 1 ; not found	;
;		 0 ; found	;
;	  (ch,cl) = code	;
;-------------------------------;
check_alt_ctrl_shift:
	mov	ch,00h
	cmp	al,lsht
	jnz	acs_1
	mov	ch,left_shift_bitx
acs_1:
	cmp	al,rsht
	jnz	acs_2
	mov	ch,right_shift_bitx
acs_2:
	cmp	al,lctl
	jnz	acs_3
	mov	ch,ctl_key_bitx
	mov	cl,rctl
acs_3:
	cmp	al,rctl
	jnz	acs_4
	mov	ch,ctl_key_bitx
	mov	cl,lctl
acs_4:
	cmp	al,lalt
	jnz	acs_5
	mov	ch,alt_key_bitx
	mov	cl,ralt
acs_5:
	cmp	al,ralt
	jnz	acs_6
	mov	ch,alt_key_bitx
	mov	cl,lalt
acs_6:
	or	ch,ch
	ret
;-------------------------------;
; GET_SCAN_CODE_2		;
;-------------------------------;
get_scan_code_2:
	push	bx
	mov	bx,offset cgroup:USBKeyCode_to_Scan_2_table+orgbase
	db	2eh		; CS:
	xlat
	pop	bx
	ret
;-------------------------------;
; GET_SCAN_CODE_3		;
;-------------------------------;
get_scan_code_3:
	push	bx
	mov	bx,offset cgroup:set_2_to_3+orgbase
	jmp	gsc_1_3
;-------------------------------;
; GET_SCAN_CODE_1		;
;-------------------------------;
get_scan_code_1:
	push	bx
	mov	bx,offset cgroup:set_2_to_1+orgbase
gsc_1_3:
	db	2eh		; CS:
	xlat
	mov	ah,al
	and	ax,0ff0h
	shr	ax,4
	rol	al,1
	not	al
	pop	bx
	ret
;-------------------------------;
; CHECK_GET_NUM_KEY_PAD		;
;-------------------------------;
; registers used: (ah,bx,al)	;
; input:			;
;	(TL0) = scan code set 2	;
; output:			;
;	(cf) = 1, not found	;
;	(cf) = 0, found		;
;	      (al) = scan 3 data;
;-------------------------------;
check_get_num_key_pad:
	mov	bx,offset cgroup:key_pad_scan_2_table - 1 +orgbase
	mov	ah,offset key_pad_scan_2_table_end-offset key_pad_scan_2_table
cnkp_1:
	mov	al,ah
	db	2eh		; CS:
	xlat			; get scan-2 code for extended key
	xor	al,tl0		; (tl0) = current scan code-2
	jz	cnkp_2		; found
	dec	ah
	jnz	cnkp_1
	stc
	ret
cnkp_2:
	mov	bx,offset cgroup:key_pad_scan_3_table - 1 +orgbase
	mov	al,ah
	db	2eh		; CS:
	xlat			; scan code 3
	clc
	ret
;-------------------------------;
; CHECK_GET_EXTD_KEY		;
;-------------------------------;
; registers used: (ah,bx,al)	;
; input:			;
;	(TL0) = scan code set 2	;
; output:			;
;	(cf) = 1, not found	;
;	(cf) = 0, found		;
;	      (al) = scan 3 data;
;-------------------------------;
check_get_extd_key:
	mov	bx,offset cgroup:extd_key_scan_2_table - 1 +orgbase
	mov	ah,offset extd_key_scan_2_table_end-offset extd_key_scan_2_table
cnkp_3:
	mov	al,ah
	db	2eh		; CS:
	xlat			; get scan-2 code for extended key
	xor	al,tl0		; (tl0) = current scan code-2
	jz	cnkp_4		; found
	dec	ah
	jnz	cnkp_3
	stc
	ret
cnkp_4:
	mov	bx,offset cgroup:extd_key_scan_3_table - 1 +orgbase
	mov	al,ah
	db	2eh		; CS:
	xlat			; scan code 3
	clc
	ret
;-------------------------------;
; CHECK_GET_EXTD_SCAN_3_NEW	;
;-------------------------------;
; registers used: (ah,bx,al)	;
; input:			;
;	th0 = scan code set 3;
; output:			;
;	(cf) = 1, not found	;
;	(cf) = 0, found		;
;	      (al) = scan 3 index
;-------------------------------;
check_get_extd_scan_3_new:
	mov	bx,offset cgroup:extd_scan_3_data - 1 +orgbase
	mov	ah,offset extd_scan_3_data_end-offset extd_scan_3_data
cnkp_5:
	mov	al,ah
	db	2eh		; CS:
	xlat			; get scan-3 code for extended key
	xor	al,th0		; (buffer) = current scan code-3
	jz	cnkp_6		; found
	dec	ah
	jnz	cnkp_5
	stc
	ret
cnkp_6:
	mov	bx,offset cgroup:extd_scan_3_new - 1 +orgbase
	mov	al,ah
	db	2eh		; CS:
	xlat			; scan code 3 index
	clc
	ret
;-------------------------------;
; MAKE CODE LEFT (LEFT SHIFT)	;
; MAKE CODE RIGHT (RIGHT SHIFT)	;
; BREAK CODE LEFT (LEFT SHIFT)	;
; BREAK CODE RIGHT (RIGHT SHIFT);
;-------------------------------;
; registers used: (al,TL0,ah)	;
; input:			;
;	none.			;
; output:			;
;	none.			;
; code generated:		;
;	E0,12			;
;	E0,59			;
;	E0,F0,12		;
;	E0,F0,59		;
;-------------------------------;
make_code_left:
	test	flag_byte,left_shift_bitx
	jz	mblr_1
	mov	tl0,12h
	jmp	make_code_2	; E0,12
make_code_right:
	test	flag_byte,right_shift_bitx
	jz	mblr_1
	mov	tl0,59h
	jmp	make_code_2	; E0,59
break_code_left:
	test	flag_byte,left_shift_bitx
	jz	mblr_1
	mov	tl0,12h
	jmp	break_code_2	; E0,F0,12
break_code_right:
	test	flag_byte,right_shift_bitx
	jz	mblr_1
	mov	tl0,59h
	jmp	break_code_2	; E0,F0,59
mblr_1:
	or	sp,sp		; (zf) = 0
	ret
;-------------------------------;
; BREAK CODE 2			;
; BREAK CODE 1			;
; MAKE CODE 2			;
; MAKE CODE 1			;
;-------------------------------;
; registers used: (al,ah)	;
; input:			;
;	(TL0) = scan code set-2	;
; output:			;
;	none.			;
; generated code:		;
;	E0,F0,TL0		;
;	TL0			;
;	E0,TL0			;
;	TL0			;
;-------------------------------;
break_code_2:
	mov	al,0e0h
	call	put_char_buffer	; E0
break_code_1:
	mov	al,scanner_flag
	and	al,03h		; possible value = scan code set-1/2
	cmp	al,02h
	jnz	mcbc_1		; scan code set-1
	test	ccb,40h
	jnz	mcbc_1		; conversion required
	mov	al,0f0h
	call	put_char_buffer	; F0
mcbc_3:
	mov	al,tl0
	jmp	put_char_buffer	; no conversion
mcbc_1:
	mov	al,tl0
	call	get_scan_code_1	; get scan code set-1
	or	al,80h
	jmp	put_char_buffer	; break code
make_code_2:
	mov	al,0e0h
	call	put_char_buffer	; E0
make_code_1:
	mov	al,scanner_flag
	and	al,03h		; possible value = scan code set-1/2
	cmp	al,02h
	jnz	mcbc_2		; scan code set-1
	test	ccb,40h
	jz	mcbc_3		; no conversion
mcbc_2:
	mov	al,tl0
	call	get_scan_code_1	; get scan code set-1
	jmp	put_char_buffer
;-------------------------------;
; WRITE CODE 3 VALUE		;
;-------------------------------;
; registers used (bx,ax)	;
; input:			;
;	(al) = scan code-3	;
;		(00..7F)	;
;	(ah) = action value	;
;		(0,1,2,3)	;
; output:			;
;	none.			;
;	action value written in	;
;	corresponding memory	;
;-------------------------------;
write_code_3_value:
	push	cx
	push	ax
	call	read_code_3_value	; A, BUFFER
	mov	cl,al
	pop	ax
	and	al,03h
	inc	al
	xchg	al,cl
	and	al,0fch		; clear last 2 bits
	or	al,ah		; insert new value
	jmp	wc3v_1
wc3v_2:
	rol	al,2		; position 2 bits
wc3v_1:
	dec	cl
	jnz	wc3v_2
	mov	[bx],al		; write back action value
	pop	cx
	ret
;-------------------------------;
; READ CODE 3 VALUE		;
;-------------------------------;
; registers used (bx,ax)	;
; input:			;
;	(al) = scan code-3	;
;		(00..7F)	;
; output:			;
;	(bx) = address		;
;	(al) = scan code-3 action;
;		in bit-1,0	;
;		xxxx xx..	;
;-------------------------------;
read_code_3_value:
	push	cx
	mov	cl,al
	and	al,03		; 0,1,2,3
	inc	al		; 1,2,3,4
	xchg	al,cl
	ror	al,2		; prepare index
	and	al,1fh		; memory address 00..1F
	cbw
	add	ax,offset scan_3_table
	mov	bx,ax		; return value
	mov	al,[bx]
	jmp	rc3v_1
rc3v_2:
	ror	al,2		; position 2 bits
rc3v_1:
	dec	cl
	jnz	rc3v_2
	pop	cx
	ret
;-------------------------------;
; CHECK CHARACTER BUFFER FULL	;
;-------------------------------;
; register used (al).		;
; input:			;
; al = # bytes needed		;
; output:			;
; (zf) = 1, buffer full		;
; (zf) = 0, buffer not full.	;
; (al) changed			;
;-------------------------------;
check_cbfull:
	push	bx
	mov	bx,ch_buff_head	; check for character buffer full
	inc	al		; 1 more byte for overrun character

⌨️ 快捷键说明

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