Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Masterkiller

By: a guest on Oct 12th, 2008  |  syntax: ASM (NASM)  |  size: 1.38 KB  |  views: 359  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. CLI
  2. ;(1) Disable Keyboard (Send To Keyboard Controller command 0xAD <disable keyboard>)
  3. CALL waitForWrite
  4. MOV al, 0xAD
  5. OUT 0x64, al
  6. ;(2) Make sure that mouse port is active by enbling it (command 0xA8)
  7. CALL waitForWrite
  8. MOV al, 0xA8
  9. OUT 0x64, al
  10. ;(3) Reset The Mouse (Send To Keyboard Controller command 0xD4 <write to mouse> and send to Mouse command 0xFF <reset>)
  11. CALL waitForWrite
  12. MOV al, 0xD4
  13. OUT 0x64, al
  14. CALL waitForWrite
  15. MOV al, 0xFF
  16. OUT 0x60, al
  17. ;(4) Reset Completition (Wait for mouse to sent 0xAA and mouseID - then assume reset mode complete and enters stream mode)
  18. CALL waitForRead
  19. IN al, 0x60 ;FA - ACK
  20. IN al, 0x60 ;AA - Reset Success; FC - Failure at reset
  21. CMP al, 0xAA
  22. JNE .hang
  23. IN al, 0x60 ;If success - MouseID
  24. ;(5) Enable mouse clock and IRQ12 by Keyboard Controller Command Byte
  25. CALL waitForWrite
  26. MOV al, 0x20
  27. OUT 0x64, al
  28. CALL waitForRead
  29. IN al, 0x60
  30. OR al, 0x2
  31. AND al, 0xDF
  32. MOV bl, al
  33. CALL waitForWrite
  34. MOV al, 0x60
  35. OUT 0x64, al
  36. CALL waitForWrite
  37. MOV al, bl
  38. OUT 0x60, al
  39. ;(6) Enable mouse to send data (Mouse command 0xF4)
  40. CALL waitForWrite
  41. MOV al, 0xD4
  42. OUT 0x64, al
  43. CALL waitForWrite
  44. MOV al, 0xF4
  45. OUT 0x60, al
  46. CALL waitForRead ;Should receive acknowledge from mouse
  47. IN al, 0x60
  48. STI
  49.  
  50. ...
  51. waitForWrite: PUSH ax
  52. .loop:IN al, 0x64
  53. TEST al, 2
  54. JNZ .loop
  55. POP ax
  56. RET
  57.  
  58. waitForRead: PUSH ax
  59. .loop:IN al, 0x64
  60. TEST al, 1
  61. JZ .loop
  62. POP ax
  63. RET