Solved

outportb in WIN32

Posted on 1997-01-31
1
652 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now