Qbasicnews.com

Full Version: OUT
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ive noticed people using the OUT command in their programs and it seems they can be pritty helpfull. I understand that it sends a number to a device but i dont really get how do use it. If somone could explaing and/or direct me to a tut on the OUT command that would be very helpfull
It only works for VGA ports. There isn't really much point in learning this command (except for legacy programs, of course) since Windows and other OS's don't allow direct access to hardware ports. Same thing with interrupts.

In short, there's no real point in learning the OUT command, so you're probably not going to find any tutorials on it.
Quote:It only works for VGA ports. There isn't really much point in learning this command (except for legacy programs, of course) since Windows and other OS's don't allow direct access to hardware ports. Same thing with interrupts.

In short, there's no real point in learning the OUT command, so you're probably not going to find any tutorials on it.
There are many other uses of the OUT command. Here's an extract from Ethan Winer's book, where the OUT command is covered in detail in chapter 10. See www.ethanwiner.com
Note: This book is several years old, and therefore these addresses may have undergone changes and additions.
Code:
LOW MEMORY ADDRESSES
====================

   It is important to understand that besides memory addresses that are accessed with PEEK and POKE, the IBM PC family also  has a series of input and output ports which are accessed using INP and OUT.

Key low memory addresses in the PC.
Address   Meaning
=======   ==========================================
&H400    2 bytes, COM1 port number (RS-232 Communications Adapter)
&H402    2 bytes, COM2 port number    "
&H408    2 bytes, LPT1 port number
&H40A    2 bytes, LPT2 port number
&H410    2 bytes, Equipment List (System Data)
&H413    2 bytes, installed memory (K)
&H417    2 bytes, keyboard status
&H418    2 bytes, enhanced keyboard status
&H41A    2 bytes, keyboard buffer head pointer
&H41C    2 bytes, keyboard buffer tail pointer
&H41E    30 bytes, keyboard buffer
&H43F    1 byte, diskette motor on indicator
&H440    1 byte, diskette motor countdown timer
&H449    1 byte, current video mode
&H44A    2 bytes, current screen width (columns)
&H44C    2 bytes, current video page size (bytes)
&H462    1 byte, current video page number
&H463    2 bytes, CRT controller port number
&H46C    4 bytes, long integer system timer count
&H478    4 bytes, LPT1 - LPT4 timeout values
&H484    1 byte, EGA/VGA screen height (rows)
&H485    2 bytes, character height (scan lines)
&H487    1 byte, EGA/VGA Features bits
&H4F0    16 bytes, Inter-Application Area
&H500    1 byte, PrtSc busy flag
&H504    1 byte, active drive for one-diskette PC

For the most part, you should not experiment with the ports unless you know what they are for, and which values are appropriate.
*****
With FreeBASIC 0.15b if a program using OUT has admin rights, it can directly access ports. But it should only be used with serial ports, drivers provide a better interface for doing much anything else.

If OUT is used in graphics mode it will be emulated, per thegrogen's formerly correct answer.