Topic: Newbie help on memory access


Author: esap@mustarastas.cs.tut.fi (Pulkkinen Esa)
Date: 14 Nov 1994 12:11:54 GMT
Raw View
David Sachs (b91926@fsgm01.fnal.gov) wrote:
: Use a cast. The exact form is implementation dependent but you should
: try something like:

: #define printer_port char*(0x378)

I think the construct "char*(0x378)" is illegal. At least the ARM requires the
use of the alternative cast syntax for complex types, so you have to write:

#define printer_port ((char*)(0x378))

Another thing: I doubt that the original question was about pointer to
a fixed address in memory, but instead about a pointer to a I/O address
space, which isn`t mapped to memory (on PC's), and accessing it requires
the use of implementation-dependent features, like the "outportb"-macro
in Borland's compilers. One can always define a class, which acts as a
pointer to the I/O space.
--
   Esa Pulkkinen                        | C++ programmers do it virtually
   E-Mail:  esap@cs.tut.fi              | everywhere with a class, resulting
   WWW   :  http://www.cs.tut.fi/~esap/ | in multiple inheritance.





Author: je@unix.brighton.ac.uk (John English)
Date: Wed, 16 Nov 1994 14:36:31 GMT
Raw View
David Sachs (b91926@fsgm01.fnal.gov) wrote:
: Tigger <esi008@coventry.ac.uk> writes:
: > I'm trying to access memory space ($378 to be precise) so that I
: >can do bit manipulations on it - the area is the printer port data register.
: > How do i set a pointer to the area???
: > I would like to #define this as a base address and access it directly
: >as there are control and status registers that I will also need.
: > Anything would help....(this is probably a dumb question and
: >deserves the flames!!)

: Use a cast. The exact form is implementation dependent but you should
: try something like [... snip ...]

a) comp.std.c++ is the wrong place to ask this!
b) this looks like a PC problem.  The printer port is indeed 0x378, but it's
   an I/O port, not a memory address, so casting won't help.  Look in your
   manual for "inport" and "outport" or some such similar names.

--
-------------------------------------------------------------------------------
John English                    | Thoughts for the day:
Dept. of Computing              | - People who live in windowed environments
University of Brighton          |   shouldn't cast pointers
E-mail: je@brighton.ac.uk       | - In C++ only your friends can access your
Fax:    0273 642405             |   private parts
-------------------------------------------------------------------------------




Author: Tigger <esi008@coventry.ac.uk>
Date: Fri, 11 Nov 1994 14:48:58 +0000 (WET)
Raw View
 I'm trying to access memory space ($378 to be precise) so that I
can do bit manipulations on it - the area is the printer port data register.

 How do i set a pointer to the area???

 I would like to #define this as a base address and access it directly
as there are control and status registers that I will also need.

 Anything would help....(this is probably a dumb question and
deserves the flames!!)


  Ta

   Guy







Author: b91926@fsgm01.fnal.gov (David Sachs)
Date: 11 Nov 1994 11:33:30 -0600
Raw View
Tigger <esi008@coventry.ac.uk> writes:


> I'm trying to access memory space ($378 to be precise) so that I
>can do bit manipulations on it - the area is the printer port data register.

> How do i set a pointer to the area???

> I would like to #define this as a base address and access it directly
>as there are control and status registers that I will also need.

> Anything would help....(this is probably a dumb question and
>deserves the flames!!)


Use a cast. The exact form is implementation dependent but you should
try something like:

#define printer_port char*(0x378)

or use a const pointer

static char * const printer_port = char*(0x378);

("static" is really redundant in this construct but is included for
clarity)