Hi!
I am an engineering student.I was exploring the conio.h file in c++ when i encountered inp(),outp() functions. I understood the basics about them but i am still not able to create a meaningful program with it.Somebody please help me !

If you are using a 32-bit compiler on either MS-Windows or *nix then forget those two functions because they are not implemented by any 32-bit/64-bit compiler. The operating system will not permit direct access to hardware or computer ports. You have to use normal operating system api functions. Those two functions were written for 16-bit MS-DOS which did permit programs direct access to hardware.

Hi. Ancient Dragon, Thanks a lot for your valuable advice.I am using turbo c++ compiler version 3.0 which according to my knowledge is a 16-bit compiler(Tell me if I am wrong).
And if I am write please write a simple code for me.

in ur turbo c== compiler , u can navigate to help (right mouse click) and then search for inp() and outp() .
There u will not only get a decent explanation but also an example with it.
I guess that would help u out.

in ur turbo c== compiler , u can navigate to help (right mouse click) and then search for inp() and outp() .
There u will not only get a decent explanation but also an example with it.
I guess that would help u out.

Thanks Rahul. But as I mentioned earlier i have understood the basics of it. what i meant by it was that i have read its explanation in the tc help and viewed the example. But things are still not clear. thats y i m disturbing the most genious minds on earth like u and every1 else on daniweb.

Well in that case , i would need to know what exactly ur trying to achieve ?

As far as i can see is that , this is a mere part of ur project or wat ever . it would be better if u could give a panaromic view on wat r u trying to do ., then it will be easier for all of us here to help u out.

Actuallly i am not working on any projects as such.... i was just trying to enhance my programming skills when i got stuck at this..... Please give me a simple ex to create a simple prog that can interact with any hardware other than keyboard and mouse.........

Unless you are doing something with real time OSes (http://msdn.microsoft.com/en-us/library/ms838340(WinEmbedded.5).aspx), and even then it's impractical, it will be obsolete knowledge. inp/outp used to be great for interfacing with fixed address ISA cards. If you're interested in this kinda thing check out the DDK (http://www.microsoft.com/whdc/devtools/wdk/default.mspx).
Not to be a wet blanket about it, just offering some advice.

OpenWatcom allows outp()/inp() in Win32 applications and DLLs!

I will tell my success story which gave me this fact:
I looked for solution to implement support for instrument testing on real OPL3 chip in my bank editor which a cross-platform Qt application (can be built with both Qt 4 and Qt 5). At first, I made assembly of Qt 4.4.3 (last officially supported Win98) with MinGW 6.3 (yeah, I spent a time to fix compiling of so old Qt 4.4.3 on it, because I wanna C++11 which is wasn't on MinGW 3.2). After I made 98-compatible build, I have tried to make DOS application as proxy to access OPL3 chip. But I failed with that, QProcess sucks on Windows 98 with DOS applications which are freezing (and only killing of "winoldap" process saves me from that).

Then I did a simple IMF player to check out of chip working. Then I have accidentally compiled a simple DOS program as Win32 console application, and it successfuly played music on OPL3 chip! Then I made a simple DLL which I have built as 32-bit "NT_DLL":

#include <conio.h>
#define DLLExport       __declspec(dllexport)
#define STDCall         __stdcall
typedef unsigned short  uint16_t;
static const uint16_t   OPLBase = 0x388;
DLLExport void STDCall chipInit(void)
{ /* Dummy */ }
DLLExport void STDCall chipUnInit(void)
{ /* Dummy */ }
DLLExport void STDCall chipPoke(uint16_t index, uint16_t value)
{
    uint16_t c, o = (index >> 8), port = (OPLBase + o * 2);
    outp(port, index);
    for(c = 0; c < 6; ++c)  inp(port);
    outp(port + 1, value);
    for(c = 0; c < 35; ++c) inp(port);
}

and my bank editor, which uses it dynamically (not directly linked), successfully plays a music on OPL3 chip on Sound Blaster 16 card, running on Windows 98 operating system. I guess, Windows NT-family operating systems would prevent this, but I need to test that by running Windows XP life-cd on same computer with Sound Blaster 16 sound card to check out that.

If you interested, my complete code and compatible builds of my bank editor are here.

P.S. Just in case, I added the condition that checks for "is Win98 or is WinME" to turn on usage of proxy dll, so, to allow using it everywhere, just remove that condition (in the class constructor of src/opl/generator.cpp file)

UPD: I have came to home and I have tried to run my editor with disabling OS version check and force using that DLL under Windows 7: my editor was crashed with SIGILL after some number of chipPoke() calls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.