Registers , Code Size and LOOPS - AT89S51/2

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


Hi All

1) Below is a skeleton version of what I currently have. Up to now =
everything I'm doing is working without a problem, except that I've =
reached r7 register, and according to the AT89S51/2 Datasheets the max =
number of registers is 7. Maybe I'm doing it wrong by using a register =
for each LOOP, but If I'm not wrong, will it be possible to combine =
Routine_1 and Routine_2 into a new Routine_3, and still have the =
different loops in the one combined routine ?

2) The AT89S51 is a 4K and the AT89S52 a 8K microcontroller. Is this a =
direct correlation between the size of the Hex file in Kb ? If correct, =
then I won't be able to load a 9k HEX file into a AT89S52 ?

3) I don't know how to reverse engineer a hex file - if possible - But =
does the comments I add in my project, also get compiled into the Hex =
file. I removed all the comments from my project and created the Hex =
file again, but the size the hex file is shrinking is not the same =
amount of bytes I removed from my project .

4) Is it possible to call the START registers in a random order on each =
execution, or will it always do it in the order it's coded, irrespective =
if the number of r0-r7 is a following order ?

#######################

START:       MOV r0,#4   20%
             MOV r3,#2

LOOP1:       LCALL Routine_1
             DJNZ r0,LOOP1
   20%
LOOP2:       LCALL Routine_2
             DJNZ r3,LOOP2
             LJMP START

Routine_1  CPL P1.0
           .
           .
           .
           RET

Routine_2  CPL P1.0
           .
           .
           .
           RET

####################


Thank you - Any feedback appreciated

Lodewicus Maas


Re: Registers , Code Size and LOOPS - AT89S51/2



Quoted text here. Click to load it

Well, frankly, that's not a skeleton of anything worth having.

Quoted text here. Click to load it

Yes, you are.

Quoted text here. Click to load it

No.  What do you think your tools display the resulting program's code
size for at the end of linking?

Quoted text here. Click to load it

You're not correct.

Quoted text here. Click to load it

Of course not.  For goodness' sake: could you _please_ stop mucking
around and read a bloody manual for a change?

Quoted text here. Click to load it

Good grief.  If removing comments changed the size of the hex file _at
all_, that means you didn't even know assembly language well enough to
know what is a comment and could thus be removed.

Quoted text here. Click to load it

You're not making any sense whatsoever.  There is no such thing as a
"START register", nor are registers ever "called".

And no, you can't usually do anything in actual random order in a
microcontroller.

I'll be blunt and suggest you stop playing with assembly programming
right here and now.  It has become abundantly clear that you don't have
the understanding of CPUs required for it, nor the
willingness/capability to acquire that understanding on your own.
You're just not cut out for this kind of activity.

Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it
I do not know if I wi\ould tell him to stop, but he needs to read a lot
more about the CPU.  And there is much to find if you Goggle.

Re: Registers , Code Size and LOOPS - AT89S51/2


Hi Hans-Bernhard

I do understand your frustration with me and other users on this forum. I
could not find a single topic where you did provide a correct answer or add
value, but please hang in there, maybe out of my stupid questions you might
also one day get to grips with the concept of microcontrollers. There is no
note on Google which mentions only professionals or people with degrees are
allowed to participate in this forum, and many replies I received from this
forum already proofed the manuals I obtained as incorrect , which also make
your requirement of reading "bloody" manuals redundant.

Please ignore future posts from me - I will only ask questions where my
practical projects seems to conflict with the information in the manauls I
bought

Kind Regards


Quoted text here. Click to load it


Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it

This is my advice, based on the questions you've posted in this
newsgroup and your responses.  I might be judging you harshly - it's
difficult to tell.  Only /you/ will be able to judge how well it fits,
and if you want to act on any of it.  But I post this in the hope of
helping you - it is constructive criticism.  And feel free to disagree
or to ask for more help.


Hans-Bernhard might not have answered any of *your* questions in this
newsgroup, but he is one of the more knowledgeable and helpful members
of the newsgroup.  And his post here should be /very/ helpful to you -
you need to take a long hard look at what you are trying to achieve, and
think about whether you are going about this in totally the wrong way.

Assembly programming is *hard*.  It can be great fun, but only if you
understand about programming in general, and understand very clearly how
processors work.  It is obvious that you have very little idea about
what the 8051 cpu is, and how it works.  You simply don't have the basic
knowledge to write assembly code here.  You appear to be taking examples
out of a book and attempting to modify them - that's a very good way of
learning, *if* you understand what they do and how they work.  It's like
trying to learn a foreign language - and a foreign culture - by quoting
from a small phrase book.

I am not sure what you are trying to achieve here, but you are using the
wrong processor, and the wrong programming language - you've picked an
outdated, limited and awkward device, and the hardest possible
programming language.  As a beginning embedded developer, you should be
using a friendly micro with friendly tools and a cheap (or free)
friendly C compiler - typically an AVR starter kit of some kind with
ImageCraft tools.  If you ask here, I'm sure you'll get plenty of
recommendations for books and tools to get you started.

If you really insist of progressing along this path, then you should do
your best to find some sort of course, or at least an online tutorial,
teaching a basic "what is a microprocessor" topic.  You need to
understand what registers are, what the ALU is, what a program counter
is, how the microcontroller steps through the program, how the program
is stored in memory, and how it gets into the memory.  Without these
sorts of key concepts, you will always be stuck asking questions such as
these, and you will be continually frustrated with yourself and your
lack of understanding.  One of the key reasons for using a higher level
language (and a more modern microcontroller) is that you can insulate
yourself from these low-level details - the compiler takes care of them
for you.

I realise that you've spend 3 months working on this - I hate to be so
blunt, but you should probably consider much of that time as just
"learning experience", and start from scratch with new tools.  You'll
reach your end destination much faster in the end, and the journey will
be more enjoyable.

Good luck,

mvh.,

David



Quoted text here. Click to load it

<snip>

Quoted text here. Click to load it

Re: Registers , Code Size and LOOPS - AT89S51/2


Thank you David

I could not agree more with you - I'm learning and will be till the day I
die. I already obtained a degree in Electronics as well as in clasical music
(Piano) , and never in my life have I ever met people trying to help others
by incriminating them and attacking their personalities. According to my
knowledge it's never "helpful" to incriminate people, and this behaviour is
only a good sign of a bad self esteem. If this is what this forum is about,
then I don't want to be part of this, I was under the impression that this
forum - like so many in which I participate - is there to share ideas, ask
questions and help people with their problems, but now I've learned that if
you don't know the answers already, then you don't have any right to post to
this forum

I learned a lot out of every example I modify - by not knowing the limits
I've already seem to achieve the below.

I've already managed to call the registers in a random order - which was a
definite "NO" from other members.

"Hans-Bernhard might not have answered any of *your* questions in this
newsgroup  ....." - so what was the idea then of posting a reply on my post,
if I can call that a reply ??

I already obtained "The 8051 Micro Controller and Embedded Systems Using
Assembly and C - 2nd Edition" and out of this I already completed my
project, BUT I really feel that my code can be optimized, and therefor all
these questions. The expectation never was to have the forum write my code
for me.

English is my second language - and I know my tenses/grammer irritates the
'crap' out of some people. 3 People from this forum already replied directly
to my email adress should I have any other further questions, to "save me
the public humilitation by professionals" as one guy mentioned, therefor I
won't be posting any more posts to this forum, or maybe not.

Thank you for the most professional reply.



Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it

You are welcome to ask questions here, and people *will* help you.  You
don't have to know the answers before you ask.  But you do have to know
what questions to ask, and you have to show that you are willing and
able to learn from the responses.  People are not paid to help out here
- this means that posters have limits on how much effort they will put
in.  And different posters have different attitudes - some will try to
answer your questions directly, others will try to help you learn to
answer them yourself.

Quoted text here. Click to load it

It *is* a definite "NO", in that "call the registers in a random order"
is totally nonsensical.  As Hans-Bernhard said, you cannot "call" a
register, and the processor does not do anything in a random order.

We are all used to non-native English speakers in this international
newsgroup (no one will worry about spelling or grammar mistakes, as long
as you don't try to post in SMS language), but you /must/ make an effort
to get technical terminology correct or you can't make sense of the
technical issues.

Quoted text here. Click to load it

Neither I nor anyone else here is trying to humiliate you (if you want
public humiliation, I can suggest a few other newsgroups where the real
Usenet psycos hang out).  We are simply trying to help you help
yourself.  I don't see any posts that are directly "humiliating", though
there a couple that imply you must be a student, or that you are out of
your depth.  Rather than getting annoyed or huffy about these posts and
assuming these are just "arrogant professionals", you should think about
what you have written to give that impression either in the questions
you asked, or they way you asked them.  Generally speaking, when one of
the regulars in this newsgroup tells someone to do their own homework,
it's for good reasons.



Re: Registers , Code Size and LOOPS - AT89S51/2


Lodevikus - I emailed you the code to call registers in a random
order, althoug some people claim it cannot be done - unknowingly you
already provided the answer to your own question in one of your prior
postings.

It might be better to stay away from this forum should you still be on
the learning curve as profesionalism and integrity does not seem to
share the same packages here. Please feel free to reply on all emails
I send to your email address. I normally don't respond to questions on
this forum

Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it

Thank you Kaspaas - The random order sequence is working

Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it

People will continue to claim that you cannot "call registers in a
random order", because it is totally nonsensical.  You "call" a function
or a subroutine, while a "register" is a cpu store for a number.  You
can't "call a register" any more than you can "dial a house" or "drive a
football".  Secondly, and this has been pointed out before, a processor
does not do anything in a "random order".

If you are trying to say that it is possible to set the initial values
of the registers in a different order, then that's fine - but please try
to say so.  If writing in English is difficult, then simply explain what
you mean.  It's okay to use an extra sentence or two to make it clear.
It's also okay to make a mistake - but not to repeat the mistake while
claiming that everyone else is wrong.

Quoted text here. Click to load it

This is not a forum, it's a newsgroup.  Lookup google or wikipedia if
you want to know the difference.  With google, you'll also find the
archives of this newsgroup and see that people here /do/ try to help
both professionals and non-professionals.  You'll also see that
Lodewicus has received plenty of helpful replies here - both direct
answers to his questions, and general advice in embedded development.

Re: Registers , Code Size and LOOPS - AT89S51/2



Quoted text here. Click to load it

ObNit: Some processors do have random number generators in HW.
They're usually high-horsepower uControllers aimed at the
network communications market (routers, firewalls, etc.).  But,
there are also smaller parts like Atmel "secure" AVR parts with
HW RNGs.

Processors with RNG hardware can indeed do things in a random
order.

Not that this has anything at all to do with the OP's problems.

--
Grant Edwards                   grante             Yow! Now we can become
                                  at               alcoholics!
We've slightly trimmed the long signature. Click to see the full one.
Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it

RNG's are normally pseudo-random, rather than true random.  You can also
get "more" random values from other sources (timing of user keypresses,
voltage across a resistor, etc.).  But while these are all sources of
non-determinism, the processor still does what it is told, in the order
it is told - it is not the processor that does things in a random order.

Quoted text here. Click to load it

Indeed :-)

Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it

The parts I'm referring to have true random number generators.
At least that's what the datasheets claim.  They're usually
based on thermal noise or on mixing together data from several
independant free-running oscillators.

It's possible that some of them are really using a PRNG with
periodically refreshed random key, but that's definitely not
what the datasheets say.

--
Grant Edwards                   grante             Yow! Hmmm ... an arrogant
                                  at               bouquet with a subtle
We've slightly trimmed the long signature. Click to see the full one.
Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it

"call registers in a random order" is Obviously a bad translation.
Perhaps rewording it may help?

In software the best you can is pseudo-random. The quality of the
randomness that provides varies with the software algorithm.

Re: Registers , Code Size and LOOPS - AT89S51/2


Quoted text here. Click to load it
I won't be able to load a 9k HEX file into a AT89S52 ?

Find any programmer, and read a blank 89S52, look at the HEX file
created.

Quoted text here. Click to load it
 removed all the comments from my project and created the Hex file again, b=
ut the size the hex file is shrinking is not the same amount of bytes I rem=
oved from my project .

Another exercise for the student:
 The hex fie DID shrink, by how much ?
Did you think to see what ratio that might be, or even look at a HEX
file with a text editor ?

Also look at your assembler LIST file with an editor, and that should
give you clues too..


-jg


Site Timeline