title: Outputing to generic port using outb in AT&T assembly syntax: getting operand mistatch
body: <p>I am trying to "outb" to a port but I keep getting: operand type mismatch for `out'</p>
  
  <p>Here is the code:</p>
  
  <pre><code>outb  %al, %bl
  </code></pre>
  
  <p>If I replace %bl with any 8 bit register (%ah, %bh, %bl, ...) I still get same error.</p>
  
  <p>If I hard code the port number, then the code works.</p>
  
  <p>How can I write generic way (in assembly) to write to a port passed as parameter?</p>
  
  <p>The following code seems to work in C but I do not really understand why and how:</p>
  
  <pre><code>asm volatile ( "outb %0, %w1" : : "a"(val), "Nd"(port) );
  </code></pre>
  
  <p>Thank you</p>