title: text mode cursor doesn't appear in qemu vga emulator
body: <p>I have a problem with the function that updates cursor position in text mode
  the function definition and declaration are</p>
  
  <pre><code>#include &lt;sys/io.h&gt;
  signed int VGAx = 0,VGAy=0;
  void setcursor()
  {
          uint16_t position = VGAx+VGAy*COLS;
          outb(0x0f, 0x03d4);
          outb((position&lt;&lt;8)&gt;&gt;8,0x03d5);
          outb(0x0e,0x03d4);
          outb(position&gt;&gt;8,0x03d5);
  }
  </code></pre>
  
  <p>and the file sys/io.h</p>
  
  <pre><code>static inline unsigned char inb (unsigned short int port)
  {
          unsigned char value;
          asm ("inb %0, %%al":"=rm"(value):"a"(port));
          return value;
  }
  static inline void outb(unsigned char value, unsigned short int port)
  {
          asm volatile ("outb %%al, $0"::"rm"(value), "a"(port));
  }
  </code></pre>
  
  <p>before using the function the cursor sometimes was blinking underscore and sometimes didn't appear while after using the function no cursor appeared</p>
  
  <p>here is the main function that runs</p>
  
  <pre><code>#include &lt;vga/vga.h&gt;
  int kmain(){
          setcursor()
          setbgcolor(BLACK);
          clc();
          setforecolor(BLUE);
          terminal_write('h');
          setcursor();
          return 0;
  }
  </code></pre>
  
  <p>I tried using this function</p>
  
  <pre><code>void enable_cursor() {
      outb(0x3D4, 0x0A);
      char curstart = inb(0x3D5) &amp; 0x1F; // get cursor scanline start
  
      outb(0x3D4, 0x0A);
      outb(0x3D5, curstart | 0x20); // set enable bit
  }
  </code></pre>
  
  <p>which is provided <a href="https://stackoverflow.com/questions/25321608/moving-text-mode-cursor-not-working">here</a> but I got this error 
  <code>inline asm: operand type mismatch for 'in'</code>
  any help is appreciated</p>
  
  <p><strong>EDIT</strong>
  I tried to fix the wrong <code>inb</code> and <code>outb</code>:</p>
  
  <pre><code>static inline unsigned char inb (unsigned short int port)
  {
          unsigned char value;
          asm volatile("inb %1, %0" : "=a"(value) : "Nd"(port));
          return value;
  }
  static inline void outb(unsigned char value, unsigned short int port)
  {
          asm volatile ("outb %%al, $0"::"Nd"(value), "a"(port));
  }
  </code></pre>
  
  <p>I guess this is the right definition but still no cursor appeard</p>
  
  <p><strong>EDIT 2</strong>
  I followed the given answer and defined the <code>io.h</code> file as the following</p>
  
  <pre><code>static inline unsigned char inb (unsigned short int port)
  {
          unsigned char value;
          asm volatile ("inb %1, %0" : "=a"(value) : "Nd"(port));
          return value;
  }
  static inline void outb(unsigned char value, unsigned short int port)
  {
          asm volatile ("outb %0, %1"::"a"(value), "Nd"(port));
  }
  </code></pre>
  
  <p>I would like to mention that I also added<code>enable_cursor();</code> to the beginning of kmain now the compile time error is fixed but no cursor appeared (which is the main problem)</p>
  
  <p><strong>EDIT 3</strong>
  I would like to point out that a version of the whole code is availabe on <a href="http://github.com/oddcoder/opal101" rel="nofollow noreferrer">gihub</a> if any one want access to pieces of code that are no available in the question</p>