473,503 Members | 2,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading macro

hi

I have some trouble reading this macro:

#define SMC_inl(r) (*((volatile dword *)(SMC_BASE_ADDRESS+(r))))

also consider that SMC_BASE_ADDRESS is address base of I/O mapped
peripherial registers, r is register offset.
Does that read: return 32bits of data stored in memory location
SMC_BASE_ADDRESS+r.

with this "(volatile dword *)" we are casting pointer to point to 32bit
wide address and first * means get the value stored at that address.

Am i reading this right ?

regards, himba
Nov 14 '05 #1
3 1822

"roaher" <go***@email.si> wrote in message
I have some trouble reading this macro:

#define SMC_inl(r) (*((volatile dword *) (SMC_BASE_ADDRESS+(r))))

does that read: return 32bits of data stored in memory location
SMC_BASE_ADDRESS+r.
Presumably SMC_BASE_ADDRESS is defined as a constant. You will add r to that
address, and then cast the result to a dword *.
You then read the dword (probably 32 bits) from that address.
with this "(volatile dword *)" we are casting pointer to point to 32bit
wide address and first * means get the value stored at that address.

Yes. It is rather confusing that in C * is used both to declare a pointer.

char *ptr; /* ptr is variable of type char pointer */

and as the indirection operator

*ptr = 'X'; /* write the character 'X' to location pointer to by ptr */

The "volatile" just means that the variable will never be held temporarily
in a register, which makes sense for memory mapped io.
Nov 14 '05 #2
>Yes. It is rather confusing that in C * is used both to declare a pointer.

char *ptr; /* ptr is variable of type char pointer */

and as the indirection operator

*ptr = 'X'; /* write the character 'X' to location pointer to by ptr */


As long as the people implementing the compiler got it to work as they wanted,
there is nothing against it.
(/* */ Exception holds)

Nov 14 '05 #3
On Sun, 22 Feb 2004 19:15:32 +0100, roaher <go***@email.si> wrote:
hi

I have some trouble reading this macro:

#define SMC_inl(r) (*((volatile dword *)(SMC_BASE_ADDRESS+(r))))

also consider that SMC_BASE_ADDRESS is address base of I/O mapped
peripherial registers, r is register offset.
Does that read: return 32bits of data stored in memory location
SMC_BASE_ADDRESS+r.

with this "(volatile dword *)" we are casting pointer to point to 32bit
wide address and first * means get the value stored at that address.

Am i reading this right ?

regards, himba


It depends on the definition of SMC_BASE_ADDRESS.

If it is a numeric constant or variable, then the value of the
expression (r) added to the value of SMC_BASE_ADDRESS using normal
arithmetic, the resulting value is treated as the address of a dword
(which is not a standard type), and the value of the dword at that
address is the result of the expression. If the address is not
properly aligned for a dword, it invokes undefined behavior.

If it is a pointer expression, then the value of the expression
(r) is added to the value of SMC_BASE_ADDRESS using pointer arithmetic
(where +1 means the number of bytes in one object of the type the
pointer points to), the resulting value is treated the same as above.

For what it's worth, the second '(' and the next to last ')' are
superfluous.
<<Remove the del for email>>
Nov 14 '05 #4

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

Similar topics

2
3461
by: Pete | last post by:
In Access 95/97 I used to be able to create pull down menus (File,Edit ...) from a macro. It seems there used to be some wizard for that. However in Access 2000 it seems you have to build your...
3
1562
by: J Krugman | last post by:
I'm trying to read some source code that makes very heavy use of macros and other pre-processor directives. To make matters worse, macro definitions are stacked several layers deep (i.e. macros...
50
4879
by: Michael Mair | last post by:
Cheerio, I would appreciate opinions on the following: Given the task to read a _complete_ text file into a string: What is the "best" way to do it? Handling the buffer is not the problem...
13
13205
by: nuti | last post by:
Hi all, I am fairly new to VB.I am trying to figure out as how to write a script so that i can read the data from an excel sheet to Access. can u guys please help me out? cheers, nuti
2
3233
by: Paul M | last post by:
Hello, is there any way of reading Microsoft Access Macros via VBA code? Or better still through VB .net code? By reading I mean being able to read what the actions are plus any parameters &...
111
19921
by: Tonio Cartonio | last post by:
I have to read characters from stdin and save them in a string. The problem is that I don't know how much characters will be read. Francesco -- ------------------------------------- ...
1
2171
by: Roy | last post by:
Hi all, Thanks for your replies.I have to develop an application which will read a .DAT file.There are several hundred records in this file.Also I get another excel file with adds and deletes....
9
2643
by: mattia | last post by:
I've came up with this: FILE *fd; char buf; char fmt; /* open fd */ sprintf(fmt, "%%%ds", sizeof(buf)-1); while (fscanf(fd, fmt, buf) != EOF) use_word(strdup(buf));
41
5339
by: biplab | last post by:
Hi all, I want to read the pixel values of a .bmp image(which will be input to the code) into a matrix...plz help me out as i can not understand how to achieve this... thanks in advance ...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.