title: int 13h not reading sectors from virtual disk
body: <p>I'm trying to build a multistage bootloader, but I'm stuck in the 1st stage code that is supposed to read the 2nd stage into memory, the code uses <code>int 13h</code> to read sectors form a virtual floppy disk (.img file). Here's the code (MASM syntax) :</p>
  
  <pre><code>        .286
          .model tiny
          .data
      org 07c00h
      driveNumber db ?
          .code
  main:  jmp short start
         nop
  start: mov driveNumber,dl  ;storing booting drive number
         cli
         mov ax,cs
         mov ds,ax
         mov es,ax
         mov ss,ax
         sti
  reset: mov ah,0h              ;resetting the drive to the first sector
         mov dl,driveNumber
         int 13h
         js reset
  read:  mov ax,1000h           ;reading sectors into memory address 0x1000:0
         mov es,ax
         xor bx,bx
         mov ah,02h
         mov al,01h             ;reading 1 sector
         mov ch,01h             ;form cylinder #1
         mov cl,02h             ;starting from sector #2
         mov dh,01h             ;using head #1
         mov dl,driveNumber     ;on booting drive
         int 13h
         jc read
  
         push 1000h             ;pushing the memory address into stack
         push 0h                ;pushing the offset
         retf
  
  end main
  </code></pre>
  
  <p>This code is put on the first sector of the virtual disk along with the 0x55AA signature in the last two bytes, and the 2nd stage code is put on the following sector.</p>
  
  <p>And, as I'm here, it didn't work !</p>
  
  <p>I tried it on both vmware and bochs , and both give the same thing : <strong>nothing!</strong></p>
  
  <p>So I ran some tests :</p>
  
  <ol>
  <li>I thought the problem may be about how the cylinders, heads, and sectors are indexed. So I tried various combinations of cylinders, heads, and sectors numbers but it did me no good.</li>
  <li>I checked the returns of the <code>int 13h</code> and I got: status code (<code>ah</code> ==00h -> successful), actual sectors read count (<code>al</code> = 01h -> 1 sector has been actually read).</li>
  <li>Before the reading process, I've put some value into <code>es:bx</code> and then ran the reading process, after it had finished, I checked the value at <code>es:bx</code> and found that it's still the value I've put before, not the value that should be read form the sector.</li>
  </ol>
  
  <p>So, I have a test that tells me that the sector was actually read , and a test that tells me that there is nothing read into memory ... therefore , I'm stuck !</p>
  
  <p>Any thoughts?</p>