Search code examples
assemblynasmbootloaderreal-mode

bootloader reading drive parameters


I want to get dimensions of hard drive. I find that I need to use int 13h with ah = 08h. I found on wikipedia that it returns following:

DH logical last index of heads = number_of - 1 (because index starts with 0)

CX [7:6] [15:8] logical last index of cylinders = number_of - 1 (because index starts with 0)

[5:0] logical last index of sectors per track = number_of (because index starts with 1)

The problem is that I have no idea how to read only bits [5:0] on it own to get last index of sector per track, and the same with [7:6][15:8] to get last index of cylinders. I would be really thankful if someone would point me into the right way or explain how to do this.


Solution

  • mov  ax, cx
    and  ax, 63
    shr  cl, 6
    xchg cl, ch
    

    This leaves sectors in AX and cylinders in CX