In one of my project I am talking with MX909 Driver IC with C51 ucontroller. To initialize MX909 if I write module in Assembly language it's working fine. Once I replaced with C same module it's not working.
The only difference I can make for both assembly and C languages is NOP and _nop_() instruction. Is both instructions will take same number of machine cycles?
Thanks, Suresh Kumar Kavula
Once I replaced with C same module why on earth did you do that?
If you had taken one second to look at the generated assembly you would have found that they are identical.
My guess is that you suffer from some fallacy that e.g. a for loop is the same as a djnz loop and nothing could be farther from the truth.
If you, for some silly reason, have to "replace with C" have a look at the assembler code generated by the compiler and you will find your answer.
Erik
----- FUNCTION main (BEGIN) ----- 8: void main(void) 9: { 10: unsigned char loop; 11: 12: for(loop=128;loop;loop--) ;---- Variable 'loop' assigned to Register 'R7' ---- 00000F 7F80 MOV R7,#080H 000011 ?C0001?TEST: 13: { 14: } 000011 DFFE DJNZ R7,?C0001?TEST 000013 ?C0004?TEST: 15: 16: while(1); 000013 80FE SJMP ?C0004?TEST ----- FUNCTION main (END) -------
Is this supposed to be funny ?
Not funny - More sad ... That a potentially useful forum can have so many members that post useful responses muddied by very few who post in a manner that just triggers such negative reactions.
Lots of complaints and arguments.
I read the comment
as
Don't think that a for loop is equivalent with a djnz loop.
Any people who read it as:
The compiler will never make use of a djnz in a for loop.
should maybe be a bit more careful about complaining, since Erik did not claim any such foolish thing.
If you know the compiler and the right syntax, it is possible to get a djnz when using a for loop.
and then you can HOPE (a very useful approach to design) that it will still be a djnz loop in the next release of the compiler.
re my post that caused so much reaction: assuming a for loop is the same as a djnz loop and nothing could be farther from the truth.
where doues 'is' mean 'can not be' ?
... you can HOPE (a very useful approach to design)
An example of dry wit or the approach you follow?
If you have to ask you have not read many of my posts
maybe be a bit more careful about complaining, since Erik did not claim any such foolish thing.
Maybe, if he'd been a little more correct with his punctuation, people might have been able to understand it more easily.
Hope he doesn't write his code in the same manner.
What is the prize for people who get the right answer ?
The warm, fuzzy feeling of knowing that they won't fall into the trap of expecting a delay loop in C to give an exact delay.
Here's hoping it's not a trick question!
Not at all. On the contrary, there's even a hint pointing in the right direction.
Ermmmm ... It was a rhetorical question.
I've read quite a few of your posts; and the responses they trigger!
Very entertaining ;)
Nowhere.
Your original statement:
Modified as you suggest:
My guess is that you suffer from some fallacy that e.g. a for loop can not be the same as a djnz loop and nothing could be farther from the truth.
Yes, that seems correct now.
"a for loop is the same as a djnz loop"
That is, indeed, a fallacy and very far from the truth!
It's equivalent to saying something like, "a quadruped is the same as a cat"
...by saying "nothing could be further from the truth"
But that, too, is a common rhetorical device...
wlee Mr. smoked sardine, as usual you put words in my mouth that I would never use.
if you want6 a different then here it is My guess is that you suffer from some fallacy that e.g. a for loop always is the same as a djnz loop and nothing could be farther from the truth.
Seemed fine to me originally
thanks, Andy
while there can be some that do not like my choice of words, I stand by the statement.
See my response to Mr. smoked sardine where I have added a superflous word to satify him .... naah that would not be possible, but maybe someone else will understand better.
My guess is that you suffer from some fallacy that e.g. a for loop always is the same as a djnz loop and nothing could be farther from the truth.
The crazy thing about all of this is that it was a dumb-cluck thing to say in the first place - Not necessary, not helpful, of no real relevance and demeaning.
Why not just politely re-emphasize to the OP that assembler for such a task would be the better/best option.
And who says that the OP will not feel demeaned if their decision to use C is questioned in any way ?
Some past discussions went exactly this way.
That is probably true - But to go in at such an early stage with a statement such as "...you suffer from some fallacy..." is a sure fire way of belittling most people. And has been seen, causes a lot of negative reaction!
Gentle persuasion generally works better; not the "I've got experience, I know best, any other way is stupid" attitude that seems so prevalent in most responses by the poster in question.
But also, if the OP wants to use C and/or has good reason to do it that way, then surely this forum should be capable of understanding the need and provide advice to help him achieve his goal.
And has been seen, causes a lot of negative reaction!
If you come to a technical forum to get technical advice and the criticize the semantics (instead of ignoring them and using the actual information to solve your problem), then you weren't really interested in a solution in the first place.
Gentle persuasion generally works better;
If you want gentle persuasion, call tech support. Most likely, you'll get more and more persuasion the less knowledgable the person you're talking to is.
If you want gentle persuasion and actual information, how about paying for a support contract or hiring a consultant.
Don't forget that you'll find professionals giving advice for free (as in: they're not paid to do so) here. If you demand that they put additional effort into making it "work", you're expecting quite a lot for something that's free.
Free, useful, "gentle". Pick two.
And there is the problem from the post in question - In my opinion, only one was picked!
Free - Yes.
Useful - No.
Gentle - HaHa!
It is not a prerequisite of a professional to be rude and demeaning - Well, certainly not one that I would look for.
If you can deduct anything that is more useful from the extremely scant (bordering on nonexistent) information given by the OP, then please enlighten us.
Otherwise, Erik's guesses were as useful as the could be, given the (lack of) information he had to base them on.
But that seems to be the common problem - not being able to recognize a posting as useful and then complaining about formal issues.
Is there something wrong or difficult about maybe asking the OP for further information?
Since 'the professionals' do this in their own time and for free, then surely it would be more sensible to not waste time on providing answers to the wrong questions!?
His guesses were as useful as a chocolate teapot!
What about recognising a post as unuseful (and rude and demeaning) ?
Eriks first line. Oh, I know. Not gentle enough for you.
And you know that because ... ?
Oh right, you don't. You're just guessing, like Erik. Unless you're the OP posting under another name and have since then figured out where the bug in your code was. I'd assume this to be fairly unlikely, though.
Or you're "Jack Sprat" posting under yet another pseudonym (or even your real name), and don't really care about the contents of this thread as long as you're getting attention and can flame Erik.
If you think Eriks post was not useful, then, I'm sorry to say this, you're suffering from a fallacy.
What do you demeaning about this ? "Fallacy" is a perfectly normal term for something that is easily assumed to be right, while it is, in fact, wrong.
you're suffering from a fallacy.
Hmmm ... It's sounding like you're a member of the Erik luv-fest brigade!
I'm not going to bother responding to your individual points because - Well, what's the point!?
But, by the way, I am not the original poster, I am not "Jack Sprat" and I am not even the alter ego of "Christoph Franck".
I would expect professionals to be a bit more professional. Experience is not directly proportional to superiority!
View all questions in Keil forum