# IDE hard disk driver
bsy 1f7 p@ 80 and if bsy ; then ;
rdy 1f7 p@ 8 and if 1f0 a! 256 ; then rdy ;
sector 1f3 a! swap p!+ /8 p!+ /8 p!+ /8 e0 or p!+ drop p!+ drop 4 * ;
read 20 sector 256 for rdy insw next drop ;
write bsy 30 sector 256 for rdy outsw next drop ;

# comments
p@ read 8-bit port
p!+ write 8-bit port, increment port
insw read n words from port
outsw write n words to port
/8 shift right 8 bits

bsy wait till busy bit clear
rdy wait till data-ready bit set
sector set logical sector and command
read read 256 sectors
write write 256 sectors