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

junk value in variable

void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb)
{
unsigned long ulvald;
abb=2;
ulvald=0;
//fl_ad=(volatile unsigned long *)0x8020;
ulvald= *(fl_ad);
//return ucVal;
}

in the above prg the value of abb is shown as 2 but the value of
ulvald does not show 0 it shows a junk value in the debugger memeory
window
Nov 14 '05 #1
5 2976
risha wrote:
void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb)
{
unsigned long ulvald;
abb=2;
ulvald=0;
//fl_ad=(volatile unsigned long *)0x8020;
ulvald= *(fl_ad);
what if fl_ad is NULL? check for ptr==Null before dereferencing.

you have updated the value of ulvald with the value @ fl_ad. Why should
it should show 0?
//return ucVal;
}

in the above prg the value of abb is shown as 2 but the value of
ulvald does not show 0 it shows a junk value in the debugger memeory
window


Why should it be junk value? You are passing a pointer to FlashReadM,
so my assumption is that you want to read the value at location pointed
to by fl_ad, which must not be junk or else why read it?

Its junk to you beacuase you expect 0, but it would probably certianly
make sense for the FlashReadM! Ask Him.

HTH
--
Taran

Nov 14 '05 #2
risha wrote:
void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb)
{
unsigned long ulvald;
abb=2;
ulvald=0;
//fl_ad=(volatile unsigned long *)0x8020;
ulvald= *(fl_ad);
what if fl_ad is NULL? check for ptr==Null before dereferencing.

you have updated the value of ulvald with the value @ fl_ad. Why should
it should show 0?
//return ucVal;
}

in the above prg the value of abb is shown as 2 but the value of
ulvald does not show 0 it shows a junk value in the debugger memeory
window


Why should it be junk value? You are passing a pointer to FlashReadM,
so my assumption is that you want to read the value at location pointed
to by fl_ad, which must not be junk or else why read it?

Its junk to you beacuase you expect 0, but it would probably certianly
make sense for the FlashReadM! Ask Him.

HTH
--
Taran

Nov 14 '05 #3
Thank u for the reply sir. But the mistake lies on my part in not
making things clear. For conveinence I have numbered the prm
statements.

1.void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb)
{
2. unsigned long ulvald;
3. abb=2;
4. ulvald=0;
5. //fl_ad=(volatile unsigned long *)0x8020;
6. ulvald = *(fl_ad);
7. return ulvald;
}
************************************************** *****************
1>My question is in line #4 the varaible ulvald is assigned 0 after
line #4 is executed it should have initialzed the variable ulvald as 0
at this point.
(memory in the debugger window indicates junk value)

2>When it reaches line #6 it should now load the value which is at
address location fl_ad which has the value passed as a parameter in
the function.The value at that location here in my case 0x8020 has
value 0x03.After the execution of line #6 in the debugger window for
memory it should indicate the new value atleast but here it neither
shows 0 in the beginnning nor 3 as the value.So it is junk value
again!!!
3>"what if fl_ad is NULL? check for ptr==Null before dereferencing."
The debugger indicates the correct address 0x8020.Hence not null.

4>so my assumption is that you want to read the value at location
pointed
to by fl_ad,

Absolutely right sir thats what I am trying to do.

Probably since it did not even initiaze i think something is really
wrong here....

I am a student and any help will do me good,(sorry for the long
message)
Thanks in advance,
Nov 14 '05 #4
risha wrote:

Thank u for the reply sir. But the mistake lies on my part in not
making things clear. For conveinence I have numbered the prm
statements.

1.void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb) {
2. unsigned long ulvald;
3. abb=2;
4. ulvald=0;
5. //fl_ad=(volatile unsigned long *)0x8020;
6. ulvald = *(fl_ad);
7. return ulvald;
}
************************************************** *****************
1> My question is in line #4 the varaible ulvald is assigned 0 after
line #4 is executed it should have initialzed the variable ulvald as
0 at this point. (memory in the debugger window indicates junk value)


What sort of optimization is the compiler doing? There is no
reason for it to generate any code for line 4, because that value
is never used, and is immediately overwritten by line 6.

BTW, please DO NOT use nuisance abbreviations such as 'u' or
'prm'. They only serve to make your article hard to read and to
annoy.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #5
risha wrote:

Thank u for the reply sir. But the mistake lies on my part in not
making things clear. For conveinence I have numbered the prm
statements.

1.void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb) {
2. unsigned long ulvald;
3. abb=2;
4. ulvald=0;
5. //fl_ad=(volatile unsigned long *)0x8020;
6. ulvald = *(fl_ad);
7. return ulvald;
}
************************************************** *****************
1> My question is in line #4 the varaible ulvald is assigned 0 after
line #4 is executed it should have initialzed the variable ulvald as
0 at this point. (memory in the debugger window indicates junk value)


What sort of optimization is the compiler doing? There is no
reason for it to generate any code for line 4, because that value
is never used, and is immediately overwritten by line 6.

BTW, please DO NOT use nuisance abbreviations such as 'u' or
'prm'. They only serve to make your article hard to read and to
annoy.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #6

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

Similar topics

6
by: John Ramsden | last post by:
.... when the id 'junk' doesn't exist anywhere in the document, instead of returning 'object'?! I am using Javascript for a drop-down menu, slightly adapted from one by Angus Turnbull (see...
1
by: Denzil | last post by:
Hi, I am retrieving my DB values and setting them in the MyRS::DoFieldExchange(CFieldExchange* pFX) function. One of these records is a Long datatype and could be "Null" in the DB table. The...
2
by: not aaron | last post by:
I start out with a string. Which I then encode with my own algorithm changing every characters ascii value depending on a key. I then save it to a binary file. When I generate the initial...
16
by: Jeff | last post by:
Im trying to memcpy a buffer from a filled in simple structure. When I memcpy and then print the resulting buffer, I see 7 locations that have junk before my data starts. My data structure is: ...
14
by: HB | last post by:
As many of us know, when we send legitimate emails to real customers from our apps, those emails often end up in the Hotmail (and MSN -- and AOL, too) junk folder. I've done a lot of testing with...
1
by: Vinod | last post by:
Hi, In VC8 project, I am having a struct which is having a char* variable. Now I am creating a 3 elements array object for the struct. I send the base address of the object using VARIANT to a...
1
davydany
by: davydany | last post by:
Hey guys...a n00b Here for this site. I'm making a sequence class for my C++ class. And The thing is in the array that I have, lets say i put in {13,17,38,18}, when i see the current values for the...
4
by: situ | last post by:
Hello all, i have a column in a table which stores tag lines which are usually less than 500 charecter. when we display the data through the browser some character display as "boxes" or junks....
1
by: Pradeep | last post by:
Hi All, I am facing an issue where length method of std::string class gives a junk value when used in a expression. Here's an example. The code should not go into the for loop but it does...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.