Forums

Urgent help with hc11!!!

Started by hombre_kenno69 October 5, 2005
Mike,

I strongly disagree with commenting every line. Its been 5 years
since I did much C or assembly but:
>>>; The subroutine sqrt finds the integer square root of a
16-bit
>>>; value (param). The algorithm uses a temporary stack variable
>>>; space for the loop index (called index), decremented on
each loop.
>>>;
>>>; pseudocode: index <- 255;
>>>; while (index*index > param)
>>>; index--;
>>>; return index;
>>>;
>>>
>>> org $e200
Figuring this out is part of the exercise it is extremely well
documented in the names of the variables that are much less
likely to get out of sync with the code than the comments.

Gordon

Gordon Couger
Biosystems& Ag Engineering (retired)
Oklahoma State University
www.couger.com/gcouger Mike McCarty wrote:
> Tom Sefranek wrote:
>
>>You SERIOUSLY need to comment your code.
>>Line by line! > Line by line may be just a tad much. But I usually comment
> 2/3 of the lines in my assy or maybe 90%. Often, in assy,
> accomplishing any one given thing takes 2-3 instructions.
> I comment the first, and use indicators that the action is
> still taking place. For example:
>
> tsx ; Increment total byte count
> ldd Count,x ; .
> addd #1 ; .
> std Count,x ; .
>
> I think that over-commenting can be bad, but it's not
> nearly as bad as under-commenting. I'd much rather
> encounter
>
> tsx ; Prepare for stack addressing
> ldd Count,x ; Get total byte count
> addd #1 ; Increment total byte count
> std Count,x ; Store total byte count back
>
> than bare code. I'd prefer what I wrote at first, though.
>
> The very worst would be
>
> tsx
> ldd 6,x
> addd #1
> std 6,x
>
> AAAAARRRRGGGGHHHH! >>Tell us what you MEAN to be doing, NOT what the assembly
indicates.
>
>
> 'Way back when I was doing assy on the 8088, a buddy of mine
> used to comment thusly:
>
> cli ; disable interrupts
> ...
> sti ; enable interrupts
>
> Used to drive me NUTS! I asked him, in a calm tone, the first
> time I encountered it, why he made those comments. His reply
> was that he could never remember which one enabled and which
> one disabled. I replied something like "I can always look up
> the instructions. But please tell me WHY ARE YOU DISABLING
> INTERRUPTS? WHAT NEEDS TO BE ATOMIC!?"
>
> This remained a bone of contention between us. I'd figure out
> what the code was doing, and rip his comments, and add something
> like
>
> cli ; The keyboard interrupt handler uses InHead and
> ; InTail. We are critical until the
circular
>
> ; buffer update is completed.
> ...
>
> sti ; Allow keyboard interrupts...
>
> At another job, I routinely encountered comments like:
>
> CLR R0 ; Clear R0
> LDA RR2,BUF ; Load address to RR2
> CALL KERBFA ; Call kernel routine
>
> (Z8000 assy for Telecomm code) >>A paragraph describing what the module is supposed ot do
helps too.
>
>
> I have built boilerplate into my favorite editor to create
>
> file level prologue
> subroutine level prologue
>
> They are for C, rather than assy, but a quick edit changes
> them to assy commentary. >>hombre_kenno69 wrote:
>>
>>
>>
>>>Thnx guys
>>>all the inputs are appreciated
>>>I had a go today at the code, and i got the following steps
done:
>>>
>>>-compute the square of the height
>>>-compute the square of the length
>>>-add the squares together
>>>
>>>However, after i've done this, i can't seem to pass the
results to the
>>>subroutine sqrt which is provided to us, this is the step
i'm lacking...
>>>there are also alot of loop holes in my code too....its by
far perfect...
>
>
> Well, the calling procedure is the PROF'S responsibility
> to provide. Whoever writes code is responsible for making
> it absolutely clear how it is intended to be used. > [snip] >>>The subroutine provided by the TA's
>>>
>>>; The subroutine sqrt finds the integer square root of a
16-bit
>>>; value (param). The algorithm uses a temporary stack variable
>>>; space for the loop index (called index), decremented on
each loop.
>>>;
>>>; pseudocode: index <- 255;
>>>; while (index*index > param)
>>>; index--;
>>>; return index;
>>>;
>>>
>>> org $e200 > I realize this is the TA's code.
> This is inadequate commentary.
>
> Mike




Gordon Couger wrote:
> Mike,
>
> I strongly disagree with commenting every line. Its been 5 years
> since I did much C or assembly but:

You make it sound like I support commenting every line. I said
I didn't like it, but preferred it to no comments at all.

I would like it better if you didn't top-post.

> >>>; The subroutine sqrt finds the integer square root of a
> 16-bit
> >>>; value (param). The algorithm uses a temporary stack variable
> >>>; space for the loop index (called index), decremented on
> each loop.
> >>>;
> >>>; pseudocode: index <- 255;
> >>>; while (index*index > param)
> >>>; index--;
> >>>; return index;
> >>>;
> >>>
> >>> org $e200

> Figuring this out is part of the exercise it is extremely well
> documented in the names of the variables that are much less
> likely to get out of sync with the code than the comments.

Umm, how do you know that figuring out the routine calling
convention is part of the exercise? Did you design it?

If I designed an exercise in which part of the exercise
was to figure out the calling convention for a piece
of code which was inadequately commented like the one
under discussion, ANOTHER part of the exercise would
be to submit an adequately commented version of the code.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!




In a message dated 10/6/05 4:08:11 P.M. Eastern Daylight Time,
Mike.McCarty@Mike... writes:

> I strongly disagree with commenting every line.


==========================
OK, good so far. No comments......bad Comments every line......bad. Can
we settle on something in between that makes reading the program easier for
the guys trying to help debug?


BobGardner@BobG... wrote:
>
> In a message dated 10/6/05 4:08:11 P.M. Eastern Daylight Time,
> Mike.McCarty@Mike... writes: >>I strongly disagree with commenting every line.
>


HEY! I DIDN'T WRITE THAT!

Take a little more care with your attributes?

> ==========================
> OK, good so far. No comments......bad Comments every line......bad. Can
> we settle on something in between that makes reading the program easier for
> the guys trying to help debug?

I gave several examples in my message.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!



On Thu, 2005-10-06 at 14:56 -0500, Mike McCarty wrote:

> I would like it better if you didn't top-post.

Top-posting: Reply comes first, followed by the quoted original. As I
see it, the only thing wrong with this, is that there should be *no*
quoted material between the last line of reply and the sign-off, since
such material is clearly "junk" of no relevance which the writer was too
"lazy" to delete - a total waste of electrons, and disrespectful to the
reader.

Bottom-posting: Quoted original comes first, followed by the reply.
As I see it, the only thing wrong with this, is that there should be no
more than say, three lines of quoted material preceding the reply since
it should with few exceptions, be possible to clearly establish the
context for the reply in two or three lines. Quoted material excess to
this is clearly "junk" of no relevance which the writer was too "lazy"
to delete - a total waste of electrons, and disrespectful to the reader
who could reasonably conclude - from experience - that if nothing
meaningful appears immediately in the view pane, it's not really worth
scrolling!

Seems to me that the more clearly distinguished as *either* "top" *or*
"bottom"-posting it is, the more clearly sloppy work it is. Perhaps
applies to code commenting as well.

Now I am not here quoting from the Deuteronomic Book of RFCs, nor do I
care to bother, simply because all knowledge does *not* reside in such -
some things are clearly - common sense.

(:-D)
--
Cheers,
Paul B.



> I would like it better if you didn't top-post.
=================================
I'm taking a survey. I bet a buddy of mine that those who are a little OCD
about their posting must also be a little OCD about the way their TP hangs.
Does your roll off the front or the back of the roll?


BobGardner@BobG... wrote:
>>I would like it better if you didn't top-post.
>
> =================================
> I'm taking a survey. I bet a buddy of mine that those who are a little OCD
> about their posting must also be a little OCD about the way their TP hangs.
> Does your roll off the front or the back of the roll?

I recall a conversation I had with a friend of mine many years ago.
He wanted to get married, and I thought he wasn't ready. I asked him
what difference it made whether the toilet paper came off the front
or the back. His response was that there was one and only one way,
off the front. I told him he wasn't ready for marriage.

I guess you aren't, either. I am.

I think a polite statement of my preference is a reasonable thing
to do.

I think your off-topic post is not a reasonable thing to do.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!




On Oct 6, 2005, at 7:26 PM, BobGardner@BobG... wrote:

> I'm taking a survey. I bet a buddy of mine that those who are a
> little OCD
> about their posting must also be a little OCD about the way their
> TP hangs.
> Does your roll off the front or the back of the roll?

Neither. When the paper hangs off the roll it creates a toy cats can
not resist. TP roll sits on top of the empty holder where it doesn't
flap to tease the cats. Empty rolls are thrown on the floor for the
cats to play with. Are especially fun when crushed and pushed under
the closed bathroom door.

--
David Kelly N4HHE, dkelly@dkel...
========================================================================
Whom computers would destroy, they must first drive mad.


Well, Mike and David, this hc11 group is for the most part very well
restrained. Those alt.hydrogen newsgroups have some VERY opinionated selfproclamied
geniuses that tell you exactly how they like you to post and everything else.
I remember poor Ann Landers used to get some crazy 'I've got this problem,
Ann" letters that were just too wierd for belief. Sure enough they were from a
bunch of guys in the dorm at Yale that had a bet on. Then she put her foot
down and said no more tp direction letters. She'd had enough. Peace, brothers


On Thu, 2005-10-06 at 22:11 -0400, BobGardner@BobG... wrote:
> I remember poor Ann Landers used to get some crazy 'I've got this problem,
> Ann" letters that were just too wierd for belief.

OK, I shall regard myself as duly admonished.

--
Cheers,
Paul B.