One key thing I think you can do is setup CX with an operation count (256) and use a REP prefix to do 256 word moves without having to test for the condition each time through the loop. You only need to do the test at a sector boundary. You still need inline ASM to do this, but it will be infinitely faster than the loop because the instruction prefetch on the 8088 is inadequate.
This is the original code you are competing with:
Code: Select all
readSectorPIO proc near public
push ax
push cx
push dx
mov cx, SECTOR_SIZE / 2 ; sector size in words
; cli
mov dx, cs:[settings.ioBasePort] ; data register
readLoop:
in al, dx ; get lower half
mov ah, al
or dx, 8 ; switch to 2nd data reg
in al, dx
and dx, NOT 8 ; switch back
xchg ah, al
stosw ; save it
loop readLoop
; sti
pop dx
pop cx
pop ax
ret
readSectorPIO endp
It should be more like this:
Code: Select all
mov cx,256
rep insw;
Mike