inp, outp in Windows 95 - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

inp, outp in Windows 95

I wrote a C program a while ago which uses the macros inp, outp, inpw, & outpw from conio.h. This program sent commands to the ports to get hard drive info from an IDE hard drive. Now I need it to run in Windows. It works fine in DOS mode, but none of the commands work when run from a DOS prompt within Windows '95. Does anyone happen to know why? It is either not sending the commands to the ports (ie, outp isn't working) or it's not reading the values from the ports (ie, inp isn't working). Any one know any reason these functions wouldn't do the same thing they do from within Windows they do in DOS mode?


Paul Lalli





Comments

  • Hi,


    maybe you should try using assembly for your low level I/O.


    here are some functions (the "_asm" keyword is used to indicate assembly command) :


    void outp(int port,unsigned char value)

    {

    _asm mov dx,port

    _asm mov al,value

    _asm out dx,al

    }


    unsigned char inp(int port)

    {

    unsigned char value;


    _asm mov dx,port

    _asm in al,dx

    _asm mov value,al


    return value;

    }


  • Hi,


    maybe you should try using assembly for your low level I/O.


    here are some functions (the "_asm" keyword is used to indicate assembly command) :


    void outp(int port,unsigned char value)

    {

    _asm mov dx,port

    _asm mov al,value

    _asm out dx,al

    }


    unsigned char inp(int port)

    {

    unsigned char value;


    _asm mov dx,port

    _asm in al,dx

    _asm mov value,al


    return value;

    }


  • Hello.


    Thank you for your assistance. I feel rather clueless now, but is that code you gave exactly what should be typed into the source file? Because I tried those _asm commands and they all resulted in syntax errors. The compiler did not recognize the word _asm. Were you using pseudo-code, or does my compiler just suck?


    Paul Lalli


    : Hi,


    : maybe you should try using assembly for your low level I/O.


    : here are some functions (the "_asm" keyword is used to indicate assembly command) :


    : void outp(int port,unsigned char value)

    : {

    : _asm mov dx,port

    : _asm mov al,value

    : _asm out dx,al

    : }


    : unsigned char inp(int port)

    : {

    : unsigned char value;


    : _asm mov dx,port

    : _asm in al,dx

    : _asm mov value,al


    : return value;

    : }





  • Hello.


    Thank you for your assistance. I feel rather clueless now, but is that code you gave exactly what should be typed into the source file? Because I tried those _asm commands and they all resulted in syntax errors. The compiler did not recognize the word _asm. Were you using pseudo-code, or does my compiler just suck?


    Paul Lalli


    : Hi,


    : maybe you should try using assembly for your low level I/O.


    : here are some functions (the "_asm" keyword is used to indicate assembly command) :


    : void outp(int port,unsigned char value)

    : {

    : _asm mov dx,port

    : _asm mov al,value

    : _asm out dx,al

    : }


    : unsigned char inp(int port)

    : {

    : unsigned char value;


    : _asm mov dx,port

    : _asm in al,dx

    : _asm mov value,al


    : return value;

    : }





  • Dear Paul Alli,


    Using VC++, the good instructions are _inp and _outp. I think you should try to do an easier I/O access, as for the parallel port for example, to verify if your instructions are running. In the Windows environment, all hardware access is virtual, and all access is done through the HAL (Hardware Abstraction Layer). So, the system can do anything with your access if it is not allowed, as for and important device. In this case, your solution is to use a device driver. Search on internet for TVICPORT, it is a shareware device driver tha allows direct access on windows applications.


    Geovany.





  • It should work - try

    _asm{



    asm code here





    }



    or



    __asm{





    asm code here



    }

    : Hello.



    : Thank you for your assistance. I feel rather clueless now, but is that code you gave exactly what should be typed into the source file? Because I tried those _asm commands and they all resulted in syntax errors. The compiler did not recognize the word _asm. Were you using pseudo-code, or does my compiler just suck?



    : Paul Lalli



    : : Hi,



    : : maybe you should try using assembly for your low level I/O.



    : : here are some functions (the "_asm" keyword is used to indicate assembly command) :



    : : void outp(int port,unsigned char value)

    : : {

    : : _asm mov dx,port

    : : _asm mov al,value

    : : _asm out dx,al

    : : }



    : : unsigned char inp(int port)

    : : {

    : : unsigned char value;



    : : _asm mov dx,port

    : : _asm in al,dx

    : : _asm mov value,al



    : : return value;

    : : }



    :

    :






Sign In or Register to comment.