Home 

Floppy - Some BASIC statements and programs


NOTE:  The DEBUG version of this web page is at here.


----------------------------------------------------------------------------------
CRUDE REGISTER
----------------------------------------------------------------------------------

Here, we will read the floppy controller's main status register.  You do not need to have a floppy in the drive to do this.

PRINT INP(1012)

Can also use  PRINT INP(&H3F4)  which is the same thing.

As expected, the IBM 5.25" Diskette Drive Adapter in my IBM 5160 returns 128.   (whether or not a drive is connected that controller)

( In JUN19, I did this on two of my IBM 5150's and saw 16 !!!!
   Then I discovered that if I powered up the 5150's with its floppy drive disconnected from the controller, then I saw 128. )


Technical: 128d = 80h = 10000000 = Controller ready, controller in DMA mode, ...
See the the 'Main Status Register' section of here.


----------------------------------------------------------------------------------
TURN ON DRIVE's LED AND SPINDLE MOTOR
----------------------------------------------------------------------------------

You do not need to have a floppy in the drive to do this.

For A: drive, use  OUT 1010,20     (same as using  OUT &H3F2,&H14 )
For B: drive, use  OUT 1010,37     (same as using  OUT &H3F2,&H25 )

With the IBM PC family, the LED and motor will only turn on for only a few seconds (because of a timeout in the motherboard BIOS).  If you want it to happen continuously, see here.


Technical: This is sending a command to the Digital Output Register (DOR) of the primary floppy controller.
20d = 14h = 00010100 = {Motor A, DMA disabled, no reset, drive 0}
37d = 25h = 00100101 = {Motor B, DMA disabled, no reset, drive 1}
See the the 'Digital Output Register' section of here.


----------------------------------------------------------------------------------
PROGRAM TO MOVE HEADS ON DRIVE A: TO A TRACK YOU SELECT
----------------------------------------------------------------------------------

The ComputerFacts for the Shugart SA-455 includes BASIC code to step the drive's head to a track that you specify.  The ComputerFacts indicates that the code is for an "IBM PC or compatible".

That BASIC code is listed below, incorporating some changes:
- Drive A: instead of drive B:
- The code in the ComputerFacts is in error: OUT 1009 should be OUT 1010.
- The '40' in line 100 was changed to 39, because tracks on a 360K drive number from 0 to 39.

The code controls drive A:  If you want control drive B: instead, change the three "OUT 1010,20" statements to "OUT 1010,37".

Note that you do not need to have a floppy in the drive.

If desired, press CTL-BREAK to stop the program.

Note that there is no verification that the heads reached the track that you specified.


10 CLS
20 OUT 1010,33: OUT 1010,20
30 S=INP(1012)
40 GOSUB 200
50 OUT 1013,7: S=INP(1012)
60 OUT 1013,2: S=INP(1012)
70 GOSUB 200
80 GOSUB 200
90 INPUT "ENTER TRACK NUMBER";TR
100 IF TR>39 THEN 90
110 OUT 1010,33: OUT 1010,20
120 S=INP(1012)
130 GOSUB 200
140 OUT 1013,15: S=INP(1012)
150 OUT 1013,2: S=INP(1012)
160 OUT 1013,TR: S=INP(1012)
170 FOR T = 1 TO 500: NEXT T
180 PRINT "PRESS ANY KEY TO STOP"
190 A$ = INKEY$: OUT 1010,20: IF A$="" THEN 190 ELSE 10
200 OUT 1013,8: S=INP(1012): S=INP(1013): S=INP(1012)
210 S=INP(1013): S=INP(1012): RETURN

run
      <------  Don't forget this bit