title: Unabled to get right status before read or write on the disk
body: <p>I'm trying to get right status of Hard disk registers before read or write the hard disk using LBA equations.</p>
  <p>So there is the little code:</p>
  <pre><code>0x8392 &lt;waitdisk+7&gt;     mov    eax,0x1f7                                                                                                                            │
  │   0x8397 &lt;waitdisk+12&gt;    mov    edx,eax                                                                                                                              │
  │   0x8399 &lt;waitdisk+14&gt;    in     al,dx                                                                                                                                │
  │   0x839a &lt;waitdisk+15&gt;    mov    WORD PTR [ebp-0x2],ax                                                                                                                │
  │   0x839e &lt;waitdisk+19&gt;    movzx  eax,WORD PTR [ebp-0x2]                                                                                                               │
  │   0x83a2 &lt;waitdisk+23&gt;    cmp    ax,0x40                                                                                                                              │
  │   0x83a6 &lt;waitdisk+27&gt;    jne    0x8392 &lt;waitdisk+7&gt; 
  </code></pre>
  <p>So you can see that i'm waiting for right status ( <code>0x40</code> ) to end into the loop.</p>
  <p>There is the info registers before taking harddisk/floppy status :</p>
  <pre><code>eax            0x1f7               503
  ecx            0x40                64
  edx            0x1f7               503
  ebx            0x0                 0
  esp            0xff88              0xff88
  ebp            0xff98              0xff98
  esi            0x0                 0
  edi            0x8548              34120
  eip            0x8399              0x8399 &lt;waitdisk+14&gt;
  eflags         0x6                 [ IOPL=0 PF ]
  </code></pre>
  <p>And there is after taking status :</p>
  <pre><code>eax            0x100               256
  ecx            0x40                64
  edx            0x1f7               503
  ebx            0x0                 0
  esp            0xff88              0xff88
  ebp            0xff98              0xff98
  esi            0x0                 0
  edi            0x8548              34120
  eip            0x839a              0x839a &lt;waitdisk+15&gt;
  eflags         0x6                 [ IOPL=0 PF ]
  </code></pre>
  <p><code>0x100</code> taken by <code>ax</code> means nothing , ...</p>
  <p>i'm using qemu emulator , so i think that maybe i have mistaken when i have created disk image or i have gived bad parameters for <code>qemu-system-x86_64</code> , but nothing :</p>
  <pre><code>dd if=/dev/zero of=disk.img bs=512 count=2880
      dd if=bin/boot1.img of=disk.img bs=512 conv=notrunc
      dd if=bin/boot2.img of=disk.img seek=1 bs=512 conv=notrunc
      dd if=bin/kernel.elf of=disk.img bs=512 seek=5 conv=notrunc
  
  qemu-system-x86_64 -fda disk.img -no-shutdown -no-reboot -d cpu_reset -d int file:serial.log
  </code></pre>
  <p>So where i have done mistake ??
  Is it the bad code or i should not use inline assembly ??</p>