473,322 Members | 1,417 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,322 software developers and data experts.

What does it mean

rsk
Hi Friends,

Can you please explain me what's the menaing of the following statement

*((volatile uint *) 0x00450000) = 0x00012345;

With Regards,
SS..

--
Message posted using http://www.talkaboutprogramming.com/group/comp.lang.c/
More information at http://www.talkaboutprogramming.com/faq.html

Sep 24 '07 #1
7 3150
It means

(volatile uint *) 0x00450000
a pointer to a place in memory

*((volatile uint *) 0x00450000)
this is the memory it points to
*((volatile uint *) 0x00450000) = 0x00012345;
the memory is filled with a number

The procedure looks not save to use!
U are filling hard a peice of the memory without knowing anything
about this memory.

Greetings Olaf

Sep 24 '07 #2
rsk said:
Hi Friends,

Can you please explain me what's the menaing of the following statement

*((volatile uint *) 0x00450000) = 0x00012345;
At a syntactical level, it means "convert 4521984 to a pointer to a
volatile uint (possibly losing information in the process), and set the
value of the thus-pointed-to uint object (which may not exist, or which
may not be a uint, or which may not be properly aligned for a uint) to
74565, and to Hades with the consequences".

At the behavioural and semantic levels, the C language imposes no meaning
on the code - the uint is undefined, and so is the behaviour.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 24 '07 #3
rsk:
*((volatile uint *) 0x00450000) = 0x00012345;

This is platform-specific, non-portable code.

What it does is the following:

Treat the memory address 0x00450000 as if it were storage for
uint, and then store the value 0x00012345 at that address.

The volatile, from what I can gather, is superfluous (...but then
again your particular system might have something funky going on).

In the realms of portable programming though, the behaviour of the
statement is not defined by the Standard so it can do (or not do)
whatever it wants.

Martin

Sep 24 '07 #4
On Mon, 24 Sep 2007 00:15:17 -0700, mdler wrote:
It means

(volatile uint *) 0x00450000
a pointer to a place in memory

*((volatile uint *) 0x00450000)
this is the memory it points to
*((volatile uint *) 0x00450000) = 0x00012345;
the memory is filled with a number

The procedure looks not save to use!
U are filling hard a peice of the memory without knowing anything
about this memory.
Supposing the OP copied that statement from somewhere, it is very
likely that whoever wrote it *did* know that. (Of course that
knowledge is OT here.)
BTW
s/save/safe/
s/U/You/
s/peice/piece/
--
Army1987 (Replace "NOSPAM" with "email")
A hamburger is better than nothing.
Nothing is better than eternal happiness.
Therefore, a hamburger is better than eternal happiness.

Sep 24 '07 #5
In article <11*********************@k79g2000hse.googlegroups. com>,
Martin Wells <wa****@eircom.netwrote:
>*((volatile uint *) 0x00450000) = 0x00012345;
>The volatile, from what I can gather, is superfluous (...but then
again your particular system might have something funky going on).
Presumably it's to ensure that the compiler doesn't think "I just set
that location to that value a few lines up, so I don't need to do it
again".
>In the realms of portable programming though, the behaviour of the
statement is not defined by the Standard so it can do (or not do)
whatever it wants.
The standard defines the volatile modifier and allows thet casting of
integers to pointers precisely so that you can do this kind of thing,
so a compiler that really did "whatever it wants" would be a poor one.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Sep 24 '07 #6
Martin Wells wrote:
rsk:
>*((volatile uint *) 0x00450000) = 0x00012345;


This is platform-specific, non-portable code.
This look like low-level code, perhaps a device driver, which is
typically written in C.

What it does is the following:

Treat the memory address 0x00450000 as if it were storage for
uint, and then store the value 0x00012345 at that address.

The volatile, from what I can gather, is superfluous (...but then
again your particular system might have something funky going on).
Not at all. The type qualifier volatile, might be rather important here,
when you want to touch HW, volatile tell the program *not* to just
access the cache (and the compiler not to optimize).
--
Tor <torust [at] online [dot] no>
Sep 24 '07 #7
On Sep 25, 12:44 am, Tor Rustad <tor_rus...@hotmail.comwrote:
Martin Wells wrote:
rsk:
*((volatile uint *) 0x00450000) = 0x00012345;
This is platform-specific, non-portable code.

This look like low-level code, perhaps a device driver, which is
typically written in C.
What it does is the following:
Treat the memory address 0x00450000 as if it were storage for
uint, and then store the value 0x00012345 at that address.
The volatile, from what I can gather, is superfluous (...but then
again your particular system might have something funky going on).

Not at all. The type qualifier volatile, might be rather important here,
when you want to touch HW, volatile tell the program *not* to just
access the cache (and the compiler not to optimize).
Volatile is a Qualifier.
It is very common in Embedded to declare status register as volatile.
It implies that it can be changed by external hardware at any point of
time during the lifetime of the program and
the compiler must not optimise it if it is not used in the current
program.
It is for optimisation .

Karthik Balaguru

Sep 25 '07 #8

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

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
3
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification...
86
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that:...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
2
by: Steve Richter | last post by:
What does the "." mean in the following sql script stmts? use GO if exists (select * from dbo.sysobjects where id = object_id(N'.') and OBJECTPROPERTY(id,N'IsUserTable') = 1) drop table ....
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
1
by: Frank Rizzo | last post by:
Some of the classes in the framework are marked as thread-safe in the documentation. In particular the docs say the following: "Any public static (*Shared* in Visual Basic) members of this type...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
9
by: JoeC | last post by:
m_iWidth = (int)pBitmapInfo->bmiHeader.biWidth; m_iHeight = (int)pBitmapInfo->bmiHeader.biHeight; What does this mean? I have seen v=&var->member.thing; but what does it mean when you...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.