?? keyboard.s
字號:
alt_map:.byte 0,0.ascii "\0@\0$\0\0{[]}\\\0".byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte '~,13,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0,0,0 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte 0,0,0,0,0 /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '|.fill 10,1,0#elif defined(KBD_US)// 以下是美式鍵盤的掃描碼映射表。key_map:.byte 0,27.ascii "1234567890-=".byte 127,9.ascii "qwertyuiop[]".byte 13,0.ascii "asdfghjkl;'".byte '`,0.ascii "\\zxcvbnm,./".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '<.fill 10,1,0shift_map:.byte 0,27.ascii "!@#$%^&*()_+".byte 127,9.ascii "QWERTYUIOP{}".byte 13,0.ascii "ASDFGHJKL:\"".byte '~,0.ascii "|ZXCVBNM<>?".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '>.fill 10,1,0alt_map:.byte 0,0.ascii "\0@\0$\0\0{[]}\\\0".byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte '~,13,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0,0,0 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte 0,0,0,0,0 /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '|.fill 10,1,0#elif defined(KBD_GR)// 以下是德語鍵盤的掃描碼映射表。key_map:.byte 0,27.ascii "1234567890\\'".byte 127,9.ascii "qwertzuiop@+".byte 13,0.ascii "asdfghjkl[]^".byte 0,'#.ascii "yxcvbnm,.-".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '<.fill 10,1,0shift_map:.byte 0,27.ascii "!\"#$%&/()=?`".byte 127,9.ascii "QWERTZUIOP\\*".byte 13,0.ascii "ASDFGHJKL{}~".byte 0,''.ascii "YXCVBNM;:_".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '>.fill 10,1,0alt_map:.byte 0,0.ascii "\0@\0$\0\0{[]}\\\0".byte 0,0.byte '@,0,0,0,0,0,0,0,0,0,0.byte '~,13,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0,0,0 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte 0,0,0,0,0 /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '|.fill 10,1,0#elif defined(KBD_FR)// 以下是法語鍵盤的掃描碼映射表。key_map:.byte 0,27.ascii "&{\"'(-}_/@)=".byte 127,9.ascii "azertyuiop^$".byte 13,0.ascii "qsdfghjklm|".byte '`,0,42 /* coin sup gauche, don't know, [*|mu] */.ascii "wxcvbn,;:!".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '<.fill 10,1,0shift_map:.byte 0,27.ascii "1234567890]+".byte 127,9.ascii "AZERTYUIOP<>".byte 13,0.ascii "QSDFGHJKLM%".byte '~,0,'#.ascii "WXCVBN?./\\".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '>.fill 10,1,0alt_map:.byte 0,0.ascii "\0~#{[|`\\^@]}".byte 0,0.byte '@,0,0,0,0,0,0,0,0,0,0.byte '~,13,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0,0,0 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte 0,0,0,0,0 /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '|.fill 10,1,0#else#error "KBD-type not defined"#endif/** do_self handles "normal" keys, ie keys that don't change meaning* and which have just one character returns.*//** do_self 用于處理“普通”鍵,也即含義沒有變化并且只有一個字符返回的鍵。*/do_self:// 454-460 行用于根據模式標志mode 選擇alt_map、shift_map 或key_map 映射表之一。lea alt_map,%ebx // alt 鍵同時按下時的映射表基址alt_map??ebx。testb $0x20,mode /* alt-gr */ /* 右alt 鍵同時按下了? */jne 1f // 是,則向前跳轉到標號1 處。lea shift_map,%ebx // shift 鍵同時按下時的映射表基址shift_map??ebx。testb $0x03,mode // 有shift 鍵同時按下了嗎?jne 1f // 有,則向前跳轉到標號1 處。lea key_map,%ebx // 否則使用普通映射表key_map。// 取映射表中對應掃描碼的ASCII 字符,若沒有對應字符,則返回(轉none)。1: movb (%ebx,%eax),%al // 將掃描碼作為索引值,取對應的ASCII 碼??al。orb %al,%al // 檢測看是否有對應的ASCII 碼。je none // 若沒有(對應的ASCII 碼=0),則返回。// 若ctrl 鍵已按下或caps 鍵鎖定,并且字符在'a'-'}'(0x61-0x7D)范圍內,則將其轉成大寫字符// (0x41-0x5D)。testb $0x4c,mode /* ctrl or caps */ /* 控制鍵已按下或caps 亮?*/je 2f // 沒有,則向前跳轉標號2 處。cmpb $'a,%al // 將al 中的字符與'a'比較。jb 2f // 若al 值<'a',則轉標號2 處。cmpb $'},%al // 將al 中的字符與'}'比較。ja 2f // 若al 值>'}',則轉標號2 處。subb $32,%al // 將al 轉換為大寫字符(減0x20)。// 若ctrl 鍵已按下,并且字符在'`'--'_'(0x40-0x5F)之間(是大寫字符),則將其轉換為控制字符// (0x00-0x1F)。2: testb $0x0c,mode /* ctrl */ /* ctrl 鍵同時按下了嗎?*/je 3f // 若沒有則轉標號3。cmpb $64,%al // 將al 與'@'(64)字符比較(即判斷字符所屬范圍)。jb 3f // 若值<'@',則轉標號3。cmpb $64+32,%al // 將al 與'`'(96)字符比較(即判斷字符所屬范圍)。jae 3f // 若值>='`',則轉標號3。subb $64,%al // 否則al 值減0x40,// 即將字符轉換為0x00-0x1f 之間的控制字符。// 若左alt 鍵同時按下,則將字符的位7 置位。3: testb $0x10,mode /* left alt */ /* 左alt 鍵同時按下?*/je 4f // 沒有,則轉標號4。orb $0x80,%al // 字符的位7 置位。// 將al 中的字符放入讀緩沖隊列中。4: andl $0xff,%eax // 清eax 的高字和ah。xorl %ebx,%ebx // 清ebx。call put_queue // 將字符放入緩沖隊列中。none: ret/** minus has a routine of it's own, as a 'E0h' before* the scan code for minus means that the numeric keypad* slash was pushed.*//** 減號有它自己的處理子程序,因為在減號掃描碼之前的0xe0* 意味著按下了數字小鍵盤上的斜杠鍵。*/minus: cmpb $1,e0 // e0 標志置位了嗎?jne do_self // 沒有,則調用do_self 對減號符進行普通處理。movl $'/,%eax // 否則用'/'替換減號'-'??al。xorl %ebx,%ebxjmp put_queue // 并將字符放入緩沖隊列中。/** This table decides which routine to call when a scan-code has been* gotten. Most routines just call do_self, or none, depending if* they are make or break.*//* 下面是一張子程序地址跳轉表。當取得掃描碼后就根據此表調用相應的掃描碼處理子程序。* 大多數調用的子程序是do_self,或者是none,這起決于是按鍵(make)還是釋放鍵(break)。*/key_table:.long none,do_self,do_self,do_self /* 00-03 s0 esc 1 2 */.long do_self,do_self,do_self,do_self /* 04-07 3 4 5 6 */.long do_self,do_self,do_self,do_self /* 08-0B 7 8 9 0 */.long do_self,do_self,do_self,do_self /* 0C-0F + ' bs tab */.long do_self,do_self,do_self,do_self /* 10-13 q w e r */.long do_self,do_self,do_self,do_self /* 14-17 t y u i */.long do_self,do_self,do_self,do_self /* 18-1B o p } ^ */.long do_self,ctrl,do_self,do_self /* 1C-1F enter ctrl a s */.long do_self,do_self,do_self,do_self /* 20-23 d f g h */.long do_self,do_self,do_self,do_self /* 24-27 j k l | */.long do_self,do_self,lshift,do_self /* 28-2B { para lshift , */.long do_self,do_self,do_self,do_self /* 2C-2F z x c v */.long do_self,do_self,do_self,do_self /* 30-33 b n m , */.long do_self,minus,rshift,do_self /* 34-37 . - rshift * */.long alt,do_self,caps,func /* 38-3B alt sp caps f1 */.long func,func,func,func /* 3C-3F f2 f3 f4 f5 */.long func,func,func,func /* 40-43 f6 f7 f8 f9 */.long func,num,scroll,cursor /* 44-47 f10 num scr home */.long cursor,cursor,do_self,cursor /* 48-4B up pgup - left */.long cursor,cursor,do_self,cursor /* 4C-4F n5 right + end */.long cursor,cursor,cursor,cursor /* 50-53 dn pgdn ins del */.long none,none,do_self,func /* 54-57 sysreq ? < f11 */.long func,none,none,none /* 58-5B f12 ? ? ? */.long none,none,none,none /* 5C-5F ? ? ? ? */.long none,none,none,none /* 60-63 ? ? ? ? */.long none,none,none,none /* 64-67 ? ? ? ? */.long none,none,none,none /* 68-6B ? ? ? ? */.long none,none,none,none /* 6C-6F ? ? ? ? */.long none,none,none,none /* 70-73 ? ? ? ? */.long none,none,none,none /* 74-77 ? ? ? ? */.long none,none,none,none /* 78-7B ? ? ? ? */.long none,none,none,none /* 7C-7F ? ? ? ? */.long none,none,none,none /* 80-83 ? br br br */.long none,none,none,none /* 84-87 br br br br */.long none,none,none,none /* 88-8B br br br br */.long none,none,none,none /* 8C-8F br br br br */.long none,none,none,none /* 90-93 br br br br */.long none,none,none,none /* 94-97 br br br br */.long none,none,none,none /* 98-9B br br br br */.long none,unctrl,none,none /* 9C-9F br unctrl br br */.long none,none,none,none /* A0-A3 br br br br */.long none,none,none,none /* A4-A7 br br br br */.long none,none,unlshift,none /* A8-AB br br unlshift br */.long none,none,none,none /* AC-AF br br br br */.long none,none,none,none /* B0-B3 br br br br */.long none,none,unrshift,none /* B4-B7 br br unrshift br */.long unalt,none,uncaps,none /* B8-BB unalt br uncaps br */.long none,none,none,none /* BC-BF br br br br */.long none,none,none,none /* C0-C3 br br br br */.long none,none,none,none /* C4-C7 br br br br */.long none,none,none,none /* C8-CB br br br br */.long none,none,none,none /* CC-CF br br br br */.long none,none,none,none /* D0-D3 br br br br */.long none,none,none,none /* D4-D7 br br br br */.long none,none,none,none /* D8-DB br ? ? ? */.long none,none,none,none /* DC-DF ? ? ? ? */.long none,none,none,none /* E0-E3 e0 e1 ? ? */.long none,none,none,none /* E4-E7 ? ? ? ? */.long none,none,none,none /* E8-EB ? ? ? ? */.long none,none,none,none /* EC-EF ? ? ? ? */.long none,none,none,none /* F0-F3 ? ? ? ? */.long none,none,none,none /* F4-F7 ? ? ? ? */.long none,none,none,none /* F8-FB ? ? ? ? */.long none,none,none,none /* FC-FF ? ? ? ? *//** kb_wait waits for the keyboard controller buffer to empty.* there is no timeout - if the buffer doesn't empty, we hang.*//** 子程序kb_wait 用于等待鍵盤控制器緩沖空。不存在超時處理 - 如果* 緩沖永遠不空的話,程序就會永遠等待(死掉)。*/kb_wait:pushl %eax1: inb $0x64,%al // 讀鍵盤控制器狀態。testb $0x02,%al // 測試輸入緩沖器是否為空(等于0)。jne 1b // 若不空,則跳轉循環等待。popl %eaxret/** This routine reboots the machine by asking the keyboard* controller to pulse the reset-line low.*//** 該子程序通過設置鍵盤控制器,向復位線輸出負脈沖,使系統復位重啟(reboot)。*/reboot:call kb_wait // 首先等待鍵盤控制器輸入緩沖器空。movw $0x1234,0x472 /* don't do memory check */movb $0xfc,%al /* pulse reset and A20 low */outb %al,$0x64 // 向系統復位和A20 線輸出負脈沖。die: jmp die // 死機。
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -