The smallest IDE driver ever

Chuck Moore is a genius.
He claims that : That's why he focussed on the Forth programming language in order to develop what should be the simplest and most robust environment ever: ColorForth.

As an example, just consider his 5-line IDE 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
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.