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
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
Here: http://www.keil.com/forum/docs/thread8939.asp
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
Erik
" 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"
"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.
"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?
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?
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.
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,
That's hardly a fair mental exercise. A similar statement could be: "Mentally go through the process of inserting an element into an array of pointers to maintain sorting on the elements to which they point."
I suspect you'll find that, gee whiz, the linked list completes that task (on average) far faster than the array (which requires shuffling every value after the insertion point of the item.
The reasons for selecting which of these two extremely fundamental data structures (array / linked list) to use is independent of programming language. To a great extent, it can be independent of the processor if we give up the notion of dynamically allocating said structures.
-Jay D.
the example was a sort and I compared to an array of pointers
so, to switch element 47 with element 16 in a linked list is you have to perform 62 reads of addresses. to to switch element 47 with element 16 in an array of pointers, you need to perform TWO reads. There may be an exception here of you use the very inefficient bubble sort, but that will kill the performance regardless of storage method.
You state I suspect you'll find that, gee whiz, the linked list completes that task (on average) far faster than the array (which requires shuffling every value after the insertion point of the item. Of course if you refer to an "array of arrays" you can very well be right, but since "linked lists" is a pointer thingy the only fair comparison is to an array of pointers. I see no way that 62 reads "(on average)" will be faster than TWO.
Now you switch the comparison to "inserting items" and, in that case if the most frequent operation is "inserting" and the only read is sequential you may have found one obscure case where a linked list would be faster. I agree that if you do an insert in a sorted list and uses other than inserting are irrelevant you may have a case for a linked list.
There is, of course the possibility that the definition of a "linked list" has changed since i was last exposed to it. But to my recollection to find element 47 you read element 1 that has a pointer to element 2 that has a pointers to element 3, that .... Again, as stated above if the ONLY read is sequential, you may have a case.
Many would think of a linked list as "the way" for a '51 based data collection system to sort collected data on the fly and then at a convenient time transfer it to a PC (as the case above "sorted insert, sequential read"). I have seen that one. The problem report was "when it has run a couple of days it hangs up". What was the problem? it was that when it took passing umpteen entries in the linked list to find the insert point the process got too slow and crashed. What was the solution? SIMPLE do not sort on the '51, the PC can easily accept unsorted data and sort it.
View all questions in Keil forum