Hard I/O




Using the Debug I and O functions

This example is more talk that demonstrating program operation. It is because Windows XP has limitation that the Disk Operating System enjoys. Because DOS is only emulated on XP, it would be possible to change data sent to the output ports and change memory while Windows XP is actually running another program using these ports. The results would cause program operation under XP to be undependable at best. The results would be absolutely unpredictable.

Having said that, I will talk about the use of these two functions.  The a (assemble) function will not not permit assembling a program using the I (input) or O (output) functions with the XP version of Debug.
Although it is unwise, these functions may be used under Debug with the "fat finger" method, but only at your own risk. Of course, it you are using an older system that runs under DOS, the I and O functions work perfectly, as designed.







Exercising Debug I/O function with Debug
Firstly, make certain that the IO ports are the same for your processor as they are for this example. I can look into my Systems Utilities and see the ports for the timer and the internal speaker. My third timer is located at address 43 and 42 hex. My Periferal Interface Adapter that controls the internal speaker is at location 61 hex. With this information, I can create a tone with the internal speaker. Again, under XP, this must be done in Debug in real time using the "fat finge" method of controlling the processor' I/O ports.

Call Debug in the normal manner on the Floppy Disk, either by double clicking on the Debug.exe Icon or by Clicking on the Command.Com icon and calling Debug from the DOS emulator.

First the timer's count down register must be set for the desired frequency. This is done by instructing the timer to receive two bytes of data. On the Debug prompt, type:

-O43,B6    
That is the character O followed by the hex numbers 43 comma B6. This instructs the timer that the next two bytes to the counter will follow at their port address.

-O42,A9
The low byte is A9. Notice the address is 42 now, not 43 as with the first OUT instruction.

-O42,04
04 is the high byte for the word (04 A9) which corresponds to a frequency of 1000 Hz.

At this time, the timer should be counting at a 1KHz rate. Now we need to switch the Peripheral Interface Adapter that turns the internal speaker either on or off. Its location is address 61.

-O61,33
This will turn on the speaker.

-O61,30
Will turn it back off




Warning......Don't do this at home, unless home happens to be a DOS system......



Doing it anyway

I would suggest it unwise using the I and O features of debug unless you are running under a DOS system. However, under a DOS system, I would have not such reluctance. I personally would be running Native DOS by booting up on the Floppy Disk and not using the Windows pretend DOS or the Hard Drive. The worst thing that could happen to me is to clobber the Floppy Disk and I might need to re-format it and copy my work back onto it. Under the DOS systems, I would be able to assemble with the I and O functions under Debug as well.


Here is a simple program that will run nicely under Native DOS using Debug to assemble it as in previous examples:



-a
-o43,b6
-o42,A9
-o42,04
-o61,33
-mov ah,1
-int21
-o,61,30
-int 20

The output functions are explained in the previous paragraph.
The INT 21 function with the AH sub-function halts the program intil a keystrok is made.
The INT 20 function returns the program back to the program that called it. In this case, either DOS or DEBUG.









Using GWBasic to control the Input and Outports
 
The INP and OUT functions will work using GWBasic under Windows XP. There is an example in the GWBasic section that does just this. The program controls the timer the same way as we have done here.
GWBasic uses the INP( ) and OUT( ) directives to do so. Please be certain that the I/O addresses are indeed the same for your particular processor. If you can't do this, you probably should leave Hard I/O alone.