473,654 Members | 3,280 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_ADD RESS+(r))))

also consider that SMC_BASE_ADDRES S 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_ADDRES S+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 1832

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

#define SMC_inl(r) (*((volatile dword *) (SMC_BASE_ADDRE SS+(r))))

does that read: return 32bits of data stored in memory location
SMC_BASE_ADDRES S+r.
Presumably SMC_BASE_ADDRES S 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_ADD RESS+(r))))

also consider that SMC_BASE_ADDRES S 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_ADDRE SS+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_ADDRES S.

If it is a numeric constant or variable, then the value of the
expression (r) added to the value of SMC_BASE_ADDRES S 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_ADDRES S 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
3482
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 menus by customizing a toolbar. With this method you have to create a separate macro for every single menu and sub menu. The old method would allow me to include several menus (File/ print/ page setup ...) all within one macro. Now it seems I...
3
1572
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 are defined in terms of other macros, which are in turn defined in terms of other macros, seemingly ad infinitum). I tried reading the *.i files generated by the preprocessor (i.e. by giving gcc the -E flag). To my surprise, the macros were not...
50
4928
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 -- the character input is a different matter, at least if I want to remain within the bounds of the standard library.
13
13222
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
3241
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 & comments. I dont want to execute any of the steps just read them. Dont want to convert them to VBA functions either, I would like to read
111
20005
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 -- ------------------------------------- http://www.riscossione.info/
1
2178
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. There are records in this Excel file with matches in the DAT file.Whereever the records are marked "deleted" in the excel file,I have to find the similar records on the DAT file and delete those records.The records marked "add" in the excel file...
9
2655
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
5379
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 biplab
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8489
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
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 we have to send another system
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.