如何确定计算机是否装配有XT / AT键盘?

我刚写完我的16位操作系统,但我用int 0x16来告诉用户按下了哪个键。 现在我想写我自己的键盘驱动程序,我不想使用任何中断。 (这样我可以进入长时间模式)。 我意识到有两个扫描码AT和XT。 我如何确定计算机在NASM x86程序集中使用哪个键盘?

我应该让用户按下一个键并确定在操作系统启动时使用端口0x60中的扫描代码吗?
例如:一个密钥 - 0x1c(make)用于AT,0x1e(make)用于XT
但Linux不这样做.......

我用下面的代码,发现虚拟框使用XT键盘....

[org 0x2e00]

mov bx, 0x1000
mov ds, bx      ;The program is loaded at 0x12e00 or 1000:2e00 by the operating system

    xor ax, ax  ;Set AX to zero
    mov bl, 0x0e    ;Set text color 

loop:           ;Main loop

    in al, 0x60 ;Read all ports and display them
    mov cx, ax
    call hex_print  ;Print content of the port in hex
    in al, 0x61
    mov cx, ax
    call hex_print
    in al, 0x62
    mov cx, ax
    call hex_print
    in al, 0x63
    mov cx, ax
    call hex_print
    in al, 0x64
    call hex_print
    call com_cls    ;Clear the screen after printing content
    jmp loop    ;Jump to loop


;Print hex values;;;;;;;;;;;;;;;;;
hex_print:
    push ax
    push cx
    mov ah, 0x0e
    mov al, ' '
    int 0x10
    mov al, '0'
    int 0x10
    mov al, 'x'
    int 0x10
hex_print_start:
    mov al, ch
    and al, 0xf0
    call hex_map
    int 0x10
    shl cx, 0x04
    mov al, ch
    and al, 0xf0
    call hex_map
    int 0x10
    shl cx, 0x04
    mov al, ch
    and al, 0xf0
    call hex_map
    int 0x10
    shl cx, 0x04
    mov al, ch
    and al, 0xf0
    call hex_map
    int 0x10
hex_print_end:
    pop cx
    pop ax
    ret

hex_map:
    cmp al, 0x00
    jne zero_end
    mov al, '0'
    ret
zero_end:
    cmp al, 0x10
    jne one_end
    mov al, '1'
    ret
one_end:
    cmp al, 0x20
    jne two_end
    mov al, '2'
    ret
two_end:
    cmp al, 0x30
    jne three_end
    mov al, '3'
    ret
three_end:
    cmp al, 0x40
    jne four_end
    mov al, '4'
    ret
four_end:
    cmp al, 0x50
    jne five_end
    mov al, '5'
    ret
five_end:
    cmp al, 0x60
    jne six_end
    mov al, '6'
    ret
six_end:
    cmp al, 0x70
    jne seven_end
    mov al, '7'
    ret
seven_end:
    cmp al, 0x80
    jne eight_end
    mov al, '8'
    ret
eight_end:
    cmp al, 0x90
    jne nine_end
    mov al, '9'
    ret
nine_end:
    cmp al, 0xa0
    jne a_end
    mov al, 'A'
    ret
a_end:
    cmp al, 0xb0
    jne b_end
    mov al, 'B'
    ret
b_end:
    cmp al, 0xc0
    jne c_end
    mov al, 'C'
    ret
c_end:
    cmp al, 0xd0
    jne d_end
    mov al, 'D'
    ret
d_end:
    cmp al, 0xe0
    jne e_end
    mov al, 'E'
    ret
e_end:
    cmp al, 0xf0
    jne f_end
    mov al, 'F'
    ret
f_end:
    ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;The "cls" command;;;;;;;;;;;;;;;;;;;;;;;;;;;;
com_cls:
    push ax
    push bx
    push cx
    push dx
    mov ax, 0x0700      ; function 07, AL=0 means scroll whole window
    mov bh, 0x00        ; character attribute = black
    mov cx, 0x0000      ; row = 0, col = 0
    mov dx, 0x1e54      ; row = 30 (0x1e), col = 79 (0x4f)
    int 0x10            ; call BIOS video interrupt
    mov ah, 0x02        ;function 02, set curser position
    mov dx, 0x00
    int 0x10
    pop dx
    pop cx
    pop bx
    pop ax
    ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ret

扫描代码0x9e:XT! 扫描码0x9E:打破XT键盘上的'A'键!

先谢谢您的帮助。


无论何时您需要对操作系统进行编程建议,请参阅OSDev wiki非常棒!
这两页将帮助您:

  • PS2控制器。
  • PS2键盘。

  • 这是不可能的,你必须处理XT键盘,因为他们在没有8042但是8255(PPI)芯片的PC-XT中使用。
    PPI只对端口60h-63h做出响应,而忽略了我认为您正在使用的64h。
    看到这个清单。


    不要在键盘命令和控制器命令之间混淆,从你的操作系统翻译成同一个数据端口的写入,但是第一个写入到键盘,后者停在8042处。

    考虑有三个扫描码集(命名集1,2和3)。
    XT使用第一个,第二个当前由每个键盘支持,第三个很少使用。
    因此,您必须检查键盘正在使用的扫描代码集, 默认情况下它是第二个
    使用有效负载为00h的键盘命令 0f0h可以知道当前扫描代码(在通常的键盘ACK 0fah之后)。
    如果您使用01h,02h或03h的有效载荷,您可以设置正在使用的扫描码集。

    请注意 ,默认情况下,8082将扫描代码集2转换为扫描代码集1,要禁用此转换,请使用控制器命令 20h和60h清除控制器配置字节的第6位。


    总之:

  • 您可能正在处理扫描代码翻译,而不是使用(模拟)XT键盘。
  • 禁用翻译。
  • 明确设置您支持的扫描代码集。
  • 链接地址: http://www.djcxy.com/p/89845.html

    上一篇: How to determine whether the computer has an XT/AT keyboard in assembly?

    下一篇: Addressing Modes in Assembly Language (IA