Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3711
Number of posts: 9173

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Edit Report
inp, outp in Windows 95 Posted by Paul Lalli on 10 Jun 1999 at 8:31 AM
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?<p>
Paul Lalli <p>



Edit Report
Re: inp, outp in Windows 95 Posted by sharpshutter on 10 Jun 1999 at 1:37 PM
Hi,<p>
maybe you should try using assembly for your low level I/O.<p>
here are some functions (the "_asm" keyword is used to indicate assembly command) :<p>
void outp(int port,unsigned char value)<br>
{<br>
_asm mov dx,port<br>
_asm mov al,value<br>
_asm out dx,al<br>
}<p>
unsigned char inp(int port)<br>
{<br>
unsigned char value;<p>
_asm mov dx,port<br>
_asm in al,dx<br>
_asm mov value,al<p>
return value;<br>
}


Edit Report
Re: inp, outp in Windows 95 Posted by Paul Lalli on 11 Jun 1999 at 8:38 AM
Hello. <p>
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?<p>
Paul Lalli<p>
: Hi,<p>
: maybe you should try using assembly for your low level I/O.<p>
: here are some functions (the "_asm" keyword is used to indicate assembly command) :<p>
: void outp(int port,unsigned char value)<br>
: {<br>
: _asm mov dx,port<br>
: _asm mov al,value<br>
: _asm out dx,al<br>
: }<p>
: unsigned char inp(int port)<br>
: {<br>
: unsigned char value;<p>
: _asm mov dx,port<br>
: _asm in al,dx<br>
: _asm mov value,al<p>
: return value;<br>
: }<p>



Edit Report
Re: Re: inp, outp in Windows 95 Posted by B. Bober on 22 Apr 2000 at 5:58 PM
It should work - try <br>
_asm{<br>
<br>
asm code here<br>
<br>
<br>
}<br>
<br>
or<br>
<br>
__asm{<br>
<br>
<br>
asm code here<br>
<br>
}<br>
: Hello. <br>
<br>
: 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?<br>
<br>
: Paul Lalli<br>
<br>
: : Hi,<br>
<br>
: : maybe you should try using assembly for your low level I/O.<br>
<br>
: : here are some functions (the "_asm" keyword is used to indicate assembly command) :<br>
<br>
: : void outp(int port,unsigned char value)<br>
: : {<br>
: : _asm mov dx,port<br>
: : _asm mov al,value<br>
: : _asm out dx,al<br>
: : }<br>
<br>
: : unsigned char inp(int port)<br>
: : {<br>
: : unsigned char value;<br>
<br>
: : _asm mov dx,port<br>
: : _asm in al,dx<br>
: : _asm mov value,al<br>
<br>
: : return value;<br>
: : }<br>
<br>
: <br>
: <br>
<br>



Edit Report
Re: inp, outp in Windows 95 Posted by Paul Lalli on 11 Jun 1999 at 8:38 AM
Hello. <p>
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?<p>
Paul Lalli<p>
: Hi,<p>
: maybe you should try using assembly for your low level I/O.<p>
: here are some functions (the "_asm" keyword is used to indicate assembly command) :<p>
: void outp(int port,unsigned char value)<br>
: {<br>
: _asm mov dx,port<br>
: _asm mov al,value<br>
: _asm out dx,al<br>
: }<p>
: unsigned char inp(int port)<br>
: {<br>
: unsigned char value;<p>
: _asm mov dx,port<br>
: _asm in al,dx<br>
: _asm mov value,al<p>
: return value;<br>
: }<p>



Edit Report
Re: inp, outp in Windows 95 Posted by sharpshutter on 10 Jun 1999 at 1:37 PM
Hi,<p>
maybe you should try using assembly for your low level I/O.<p>
here are some functions (the "_asm" keyword is used to indicate assembly command) :<p>
void outp(int port,unsigned char value)<br>
{<br>
_asm mov dx,port<br>
_asm mov al,value<br>
_asm out dx,al<br>
}<p>
unsigned char inp(int port)<br>
{<br>
unsigned char value;<p>
_asm mov dx,port<br>
_asm in al,dx<br>
_asm mov value,al<p>
return value;<br>
}


Edit Report
Re: inp, outp in Windows 95 Posted by Geovany on 19 Oct 1999 at 11:06 AM
Dear Paul Alli,<p>
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.<p>
Geovany.<p>






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.