🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #333

Re: using hardware port-address

#333
From: b_mills
Date: Wed, 17 May 2000 00:00
48 lines
2392 bytes
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(naked) _outpw(unsigned short port, unsigned short val)
{
  asm {
    push edx
    mov dx, port
    mov ax, val
    out dx, ax
    pop edx
    ret
  }
}

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

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

MS Lucas wrote:

> 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
Technical Details
Message-ID: <39220FE4.97EDB1E7@po.bethanywv.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <#5SATlxv$GA.170@net003s>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8d38,5a4aa760b0ec40a
X-Google-Attributes: gidf8d38,public
X-Google-Thread: 109fba,5a4aa760b0ec40a
X-Google-Attributes: gid109fba,public
X-Google-Thread: 114592,5a4aa760b0ec40a
X-Google-Attributes: gid114592,public
X-Google-Thread: 1014db,5a4aa760b0ec40a
X-Google-Attributes: gid1014db,public
X-Google-Thread: 103c8d,5a4aa760b0ec40a
X-Google-Attributes: gid103c8d,public
From: b_mills <b_mills@po.bethanywv.edu>
Subject: Re: using hardware port-address
Date: 2000/05/17
Message-ID: <39220FE4.97EDB1E7@po.bethanywv.edu>
X-Deja-AN: 624360347
Content-Transfer-Encoding: 7bit
References: <#5SATlxv$GA.170@net003s>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@worldnet.att.net
X-Trace: bgtnsc04-news.ops.worldnet.att.net 958534111 12.79.48.50 (Wed, 17 May 2000 03:28:31 GMT)
Organization: AT&T Worldnet
MIME-Version: 1.0
NNTP-Posting-Date: Wed, 17 May 2000 03:28:31 GMT
Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.language,borland.public.cppbuilder.language,comp.lang.c,comp.lang.c++