title: Reading and writing on I/O ports
body: <p>I am trying to understand the following code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;sys/io.h&gt;
  
  #define baseport 0x378
  
  int main()
  {
      int b;
      if(ioperm(baseport,3,1))
      {
          perror("ioperm");
          exit(1);
      }
      outb(0,baseport);
  
      usleep(1000000);
      printf("\n the status: %x,\n",inb(baseport));
  
      if (ioperm(baseport,3,0)) {perror("ioperm"); exit(1);}
  
      exit(0);
  }
  </code></pre>
  
  <p>The output is 0xff, 255 in decimal, whether I write on Port 1 or Port 0 (using <code>outb()</code>).  I cannot understand why it is 255 when I am writing 0 to it.</p>