Using inpout32.dll, which is available as free software, you can input and output I/O ports for x86 CPUs.
@It works on both 32-bit and 64-bit Windows. Even on 64-bit Windows, follow these steps:
right-click on Binaries only - x86 & x64 DLLs and libs ,download as InpOutBinaries_1501.zip and expand it to the appropriate folder.
Copy inpout32.dll from the win32 folder to the folder where decimal BASIC is installed (the folder where BASIC.EXE resides).
The following program is a test program for a PC/AT compatible machine.
On a PC/AT compatible machine, there is a buzzer connected to I/O port number 61 in hexadecimal notation, and when you run this program, the buzzer will appear.
Running this program on anything other than a PC/AT compatible machine is risky. In that case, rewrite lines 230 and beyond to fit your hardware.
100 SUB OutB(port, dat)
110 ASSIGN "inpout32.dll","DlPortWritePortUchar"
120 END SUB
130 FUNCTION InpB(port)
140 ASSIGN "inpout32.dll","DlPortReadPortUchar"
150 END FUNCTION
160 SUB OutW(port, dat)
170 ASSIGN "inpout32.dll","Out32"
180 END SUB
190 FUNCTION InpW(port)
200 ASSIGN "inpout32.dll","Inp32"
210 END FUNCTION
220
230 LET port=BVAL("61",16)
240 LET n=InpB(port)
250 PRINT BSTR$(n,2)
260 CALL OutB(port,INT(n/4)*4+3) ! Ring
270 PAUSE
280 CALL OutB(port,INT(n/4)*4) ! Stop
290
300 END
Copy 100`210 lines of the test program above to the program you want to run CPU I/O on.
For 8-bit input and output, we use the InpB function and the subprogram OutB.
For 16-bit input and output, we use the InpW function and the subprogram OutW.
On OutB and OutW, the first argument is the port number and the second argument is the value you want to output.