using hardware port-address 
Author Message
 using hardware port-address

How can i use an i/o port off my computer in CBuilder ?
I want to read/write data from/to an i/o port. In Pascal you can use the
command port[address] := value but what is the equivalent of this in C

Question 2
How can I use basic code in a C program. The reason is that I'm writing a
program for a CPU on an add-on card that is using a basic-dialect.

Maurice Lucas



Sat, 02 Nov 2002 03:00:00 GMT  
 using hardware port-address
On Tue, 16 May 2000 11:31:21 +0200, "MS Lucas"

Quote:

>How can i use an i/o port off my computer in CBuilder ?
>I want to read/write data from/to an i/o port. In Pascal you can use the
>command port[address] := value but what is the equivalent of this in C

This question is off topic for this newsgroup. Better luck in the many
other ng's you posted to.

Quote:
>Question 2
>How can I use basic code in a C program. The reason is that I'm writing a
>program for a CPU on an add-on card that is using a basic-dialect.

You cannot. Basic, especially interpreted basic, is an unlikely candidate
for interlanguage procedure calling. It really isn't that hard to simply
transcribe BASIC to C. The other way around can be quite gross however.


Sat, 02 Nov 2002 03:00:00 GMT  
 using hardware port-address
using basic code in c:
put the basic code in a .dll file, and make sure that both the dll and the
calls your program makes to functions in this dll use the same calling
convention for parameters.


Quote:
>How can i use an i/o port off my computer in CBuilder ?
>I want to read/write data from/to an i/o port. In Pascal you can use the
>command port[address] := value but what is the equivalent of this in C

>Question 2
>How can I use basic code in a C program. The reason is that I'm writing a
>program for a CPU on an add-on card that is using a basic-dialect.

>Maurice Lucas



Sat, 02 Nov 2002 03:00:00 GMT  
 using hardware port-address


Quote:
> How can i use an i/o port off my computer in CBuilder ?
> I want to read/write data from/to an i/o port. In Pascal you can use
the
> command port[address] := value but what is the equivalent of this in C

> Question 2
> How can I use basic code in a C program. The reason is that I'm
writing a
> program for a CPU on an add-on card that is using a basic-dialect.

> Maurice Lucas

Since other people are giving platform specific advice, I'll chip in my
two cents:

The method I use to access hardware is to use a pointer and assign the
hardware item's address into the pointer.  The pointer's type depends on
the data width of the hardware item.  For example:

const volatile unsigned int * Uart_Base_Ptr =
    (volatile unsigned int *) (0xFFFD0000);

and
unsigned int Uart_Value = *Uart_Base_Ptr;

Just remember that you want to make sure that the pointer points to a
volatile location because the hardware devices may change their data
values without telling the program.

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 02 Nov 2002 03:00:00 GMT  
 using hardware port-address
I'm not sure how to do it CBuilder but in Turbo C there is a command called
outportb and inportb that can be used to send data to and recieve data from
any direct address port.
On solution is to write assembly code to directly address a port.  Of course
this is processor dependent.  And I don't know if Cbuilder supports machine
code but in Metroworks Codewarrior the assemble code is as follows for a x86
intel processor.

Output:
oid __declspec({*filter*}) _outpw(unsigned short port, unsigned short val)
{
  asm {
    push edx
    mov dx, port
    mov ax, val
    out dx, ax
    pop edx
    ret
  }

Quote:
}

Input:
unsigned short __declspec({*filter*}) _inpw(unsigned short port)
{
  asm {
    push edx
    mov dx, port
    in ax, dx
    pop edx
    ret
  }

Quote:
}

And question 2 I don't know. Sorry
Hope this is of some help,
Bryan Mills
Quote:

> How can i use an i/o port off my computer in CBuilder ?
> I want to read/write data from/to an i/o port. In Pascal you can use the
> command port[address] := value but what is the equivalent of this in C

> Question 2
> How can I use basic code in a C program. The reason is that I'm writing a
> program for a CPU on an add-on card that is using a basic-dialect.

> Maurice Lucas



Sun, 03 Nov 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. reading and writing to a port address using Visual C++

2. Getting LPT port address under Windows 9x using VC++ 6.0

3. Getting LPT port address under Windows 9x using VC++ 6.0

4. how to directly address an I/O Port in VC++ using MFC functions

5. Getting a hardware address?

6. Hardware Addressing from Windows via FP

7. Reading hardware addresses

8. NIC hardware address

9. Interpreting a Hardware Address

10. hardware port i/o

11. In/output byte to hardware port in Win32?

12. Accessing Hardware Port

 

 
Powered by phpBB® Forum Software