xdata struct EEPROM {
unsigned int Last_Data; struct EEPROM *Node; };
struct EEPROM xdata * xdata p; p = (struct EEPROM xdata *)0x0FF6; if i will print the following statement printf("Size of p = %d",(unsigned int)sizeof(*p));
then it will shows the 5,but actually it should show the 4 bytes
standard programming techniques.
these "techniques" may be OK on a PC or some such thing, but when applied to the '51 without any concern for the uniqueness of the processor they become misapplied techniques.
I understand from your rants that you belong to the group that believe that the processor is there for the programmer, I happen to be of the opposite opinion.
Did you even bother to absorb (if you have that ability) "Just mentally go through the process of getting to the last entry in a linked list as opposed to getting to the last entry in an array of pointers. Point taken?"
Erik
a link list is an excellent idea if you want your project to come to a crawl
<rest of silly rant snipped>
It seems that almost every thread on this forum has attracted one of your mindless contributions. I'm sure that most people would prefer it if you could confine your comments to areas in which you have some expertise. These areas clearly do not include the 'C' programming language or standard programming techniques.
Whatever your opinions are regarding which techniques are appropriate or which subset of the 'C' language is suitable for use on an 8051 please try and remember that thse are *your opinions*, not *facts*. Unfortunately I suspect that you consider them to be facts.
"The link list is a very ineffective means of storing stuff"
Not necessarily. Linked lists are particularly useful when your data needs to be easily re-ordered without copying it. no more useful than re-ordering pointers in an array
"require 'unlimited' memory" Completely untrue! As previously discussed, statically-allocated linked lists are perfectly common. if open-ended is not a desire, then using a linked list becomes even more silly.
"other than 'It is easy'" Surely that could be an entirely valid reason? 1) easier than what 2) "It is easy'" is thr most often used excuse for writing ineffective code.
Just mentally go through the process of getting to the last entry in a linked list as opposed to getting to the last entry in an array of pointers. Point taken?
" it has nothing to do with language."
Correct: it's a fundamental tool in any computing environment - so you'd expect any real language to support it! And any programmer to include it in their "armoury"
Not necessarily. Linked lists are particularly useful when your data needs to be easily re-ordered without copying it.
"require 'unlimited' memory"
Completely untrue! As previously discussed, statically-allocated linked lists are perfectly common.
"I would greatly appreciate if someone could tell me a reason for using a link list"
See above. As we're talking EEPROM here, it might be something to do with wear-levelling?
For another example, see 'It is easy'"
Surely that could be an entirely valid reason?
a link list is an excellent idea if you want your project to come to a crawl.
I have no idea why, somehow, the link list has become a part of C, it has nothing to do with language.
The link list is a very ineffective means of storing stuff and, in addition, require 'unlimited' memory which the '51 definitely does not have.
WHAT IS WRONG WITH arrays and structures?
I would greatly appreciate if someone could tell me a reason for using a link list other than "It is easy". That it is "open ended" is irrelevant, in a '51 it WILL end when you run out of memory
Here: http://www.keil.com/forum/docs/thread8939.asp
Why did you think 4?
Hm ... I can only guess.
I can also guess that the next question will be about some dynamic memory allocation/deallocation issue. Anyone want to bet ?
You need to refer to the documentation about generic and memory specific pointers. Your code does show you the correct number of bytes. Your guess is incorrect.
http://www.keil.com/support/man/docs/c51/c51_le_ptrs.htm
It would help if you formatted you code legibly - see http://www.keil.com/forum/tips.asp
xdata struct EEPROM { unsigned int Last_Data; // 2 bytes struct EEPROM *Node; // 3 bytes (Generic pointer) };
So the toal should be 5!
View all questions in Keil forum