Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; goto label
- .model tiny
- .386
- .code
- org 100h
- start:
- pusha
- lea dx, start_msg
- mov ah, 09h
- int 21h
- push 40h
- pop es
- mlp:
- mov di, es:[1Ah] ;DI <- BEGIN
- mov dx, es:[1Ch] ;DX <- END
- l: cmp dx, di
- je mlp
- call reader
- cmp EXIT_FLAG, 01h
- jne mlp
- popa
- ret
- start_msg db "PRESS ANY KEY", '$'
- EXIT_FLAG db 0
- KB_BEGIN equ 1Eh
- KB_END equ 1Eh + 20h
- reader: ;READ KB BUFFER [DI, DX), DX != DI
- mov bx, es:[di]
- mov ax, 03
- int 10h
- call process
- call print_shift
- add di, 2
- cmp di, KB_END ;eobuffer
- jne skip
- mov di, KB_BEGIN
- skip:
- cmp dx, di
- jne reader
- mov es:[1Ah], di
- ret
- L_0 equ 0FAh
- L_1 equ 0FEh
- msg db "INSERT LOCKED ", "_", 13, 10,\
- "CAPS LOCK LOCKED ", "_", 13, 10,\
- "NUM LOCK LOCKED ", "_", 13, 10,\
- "SCROLL LOCK LOCKED ", "_", 13, 10,\
- "ALT KEY IS PRESSED ", "_", 13, 10,\
- "CTRL KEY IS PRESSED ", "_", 13, 10,\
- "LEFT SHIFT KEY IS PRESSED ", "_", 13, 10,\
- "RIGHT SHIFT KEY IS PRESSED ", "_", 13, 10, '$'
- print_shift:
- push bx
- push di
- push dx
- push es
- mov bx, es:[17h]
- push cs
- pop es
- lea di, msg
- add di, 27 + 7 * 30
- mov cx, 8
- fill:
- mov ax, 1
- and ax, bx
- ror bx, 1
- cmp al, 1
- je c1
- c0: mov al, L_0
- jmp ce
- c1: mov al, L_1
- ce: stosb
- sub di, 31
- loop fill
- lea dx, msg
- mov ah, 09h
- int 21h
- pop es
- pop dx
- pop di
- pop bx
- ret
- output db "SCAN CODE: __; ASCII: _", 13, 10, 13, 10, '$'
- process:
- push di
- push dx
- push es
- push cs
- pop es
- lea di, output
- add di, 11
- ror bx, 8
- call h2
- add di, 9
- mov byte ptr [di], bh
- lea dx, output
- mov ah, 09h
- int 21h
- mov EXIT_FLAG, bl
- pop es
- pop dx
- pop di
- ret
- h4: ;ES:DI <- hex of BX
- ror bx, 8
- call h2
- ror bx, 8
- h2: ;ES:DI <- hex of BL
- mov al, bl
- shr al, 4
- cmp al, 10
- sbb al, 69h
- das ;AL = hex of BL (h)
- cld ;DF = 0 (DI++, SI++ on str ops)
- stosb ;ES:DI <- AL
- mov al, bl
- and al, 0Fh
- cmp al, 10
- sbb al, 69h
- das ;AL = hex of BL (l)
- stosb ;ES:DI <- AL
- ret
- end start
- ; :label
- ; tasm /m5 kb.bat
- ; tlink /x/t kb.obj
- ; del kb.obj
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement