473,385 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to access processor registers

In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?

Mar 31 '07 #1
16 8967
dspfun wrote:
In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?
There isn't a general answer. Not many processors have registers that
can be memory mapped.

Most compilers provide a means to embed assembly language, but you will
have to ask on a compiler and platform specific group.

--
Ian Collins.
Mar 31 '07 #2
"dspfun" <ds****@hotmail.comwrites:
In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?
C doesn't provide any portable means to do either one. I'd
advise you to seek help in a forum dedicated to your particular C
implementation.

Also: on most CPUs, the registers do not have addresses.
--
Comp-sci PhD expected before end of 2007
Seeking industrial or academic position *outside California* in 2008
Mar 31 '07 #3
dspfun wrote, On 31/03/07 22:57:
In general, how do you read contents of the CPU's registers
Last time I did it I used an In-Circuit Emulator
and how do
you get hold of the addresses of the CPU's registers?
What makes you think they have addresses?

Also, what makes you think this is a C question?
--
Flash Gordon
Mar 31 '07 #4
Ben Pfaff wrote:
"dspfun" <ds****@hotmail.comwrites:
>In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?
Either with target-specific compiler extensions or assembly language.
Also: on most CPUs, the registers do not have addresses.
<OT>
I would say that that the register addresses are in a different memory
space on many processors. In some cases, you need to go through
multiple levels of selection or addressing to access the register. With
memory protection, I/O register access is typically denied to processes
running in user space.
</OT>

--
Thad
Apr 1 '07 #5
dspfun wrote:
>
In general, how do you read contents of the CPU's registers and
how do you get hold of the addresses of the CPU's registers?
What registers? C runs quite well on register free machines.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com

Apr 1 '07 #6
>>In general, how do you read contents of the CPU's registers and how do
>>you get hold of the addresses of the CPU's registers?
C doesn't provide any portable means to do either one. I'd
advise you to seek help in a forum dedicated to your particular C
implementation.

Also: on most CPUs, theregistersdo not have addresses.
Thanks, that's why I haven't found a way to do this using C.

Apr 1 '07 #7
dspfun wrote:
>In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?
C doesn't provide any portable means to do either one. I'd
advise you to seek help in a forum dedicated to your particular C
implementation.

Also: on most CPUs, theregistersdo not have addresses.

Thanks, that's why I haven't found a way to do this using C.
C specifically disallows taking the address of objects qualified with
register, even if they may not actually be stored in machine
registers. There're also some more limitations for objects qualified
with register. Under modern compilers, register is of little, if any,
usefulness.

Apr 1 '07 #8
On Apr 1, 10:56 am, "santosh" <santosh....@gmail.comwrote:
Thanks, that's why I haven't found a way to do this using C.

C specifically disallows taking the address of objects qualified with
register, even if they may not actually be stored in machine
registers. There're also some more limitations for objects qualified
with register. Under modern compilers, register is of little, if any,
usefulness.
Well as I read somewhere recently, the main audience for your code
isn't so much the compiler as a hypothetical future maintainer of your
code. And the register keyword surely transmits useful information
about the variable to him or her - ie that it's a key variable that
will be heavily used throughout the function.

Apr 1 '07 #9
Fr************@googlemail.com wrote:
On Apr 1, 10:56 am, "santosh" <santosh....@gmail.comwrote:
>>>Thanks, that's why I haven't found a way to do this using C.

C specifically disallows taking the address of objects qualified with
register, even if they may not actually be stored in machine
registers. There're also some more limitations for objects qualified
with register. Under modern compilers, register is of little, if any,
usefulness.


Well as I read somewhere recently, the main audience for your code
isn't so much the compiler as a hypothetical future maintainer of your
code. And the register keyword surely transmits useful information
about the variable to him or her - ie that it's a key variable that
will be heavily used throughout the function.
That should be obvious from inspection. Like any superfluous
documentation, it also has to be maintained. So when the function is
refactored and the variable is no longer important, you have to remember
to remove the unnecessary keyword.

--
Ian Collins.
Apr 1 '07 #10

Fr************@googlemail.com wrote:
On Apr 1, 10:56 am, "santosh" <santosh....@gmail.comwrote:
Thanks, that's why I haven't found a way to do this using C.
C specifically disallows taking the address of objects qualified with
register, even if they may not actually be stored in machine
registers. There're also some more limitations for objects qualified
with register. Under modern compilers, register is of little, if any,
usefulness.

Well as I read somewhere recently, the main audience for your code
isn't so much the compiler as a hypothetical future maintainer of your
code. And the register keyword surely transmits useful information
about the variable to him or her - ie that it's a key variable that
will be heavily used throughout the function.
IMHO, the register keyword is a poor way to do this. If you keep your
functions short in length and purpose, it ought to be easy enough to
determine the relative use of it's objects.

Apr 2 '07 #11
At about the time of 3/31/2007 2:57 PM, dspfun stated the following:
In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?
The short answer? You don't. The compiler takes care of it for you.

CPU registers are, by definition, in the CPU, not memory. So they don't
have addresses per say.
--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
Apr 5 '07 #12
Daniel Rudy wrote:
At about the time of 3/31/2007 2:57 PM, dspfun stated the following:
>>In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?


The short answer? You don't. The compiler takes care of it for you.

CPU registers are, by definition, in the CPU, not memory. So they don't
have addresses per say.
Have you ever used an 8051?

--
Ian Collins.
Apr 5 '07 #13
>>>In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?
Daniel Rudy wrote:
>The short answer? You don't. The compiler takes care of it for you.
CPU registers are, by definition, in the CPU, not memory. So they
don't have addresses per say.
On Fri, 06 Apr 2007 10:32:41 +1200, Ian Collins wrote:
Have you ever used an 8051?
Some modesl of the IBM 1130 stored the index register in memory. Some
microprocessor (TI9900, IIRC) used a single hardware register to point
to a block of memory locations containing the "registers". The Microdata
Reality series had a memory resident "accumulator", which was occasionally
loaded with a two character subroutine "op<number>; return;" to make up
for a handful of opcodes that had a constant where they should have had
an index. Way Back Then, registers weren't that much faster than memory.
Your token olde farte,

Martin
--
Martin Golding | When _I_ started programming, we didn't even have _disks_.
DoD #236 | We had to use GRAD STUDENTS for SWAP.
ma************@adp.com Portland, OR
Apr 6 '07 #14
At about the time of 4/5/2007 3:32 PM, Ian Collins stated the following:
Daniel Rudy wrote:
>At about the time of 3/31/2007 2:57 PM, dspfun stated the following:
>>In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?

The short answer? You don't. The compiler takes care of it for you.

CPU registers are, by definition, in the CPU, not memory. So they don't
have addresses per say.
Have you ever used an 8051?
Actually, I have. In fact, I have a few of Atmel versions laying
around. Microcontrollers like the 8051 use memory mapped I/O...and I
think that one does have the fabled memory mapped registers (It's been
awhile).

But, once again, this is not exactly portable C code. That is specific
to that platform.

--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
Apr 6 '07 #15
At about the time of 4/5/2007 6:51 PM, Martin Golding stated the following:
>>>In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?
>Daniel Rudy wrote:
>>The short answer? You don't. The compiler takes care of it for you.
CPU registers are, by definition, in the CPU, not memory. So they
don't have addresses per say.

On Fri, 06 Apr 2007 10:32:41 +1200, Ian Collins wrote:
>Have you ever used an 8051?

Some modesl of the IBM 1130 stored the index register in memory. Some
microprocessor (TI9900, IIRC) used a single hardware register to point
to a block of memory locations containing the "registers". The Microdata
Reality series had a memory resident "accumulator", which was occasionally
loaded with a two character subroutine "op<number>; return;" to make up
for a handful of opcodes that had a constant where they should have had
an index. Way Back Then, registers weren't that much faster than memory.
Your token olde farte,

Martin
And I thought that the 8051, 8042, and their clones were the only ones
who did memory mapped registers....
--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
Apr 6 '07 #16
On Thu, 05 Apr 2007 20:51:29 -0500, Martin Golding
<fo*****@comcast.netwrote:
>
>>>>In general, how do you read contents of the CPU's registers and how do
you get hold of the addresses of the CPU's registers?
>Daniel Rudy wrote:
>>The short answer? You don't. The compiler takes care of it for you.
CPU registers are, by definition, in the CPU, not memory. So they
don't have addresses per say.

On Fri, 06 Apr 2007 10:32:41 +1200, Ian Collins wrote:
>Have you ever used an 8051?

Some modesl of the IBM 1130 stored the index register in memory. Some
microprocessor (TI9900, IIRC) used a single hardware register to point
to a block of memory locations containing the "registers".
IIRC, the TI99xx was a wide spectrum of computers based on the same
instruction set. The big thing about the register block was very fast
(for the time) context switching, each context having its own register
block.
The Microdata
Reality series had a memory resident "accumulator", which was occasionally
loaded with a two character subroutine "op<number>; return;" to make up
for a handful of opcodes that had a constant where they should have had
an index. Way Back Then, registers weren't that much faster than memory.
Your token olde farte,

Martin
--
Al Balmer
Sun City, AZ
Apr 6 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: silentlights | last post by:
Hi Guys, I am looking for an alternative means of register access in a microcontroller. Currently my get() function looks like this.. ------------------------ implementation in comm.c...
70
by: lgbjr | last post by:
Hello All, I've been developing a VB.NET app that requires the use of a DB. Up to now, I've been using Access. It's a bit slow, but everything works. I'm at a point now where I need to decide if...
12
by: rodneys | last post by:
Hi, please take a look to this sample code: class MyClass { private: static int length ; public: static void setLength(int newLength) ; void do() ;
0
by: pedz | last post by:
I am trying to write a set of classes, probably template classes, to allow "pretty" and safe access to low level machine words. The syntax I would like to end up with is something like: foo =...
2
by: tchiex | last post by:
Hello all, I'm trying to implement this interface into either a C++ dll or into the DirectShowNet dll. This interface is used by the PGR type cameras to access any register on the camera. I need to...
24
by: junky_fellow | last post by:
Hi, I am using a gcc compiler for a 32 bit powerpc processor. When I look at the size of unsigned long long, it displays 8 bytes. I was wondering, how we can have a data type of 64 bits on a 32...
168
by: broeisi | last post by:
Hello, Is there a way in C to get information at runtime if a processor is 32 or 64 bit? Cheers, Broeisi
8
by: Gerhard Fiedler | last post by:
Hello, I'm not sure whether this is a problem or not, or how to determine whether it is one. Say memory access (read and write) happens in 64-bit chunks, and I'm looking at 32-bit variables....
5
by: dissectcode | last post by:
In my code, I have bit fields in structures to access hw registers. I tested my compiler to see how it reads/writes to the registers and noticed that the compiler is trying to access the registers by...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.