title: interfacing keyboard controller in assembly
body: <p>I'm trying to interface with my <b>keyboard controller</b> through ports
  <code><b>64h</b></code> and <code><b>60h</b></code>. I've written assembly code compatible with <b>Borland
  Turbo Assembler(TASM)</b> and <b>Linker(TLINK)</b> to do it.
  I have tried to get enough info about interfacing a keyboard
  controller from articles over the web but unfortunately no success
  so far on getting my code to have the expected result.</p>
  
  <p>Here is the summary of what I have done already:</p>
  
  <ol>
  <li>I read <b>Status Register</b> by reading port <code><b>64h</b></code> and got the byte
     <code><b>(00010100b)</b></code> initially.</li>
  <li>Before sending any command to the controller I have included
     a loop to wait for <b>IBF</b> flag <i>(Bit 1 of Status Register)</i> to make sure that it's cleared
     <code><b>(IBF = 0)</b></code>.</li>
  <li>After the loop described above I have sent a simple command like
     <code><b>AAh</b></code><i>(Controller Self Test)</i> or <code><b>ADh</b></code><i>(Disable Keyboard Interface)</i> to
     the controller via port <code><b>64h</b></code>.</li>
  <li>Included another loop after sending command to make sure and
     determine that <b>OBF</b> flag <i>(Bit 0 of Status Register)</i> is set <code><b>(OBF = 1)</b></code>.</li>
  </ol>
  
  <p>and the problem rises right at this stage and when I check
  the <b>Status Register</b> by reading port <code><b>64h</b></code> I can't see that
  neither <b>OBF</b> nor <b>IBF</b> is updated by the controller as I suppose
  at least <b>OBF</b> should be and what I get from <b>Status Register</b>
  is the byte <code><b>(00011100b)</b></code> which says that a command was sent to the
  controller as "bit 3" was set. Although just in command <code><b>ADh</b></code><i>(Disable
  Keyboard Interface)</i> I see that my keyboard stops responding.</p>
  
  <p>And the info of the system I use:</p>
  
  <ul>
  <li>Pentium 4,</li>
  <li>Windows XP SP3,</li>
  <li>Windows Command Prompt(cmd),</li>
  <li>Borland Turbo Assembler(TASM) and Linker(TLINK) version 5,</li>
  <li>An FCR-8900 keyboard with a PS/2 connector,</li>
  <li>A USB Mouse connected to a second PS/2 port via a USB-2-PS/2,</li>
  </ul>
  
  <p>The PS/2 ports are <b>6-pin DIN</b> as I believe and checked double time.</p>
  
  <p>Despite of these PS/2 ports, I have used several snippets from
  the net that report my system as an <b>AT system</b>, something that I
  can't understand either.</p>
  
  <p>I appreciate anyone sharing any kind of experience or help.<br>
  Thank you...</p>