Solved

outportb in WIN32

Posted on 1997-01-31
1
673 Views
Last Modified: 2013-12-04
A group at Queen's University is trying to implement the (out,in)portb command in an WIN32 program. We are using the command to directly control the digital port of a National Instruments A/D card. In a 16-bit Dos application, we could simply use the (in,out)portb command, but when trying to create a 32-bit windows GUI application, Borland C++ 5.0 won't compile the program. Checking the help manual and the compatibility list for certain commands, it lists that (in,out)portb is not avaliable to WIN32. Is there any way around this in a WIN95 environment to use the outportb command in a 32-bit application. If so, how would one do it? (does it possibly involve accessing the EISA.vxd file in windows 95?)

Thanks for such consideration,

Yael Maguire
Queen's University, Kingston, Ontario.
0
Comment
Question by:yael
1 Comment
 
LVL 1

Accepted Solution

by:
glittle earned 50 total points
ID: 1298619
2 possible methods that should work for Win95.

1.  If your compiler has inline assembly, use it to insert the proper assembly calls.

unsigned char inportb(int port)
{
    _asm {
        mov    dx, port
        xor      ax,ax
        in         al, dx
    }
    return;
}

void outputb(int port, char ch)
{
    _asm {
        mov    dx, port
        xor       ax,ax
        mov    al, ch
        out       dx, al
    }
    return;
}

These examples are for Microsoft C, but should give you the basic concept.  


2.  Write 2 assembly language functions and link them with your C program.  The assembly used above can be the kernel code for these functions.  You simply need to know how to interface assembly with Borlannd's C++ 5.0 environment.

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question