The description given by ATA/ATAPI specification seems quite straightforward :
However, all tutorial and code examples I could find show that we are supposed to read one sector at a time and control ourselves the number of time we do so.Sector Count - number of sectors to be transferred. A value of 00h specifies that 256 sectors are to be transferred.
for example, taken from https://wiki.osdev.org/ATA_PIO_Mode
The pio28_read procedure reads one sector and decrements ebx that contains initially the sector count :
Code: Select all
mov cx, 256
rep insw ; gulp one 512b sector into edi
...
dec ebx ; decrement the "sectors to read" count
And pio28_read is called until ebx reaches 0
Code: Select all
.read28:
test ebx, ebx ; no more sectors to read?
je short .r_don
call pio28_read ; read up to 256 more sectors, updating registers
je short .read28 ; if successful, is there more to read?
.r_don:
(of course it applies to the write function as well. )