How do I properly read multiple sectors from a disk using 28-bit PIO in assembly?

2

How do I properly read multiple sectors from a disk using 28-bit PIO in assembly?

This is my load sectors subroutine:

load32:
    jmp load32_skipvars:
    load32_source dd 0
    load32_return dd 0
load32_skipvars:
    mov dword [load32_source], esi
    mov dword [load32_return], ebx
    mov ebx, ecx
    mov al, byte [load32_source + 3]
    or al, 0xe0
    mov dx, 0x1f6
    out dx, al
    mov dx, 0x1f1
    mov al, 0x00
    out dx, al
    mov dx, 0x1f2
    mov al, cl
    out dx, al
    mov al, byte [load32_source]
    mov dx, 0x1f3
    out dx, al
    mov al, byte [load32_source + 1]
    mov dx, 0x1f4
    out dx, al
    mov al, byte [load32_source + 2]
    mov dx, 0x1f5
    out dx, al
    mov dx, 0x1f7
    mov al, 0x20
    out dx, al
waitforit:
    in      al, dx
    test    al, 0x08
    jz      waitforit
    mov     ecx, 0x00000100
    mov     edx, 0x000001f0
    rep     insw
    dec     ebx
    cmp     ebx, 0
    jg      waitforit
    jmp     [load32_return]

Which can be called like so:

    mov esi, dword [kernel_cluster_loc]
    mov edi, dword [kernel_put]
    xor ecx, ecx
    mov cl, [bpb_sectors_per_cluster]
    mov ebx, morekernel
    jmp load32
morekernel:

This loads the multiple sectors as it should, however, there are multiple sectors of "FFFFFFFF" between them, breaking it into pieces so it's not contiguous.

This is what the memory looks like after loading:

Offset(h) 00       04       08       0C

00100000  BDFFFFEF 00BCFFFF EF00E852 010000EB  ½ÿÿï.¼ÿÿï.èR...ë
00100010  FE5589E5 905DC355 89E583EC 088B5508  þU‰å.]ÃU‰åƒì.‹U.
00100020  8B450C66 8955FC88 45F80FB7 55FC0FB6  ‹E.f‰UüˆEø.·Uü.¶
00100030  45F8EE90 C9C35589 E583EC10 C745F800  Eøî.ÉÃU‰åƒì.ÇEø.
00100040  000000C7 45FC0000 0000EB08 8345F801  ...ÇEü....ë.ƒEø.
00100050  8345FC01 8B55088B 45FC01D0 0FB60084  ƒEü.‹U.‹Eü.Ð.¶.„
00100060  C075E98B 45F8C9C3 5589E56A 0F68D403  Àué‹EøÉÃU‰åj.hÔ.
00100070  0000E8A0 FFFFFF83 C4088B45 080FB6C0  ..è ÿÿÿƒÄ.‹E..¶À
00100080  5068D503 0000E88C FFFFFF83 C4086A0E  PhÕ...èŒÿÿÿƒÄ.j.
00100090  68D40300 00E87DFF FFFF83C4 088B4508  hÔ...è}ÿÿÿƒÄ.‹E.
001000A0  C1E8080F B6C05068 D5030000 E866FFFF  Áè..¶ÀPhÕ...èfÿÿ
001000B0  FF83C408 90C9C355 89E583EC 10C745FC  ÿƒÄ..ÉÃU‰åƒì.ÇEü
001000C0  00800B00 C745F800 000000EB 1D8B55F8  .€..ÇEø....ë.‹Uø
001000D0  8B45FC01 D0C60020 8B45F88D 50018B45  ‹Eü.ÐÆ. ‹Eø.P.‹E
001000E0  FC01D0C6 00078345 F802817D F89F0F00  ü.ÐÆ..ƒEø..}øŸ..
001000F0  007EDA90 C9C35589 E583EC10 C745FC00  .~Ú.ÉÃU‰åƒì.ÇEü.
00100100  800B00FF 7508E82B FFFFFF83 C404C1E0  €..ÿu.è+ÿÿÿƒÄ.Áà
00100110  0201450C C745F400 000000C7 45F80000  ..E.ÇEô....ÇEø..
00100120  0000EB2B 8B55F48B 45FC01C2 8B4DF88B  ..ë+‹Uô‹Eü.‹Mø‹
00100130  450801C8 0FB60088 028B45F4 8D50018B  E..È.¶.ˆ.‹Eô.P.‹
00100140  45FC01D0 C6000783 45F80183 45F4028B  Eü.ÐÆ..ƒEø.ƒEô.‹
00100150  55F88B45 0801D00F B60084C0 75C690C9  Uø‹E..Ð.¶.„ÀuÆ.É
00100160  C35589E5 83EC1865 A1140000 008945F4  ÃU‰åƒì.e¡....‰Eô
00100170  31C0C745 EC000000 00C745F0 C0011000  1ÀÇEì....ÇEðÀ...
00100180  E832FFFF FF8B45EC 50E8DAFE FFFF83C4  è2ÿÿÿ‹EìPèÚþÿÿƒÄ
00100190  048D45EC 50FF75F0 E859FFFF FF83C408  ..EìPÿuðèYÿÿÿƒÄ.
001001A0  8B45EC50 E8BFFEFF FF83C404 908B45F4  ‹EìPè¿þÿÿƒÄ..‹Eô
001001B0  65330514 00000074 05E853FE FFFFC9C3  e3.....t.èSþÿÿÉÃ
001001C0  54686973 20697320 796F206B 65726E65  This is yo kerne
001001D0  6C206D65 6E672100 14000000 00000000  l meng!.........
001001E0  017A5200 017C0801 1B0C0404 88010000  .zR..|......ˆ...
001001F0  1C000000 1C000000 19FEFFFF 06000000  .........þÿÿ....
00100200  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100210  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100220  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100230  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100240  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100250  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100260  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100270  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100280  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100290  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001002A0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001002B0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001002C0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001002D0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001002E0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001002F0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100300  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100310  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100320  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100330  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100340  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100350  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100360  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100370  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100380  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100390  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001003A0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001003B0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001003C0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001003D0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001003E0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001003F0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100400  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100410  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100420  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100430  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100440  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100450  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100460  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100470  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100480  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100490  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001004A0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001004B0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001004C0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001004D0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001004E0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001004F0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100500  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100510  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100520  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100530  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100540  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100550  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100560  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100570  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100580  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100590  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001005A0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001005B0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001005C0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001005D0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001005E0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001005F0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100600  00410E08 8502420D 0542C50C 04040000  .A..….B..BÅ.....
00100610  1C000000 3C000000 FFFDFFFF 1F000000  ....<...ÿýÿÿ....
00100620  00410E08 8502420D 055BC50C 04040000  .A..….B..[Å.....
00100630  1C000000 5C000000 FEFDFFFF 32000000  ....\...þýÿÿ2...
00100640  00410E08 8502420D 056EC50C 04040000  .A..….B..nÅ.....
00100650  1C000000 7C000000 10FEFFFF 4F000000  ....|....þÿÿO...
00100660  00410E08 8502420D 05024BC5 0C040400  .A..….B...KÅ....
00100670  1C000000 9C000000 3FFEFFFF 3F000000  ....œ...?þÿÿ?...
00100680  00410E08 8502420D 057BC50C 04040000  .A..….B..{Å.....
00100690  1C000000 BC000000 5EFEFFFF 6B000000  ....¼...^þÿÿk...
001006A0  00410E08 8502420D 050267C5 0C040400  .A..….B...gÅ....
001006B0  1C000000 DC000000 A9FEFFFF 5F000000  ....Ü...©þÿÿ_...
001006C0  00410E08 8502420D 05025BC5 0C040400  .A..….B...[Å....
001006D0  00000000 00000000 00000000 00000000  ................
001006E0  00000000 00000000 00000000 00000000  ................
001006F0  00000000 00000000 00000000 00000000  ................
00100700  00000000 00000000 00000000 00000000  ................
00100710  00000000 00000000 00000000 00000000  ................
00100720  00000000 00000000 00000000 00000000  ................
00100730  00000000 00000000 00000000 00000000  ................
00100740  00000000 00000000 00000000 00000000  ................
00100750  00000000 00000000 00000000 00000000  ................
00100760  00000000 00000000 00000000 00000000  ................
00100770  00000000 00000000 00000000 00000000  ................
00100780  00000000 00000000 00000000 00000000  ................
00100790  00000000 00000000 00000000 00000000  ................
001007A0  00000000 00000000 00000000 00000000  ................
001007B0  00000000 00000000 00000000 00000000  ................
001007C0  00000000 00000000 00000000 00000000  ................
001007D0  00000000 00000000 00000000 00000000  ................
001007E0  00000000 00000000 00000000 00000000  ................
001007F0  00000000 00000000 00000000 00000000  ................
00100800  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100810  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100820  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100830  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100840  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100850  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100860  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100870  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100880  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100890  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001008A0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001008B0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001008C0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001008D0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001008E0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001008F0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100900  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100910  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100920  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100930  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100940  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100950  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100960  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100970  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100980  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100990  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001009A0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001009B0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001009C0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001009D0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001009E0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
001009F0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100A00  10000600 0000FC01 10000A00 00005400  ......ü.......T.
00100A10  00000B00 00001000 00001100 0000C003  ..............À.
00100A20  10001200 00003000 00001300 00000800  ......0.........
00100A30  00001600 00000000 0000FAFF FF6F0100  ..........úÿÿo..
00100A40  00000000 00000000 00000000 00000000  ................
00100A50  00000000 00000000 00000000 00000000  ................
00100A60  00000000 00000000 00000000 00000000  ................
00100A70  00000000 00000000 00000000 00000000  ................
00100A80  00000000 00000000 00000000 00000000  ................
00100A90  00000000 00000000 00000000 00000000  ................
00100AA0  00000000 00000000 00000000 00000000  ................
00100AB0  00000000 00000000 00000000 00000000  ................
00100AC0  00000000 00000000 00000000 00000000  ................
00100AD0  00000000 00000000 00000000 00000000  ................
00100AE0  00000000 00000000 00000000 00000000  ................
00100AF0  00000000 00000000 00000000 00000000  ................
00100B00  00000000 00000000 00000000 00000000  ................
00100B10  00000000 00000000 00000000 00000000  ................
00100B20  00000000 00000000 00000000 00000000  ................
00100B30  00000000 00000000 00000000 00000000  ................
00100B40  00000000 00000000 00000000 00000000  ................
00100B50  00000000 00000000 00000000 00000000  ................
00100B60  00000000 00000000 00000000 00000000  ................
00100B70  00000000 00000000 00000000 00000000  ................
00100B80  00000000 00000000 00000000 00000000  ................
00100B90  00000000 00000000 00000000 00000000  ................
00100BA0  00000000 00000000 00000000 00000000  ................
00100BB0  00000000 00000000 00000000 00000000  ................
00100BC0  00000000 00000000 00000000 00000000  ................
00100BD0  00000000 00000000 00000000 00000000  ................
00100BE0  00000000 00000000 00000000 00000000  ................
00100BF0  00000000 00000000 0000FFFF FFFFFFFF  ..........ÿÿÿÿÿÿ
00100C00  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C10  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C20  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C30  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C40  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C50  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C60  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C70  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C80  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100C90  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100CA0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100CB0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100CC0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100CD0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100CE0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100CF0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100D00  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ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ÿÿÿ
00100FB0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100FC0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100FD0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100FE0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00100FF0  FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

The three parts that aren't "FF" are the whole file, I just cant figure out how to get it loaded properly. I assume this has to do with the waiting needed between sectors, but I have it go back after each sector to waitforit what am I doing wrong?

assembly
io
x86
kernel
asked on Stack Overflow Sep 12, 2017 by Willdorf

1 Answer

4

You forgot to restore dx to 1f7h (The ATA Controller Status Register) at the end of the loop.

Failing at restoring dx will make the test for bit 3 (DRQ) to happen on the Data Register.
Since, due to electrical legacy, an unserviced IO read returns a datum with all the bits set, the test always passes leading you to the offending reads.

It's a bit curious how the controller returns the correct data only after an integral amount of sectors (512 bytes) has been read - probably due to some internal counter/latching logic.


This is a bit off-topic but if I may, let me give you one more advice.

Robustness

  1. Always check if the controller is ready to accept a new command (bit 7, BSY, of the Status Register).
  2. Always check if the last command succeeded (bit 0, ERR, of the Status Register) along with the Error Register.
  3. Check if the controller and channel selected have an attached and ready device (Bit 6, DRDY, of the Status Register)
  4. Establish a calling convention, particularly which registers should be preserved, or adhere to an existing one (if you are going to use, e.g., C).

Readability

  1. Use the stack to save your local variables, not global vars.
  2. Use calls/returns not jumps unless you have a specific reason not to.
  3. Don't put variables in the flow of execution, place them between functions if you don't have a data segment.

The "programming reference" for old AT controllers or PCI attached ATA controllers is the ATA/ATAPI 6 specification which is basically one of the latest before the introduction of SATA.
It also describes the ATAPI (e.g. advanced disk management, CD-ROM readers) interface and all the possible defined commands.
It is surprisingly comfortable to read, just be warned that you won't find IO ports addresses but offsets (encoded as asserted/non-asserted pins but that is just the binary pattern of the low bits of the port address).

answered on Stack Overflow Sep 12, 2017 by Margaret Bloom

User contributions licensed under CC BY-SA 3.0