Tuesday, August 25, 2009

END FUNCTION

The function first decides how many bits it has to work with by looking at the address of the port. Note that in all other examples it was really irrelevant if you used decimal or HEX addresses. In this function you will need to change the numbers if you work in HEX. Now, back to how the function functions (he he he). After deciding how many bits there are in the port, it makes an array of the same number of elements. It then goes through a loop, performing integer division on the number returned from the port. It performs one division for each bit in the port. This is probably the easiest way to convert to binary, as BASIC has no built in decimal to binary function. Again, if you work in HEX you will have to adjust the function here. The function then assigns itself the value of the array element you specify with the BitYouWant% variable.

For example, to read bit 5 of port 888, you would use:


Bit5Variable% = BitStatus%(888, 5)

Well, that's it. The above is not limited to the parallel port. You can use it with any sort of interface that uses a standard I/O port. Of course, this code would not be ideal in controlling the serial port, as a lot of low level coding would be necessary.

0 Comments:

Post a Comment