键盘中断如何始终在端口 60 上访问?

发布于 2025-01-11 00:39:57 字数 805 浏览 6 评论 0原文

我正在学习操作系统和引导加载程序。我发现,要读取键盘按键,可以使用端口 60 的 in 汇编助记符。即使在编写在现代计算机上运行的低级汇编程序时,这也有效。

我正在阅读

keyhandler:
   in al, 0x60   ; get key data
   mov bl, al   ; save it
   mov byte [port60], al
 
   in al, 0x61   ; keybrd control
   mov ah, al
   or al, 0x80   ; disable bit 7
   out 0x61, al   ; send it back
   xchg ah, al   ; get original
   out 0x61, al   ; send that back
 
   mov al, 0x20   ; End of Interrupt
   out 0x20, al   ;
 
   and bl, 0x80   ; key released
   jnz done   ; don't repeat
 
   mov ax, [port60]
   mov  word [reg16], ax
   call printreg16

机器如何知道将插入例如任意 USB 连接器的键盘路由到端口 60,以便程序员可以访问它?

I am in the process of learning about operating systems and bootloaders. I have found that, to read keyboard keypresses, one can use the in assembly mnemonic with port 60. This works even when writing low-level assembly programs running on a modern machine.

I was reading this article on the topic, in order to better understand this snippet:

keyhandler:
   in al, 0x60   ; get key data
   mov bl, al   ; save it
   mov byte [port60], al
 
   in al, 0x61   ; keybrd control
   mov ah, al
   or al, 0x80   ; disable bit 7
   out 0x61, al   ; send it back
   xchg ah, al   ; get original
   out 0x61, al   ; send that back
 
   mov al, 0x20   ; End of Interrupt
   out 0x20, al   ;
 
   and bl, 0x80   ; key released
   jnz done   ; don't repeat
 
   mov ax, [port60]
   mov  word [reg16], ax
   call printreg16

How does the machine know to route a keyboard plugged into, for example, an arbitrary USB connector to port 60 so it is accessible for the programmer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文