在内存地址 0040:0017 处这一个字节表示当前键状态。这一个字节是利用二进制的1或是0来表示键盘状态的。
0表示无开启状态,1表示开启锁定状态。
如果按下某个(4楼hebecoco兄给出的资料)中所示的按键,所示地址 0040:0017 就会被中断例程改写,置示当前的按键状态。
实验:
只有右侧小键盘上的 NumLock (数字输入状态)的灯亮着:
内存地址 0040:0017 处 的 20H ,转成二进制为: 00100000
第 5 位为1(为真)表示开启,其它位均为0。
-d 40:17
0040:0010 20-00 00 32 00 32 00 64 20
0040:0020 20 39 34 05 34 05 08 0E-30 0B 3A 27 31 02 37 08
0040:0030 0D 1C 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0040 AE 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 06 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 EC 71 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10
然后再按一下右键小键盘上的 NumLock 键,关掉数字状态(此时灯不亮了)
00H 转二进制是:00000000 ,全是0,表示未开启。
-d 40:17
0040:0010 00-00 00 2E 00 2E 00 08 0E
0040:0020 08 0E 34 05 30 0B 3A 27-31 02 37 08 0D 1C 37 08
0040:0030 0D 1C 61 1E 08 0E 64 20-20 39 33 04 30 0B 00 00
0040:0040 F2 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 10 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 A8 78 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10
然后按一下左侧键盘上的 CapsLock (启动大写状态),则下面是 40H,
转二进制是:01000000 第6位是1,表示大写启动状态。
-D 40:17
0040:0010 40-00 00 1E 00 1E 00 08 0E
0040:0020 08 0E 34 05 30 0B 3A 27-31 02 37 08 0D 1C 44 20
0040:0030 20 39 34 05 30 0B 3A 27-31 02 37 08 0D 1C 00 00
0040:0040 53 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 1A 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 47 7E 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10
所以,最后用 Debug
E 40:17 40
(Windows CMD 下无效,MS-DOS下有效)
这一个命令就可以直接改写内存地址 0040:0017 处这一个字节的键盘表示状态。
并将键盘改写为大写锁定状态: 二进制位的第6位为 1 ,表是开启功能,则 01000000 的16进制(好读)就是 40,所以把40填进那个内存地址就行了~:)
4楼hebecoco兄给出的 “pokeb(0x40.0x17,0x40)” 是高级语言的操作方法,根据hebecoco兄4楼详细的说明资料,可以用C等可以写、操作内存的高级语言来完成功能~:)
At memory address 0040:0017, there is a byte that represents the current key state. This byte uses binary 1 or 0 to indicate the keyboard state.
0 means no on state, and 1 means on lock state.
If a key as shown in the information from Brother hebecoco on floor 4 is pressed, the shown address 0040:0017 will be rewritten by the interrupt routine to indicate the current key state.
Experiment:
Only the NumLock (numeric input state) light on the right small keyboard is on:
The 20H at memory address 0040:0017, converted to binary: 00100000
The 5th bit is 1 (true) indicating on, and the other bits are all 0.
-d 40:17
0040:0010 20-00 00 32 00 32 00 64 20
0040:0020 20 39 34 05 34 05 08 0E-30 0B 3A 27 31 02 37 08
0040:0030 0D 1C 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0040 AE 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 06 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 EC 71 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10
Then press the NumLock key on the right small keyboard again to turn off the numeric state (at this time the light is off)
00H in binary is: 00000000, all 0s, indicating not on.
-d 40:17
0040:0010 00-00 00 2E 00 2E 00 08 0E
0040:0020 08 0E 34 05 30 0B 3A 27-31 02 37 08 0D 1C 37 08
0040:0030 0D 1C 61 1E 08 0E 64 20-20 39 33 04 30 0B 00 00
0040:0040 F2 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 10 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 A8 78 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10
Then press the CapsLock key on the left keyboard to start the uppercase state, then the following is 40H,
In binary: 01000000 The 6th bit is 1, indicating the uppercase on state.
-D 40:17
0040:0010 40-00 00 1E 00 1E 00 08 0E
0040:0020 08 0E 34 05 30 0B 3A 27-31 02 37 08 0D 1C 44 20
0040:0030 20 39 34 05 30 0B 3A 27-31 02 37 08 0D 1C 00 00
0040:0040 53 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 1A 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 47 7E 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10
So finally use Debug
E 40:17 40
(Invalid under Windows CMD, valid under MS-DOS)
This command can directly rewrite the keyboard representation state of the byte at memory address 0040:0017.
And set the keyboard to the uppercase lock state: the 6th bit of the binary is 1, indicating the on function, then 01000000 in hexadecimal (for easy reading) is 40, so fill 40 into that memory address~:)
Brother hebecoco on floor 4 gave "pokeb(0x40.0x17,0x40)" which is the operation method in high-level languages. According to Brother hebecoco's detailed explanation on floor 4, it can be completed in high-level languages like C that can write and operate memory~:)