From: Robert Adsett on 3 Feb 2007 17:59 In article <3nf9s25pb8395drsr0deedan9dd6ese5a0(a)4ax.com>, John Larkin says... > This is a snip from an embedded product program, a combination > thermocouple temperature controller and NMR gradient driver. This is a > sort of printf function. > > The program was done in a couple of weeks calendar time, released as > rev A, and has been in production for about a year. There are no bugs. > A bit over 4K lines of assembly. It's an absolute, monolithic assembly > of a single source file, no libs, includes, or linkers involved. > > The .SBTTL directive create an entry in the listing's table of > contents. > > > > > .SBTTL . MAKE A FORMATTED ASCII NUMERIC STRING. > > ; THIS IS A NON-REENTRANT VERSION, WHEREIN WE BUILD THE > ; DESIRED STRING IN THE 'J0..J7' BUFFER AREA. ON ENTRY... > ; > ; D5 CONTAINS UNSIGNED, RANGE-CHECKED 32-BIT VALUE > ; JM HOLDS SIGN CHARACTER, USER'S OPTION > ; D4 CONTAINS 'FORMAT' IN RANGE 0...5: THIS IS HOW MANY > ; DIGITS APPEAR TO THE RIGHT OF THE DECIMAL. > ; A3 IS POINTER TO 8-BYTE OUTPUT STRING > ; > ; 12345 FORMAT 0 IS ' 12345' > ; -98765 FORMAT 3 IS ' -98.765' > > > BASS: MOVEA.W # J7+1, A5 ; AIM AT *END* OF STRING > MOVE.L D5, D0 ; COPY OUR NUMERIC INPUT > MOVE.B # " ", J0.W ; POKE A NECESSARY SPACE > MOVE.L # 10, D1 ; AND NAME A POPULAR RADIX Now that's more like it. There's no reason the original example couldn't have been done that well. It just take a certain amount of self discipline and pride in your work. Robert -- Posted via a free Usenet account from http://www.teranews.com
From: PeteS on 3 Feb 2007 19:35 Robert Adsett wrote: > <snip> >> So, I am not shy with comments :-) > > I'm not saying you are. Just that the commenting in the example John > was given was poor. Unfortunately it appears the other examples on the > same site are worse. Not much wonder John dislikes C if that's what > he's got to go on. > > Robert > Poor discipline is the bane of the industry, and I must agree with John on this, even though I prefer to write in C. #include <rant.h> I have spoken with many a programmer unworthy of the name if only because they think hardware is something that automagically does what they need; it's the product of a great deal of hard disciplined work! In this, incidentally, I include those who are software engineers and computer scientists (I have yet to divine the distinction). #undef rant Discipline is something foreign to many software engineers (but not all, as I can attest from personal knowledge) and is necessary if a product is to be successful. So the answer seems to be; a disciplined approach is likely to produce successful results. Duh. Cheers PeteS
From: Jan Panteltje on 4 Feb 2007 06:27 On a sunny day (Sat, 3 Feb 2007 17:54:47 -0500) it happened Robert Adsett <sub2(a)aeolusdevelopment.com> wrote in <45c5061d$0$16408$88260bb3(a)free.teranews.com>: >> So, I am not shy with comments :-) > >I'm not saying you are. Just that the commenting in the example John >was given was poor. Unfortunately it appears the other examples on the >same site are worse. Not much wonder John dislikes C if that's what >he's got to go on. > >Robert You are partly right in my view. If I buy a book in English (I am Dutch), can I require that plent of Ducth lines are inserted so I can read it if my English is broken? If you are going to do some reading of C files, do you not think you should _AT_LEAST_ be able to read the language fluently? Even more when writing in C. C, written in the right way, other then if cryptic use of variables and functions in made, is very readable. I have worked myself throught tons of sourcefiles that had zero comments, something you learn when using open source..... Sometimes comments just distract. >Posted via a free Usenet account from http://www.teranews.com The reliability of teranews (I once payed for lifetime access to it) is such that I stay clear of it.
From: Robert Adsett on 4 Feb 2007 12:03 In article <1170585110.650611.149170(a)q2g2000cwa.googlegroups.com>, Didi says... > On Feb 4, 3:37 am, John Larkin > <jjlar...(a)highNOTlandTHIStechnologyPART.com> wrote: > > The very act of commenting forces a programmer to explain the program > > to himself, sometimes with novel results. > > I did not realize this was not a common truth/practice for all > programmers > nowadays until not so long ago... Sorry to have disillusioned you :) > Not that one cannot comment each line (or few characters...) in C, > Basic or whatever, but HLLs are designed following a "no comment > necessary" ideology, which is a major weakness they all have. While people do work that way, I don't think any HLLs have been designed that way. > Obviously trying to communicate a software project without using > English is doomed; so people do use some minimized comments, > which results in minimized code quality. Well, I think maybe English is necessary if you are communicating with English readers ;) > Other than in HLLs, writing comments using 68k (and perhaps some > others in this particular context) assembler is a de facto part > of the language, not a result of discipline. Now her I'll disagree. I've certainly seen uncommented and poorly commented assembly code. No assembler I've seen encouraged comments any more than most HLLs. The prevalance of commenting, especially meaningful commenting, appears to have to do far more with the people writing the code than the language they are using to write it. The exception might be graphical languages which in my limited experience do not seem to have developed clear commenting techniques. Robert -- Posted via a free Usenet account from http://www.teranews.com
From: Michael N. Moran on 4 Feb 2007 13:08
Jan Panteltje wrote: > Take your pills Why have the people in this thread been so belligerent? Most of us in this group (c.a.e) can remain civil in spite of our disagreements. In this case CBF was simply making a point, not insulting anyone. -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 http://mnmoran.org "So often times it happens, that we live our lives in chains and we never even know we have the key." The Eagles, "Already Gone" The Beatles were wrong: 1 & 1 & 1 is 1 |