Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/07/06 14:50
Read: times


 
#129128 - aaah now I see what you meant...
Responding to: ???'s previous message
... by "meaningless".

OK, so you want the labels to be "self-commenting"?

Isn't that YOU who speak against the "self-commenting code" idea?

The whole idea of "neat code" is much of psychologic character hence subjective (unless "commonly accepted style" is around, which for asm is AFAIK not - please correct me if I am wrong).

My way is, spare time by not thinking on creating label names inside a routine, spend the same time on commenting.
This pays off, as some of the labels (my guess is >50%) are trivial=meaningless, but there are other places without labels worth commenting. In my way, to read the program, you need to look only at the comments.

Simplistic and slightly exagerrated example:
CompareNum:
   mov   a,Num1
   cjne  a,Num2,CompareNum_1
   blah  blah1                    ;if Num1=Num2
   blah  blah2                         ;do blahblah
   sjmp  CompareNum_9         
CompareNum_1:
   jc    CompareNum_2
   blah  blah3                    ;if Num1<Num2
   blah  blah4                         ;do something else
   sjmp  CompareNum_9
CompareNum_2:
   blah  blah5                    ;if Num1>Num2
   blah  blah6                        ;do something
   blah  blah7                        ;and fallthrough to end
CompareNum_9:
   ret
Also, using a character not used elsewhere (e.g. underscore - although I use a different character, I don't like underscores) for the unimportant labels, one quickly develops a habit to ignore the unimportant labels and see the important (routine names) only.

This might work for one and might not for other, of course.

JW


List of 27 messages in thread
TopicAuthorDate
Interrupt handeling in C/C++ for 8051            01/01/70 00:00      
   before asking such questions, work through the Kei            01/01/70 00:00      
   RTFM            01/01/70 00:00      
      It is enough now THANKS A LOT for Mr. Andy Neil            01/01/70 00:00      
   labels?            01/01/70 00:00      
      ARGH            01/01/70 00:00      
         labels?            01/01/70 00:00      
            still meaninbgless            01/01/70 00:00      
               what's O in ANOloop/ANOdone?            01/01/70 00:00      
                  an abbreviation of AddNumber            01/01/70 00:00      
               aaah now I see what you meant...            01/01/70 00:00      
                  intuitive            01/01/70 00:00      
                     that's not the case            01/01/70 00:00      
                        it would take, at least, 10.000 programmers to fin            01/01/70 00:00      
      switching to structured programming?            01/01/70 00:00      
         OOPS            01/01/70 00:00      
            to structure or not to structure            01/01/70 00:00      
               it is            01/01/70 00:00      
                  sometimes yes, sometime not quite so well...            01/01/70 00:00      
            eh?            01/01/70 00:00      
               YOUR definition            01/01/70 00:00      
                  hmm........            01/01/70 00:00      
                     different from what?            01/01/70 00:00      
                        this            01/01/70 00:00      
   labels yes but nor RANdom Capitalization please            01/01/70 00:00      
      what is 'random' about            01/01/70 00:00      
   that you believe in one definition ...            01/01/70 00:00      

Back to Subject List