More on the INPUT# command

Recently I commented on how an INPUT# command can cause execution to hang on a Commodore home-computer if the device for which it is intended is not on the IEC bus. I thought to provide some more details on what the right course of action is to avoid the hanging and what one might be doing that causes a hanging.

In a BASIC program genuinely interested in working with a disk drive, such as the ones listed in Inside Commodore DOS, it is not uncommon to read something along these lines:

10 OPEN 15,8,15
20 PRINT#15,"I0"
30 INPUT#15,EN$,EM$,ET$,ES$
40 IF EN$="00" GOTO 70
50 PRINT EN$", "EM$","ET$","ES$
60 END
200 CLOSE 15

The lesson to take home here is that at the beginning of a disk utility you issue a disk initialization (line 20). This operation fails with “?DEVICE NOT PRESENT  ERROR IN 20” if drive number 8 is not on the IEC bus. And that’s all good as we don’t get to line 30 where execution would hang.

Now let’s suppose we remove line 20 because we want to check the DOS version of a drive at power-on or after a drive reset. A 1541 would return:

73,CBM DOS V2.6 1541,00,00

However, if drive 8 is not on the IEC bus and the above BASIC program is run without line 20, execution hangs at line 30 (executing the loop at $EDD6 – on a Commodore 64 – until the serial clock is pulled low by the non-existing device, which obviously does not happen).

About Luigi Di Fraia

I am a Senior DevOps Engineer so I get to work with the latest technologies and open-source software. However, in my private time I enjoy retro-computing.
This entry was posted in Retrocomputing, Technical and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s