Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!hao!oddjob!gargoyle!ihnp4!inuxc!iuvax!iucs!bobmon From: bobmon@iucs.UUCP Newsgroups: comp.misc Subject: Re: Assembly Language Message-ID: <4650@iucs.UUCP> Date: Fri, 14-Aug-87 21:59:14 EDT Article-I.D.: iucs.4650 Posted: Fri Aug 14 21:59:14 1987 Date-Received: Sun, 16-Aug-87 09:10:25 EDT References: <892@edge.UUCP> <2840@phri.UUCP> Reply-To: bobmon@iucs.UUCP (RAMontante [condition that I not be identified]) Organization: Indiana University, Bloomington Lines: 35 In article <2840@phri.UUCP> roy@phri.UUCP (Roy Smith) writes: > > My experience has been that most assembler code has one comment >per statement, often not very useful at that. A typical example might be: > > add r1, r2 ; add r1 to r2, leave result in r2 > cmp r2, r0 ; is r2 greater than r0? > bge skip1 ; if no.... > mov r0, -(sp) ; push r0 onto the stack > bra skip2 ; if yes... >skip1: mov r2, -(sp) ; push r2 onto the stack >skip2: jsr foo ; call subroutine foo > > Of course, this is not to say that there aren't assembler >programmers who comment the algorithm instead of translating the opcodes >into english, but they seem rare. In fact, I would guess that in most >assembler courses (are there any of these anymore?) the above code would >get a positive nod from the instructor because every line had a comment, >just like it is supposed to. Sorry, I hafta defend my honor here. I'm a grad student, I just (today!) finished teaching an undergraduate assembly-language course. Actually it's called "Computer Structures", but it's centered on the machine language. I've gone to the point of public ridicule to discourage the "add memory to register" style of comments. I specifically said that I preferred a block of comments about a subroutine to line-by-line comments. I told them that the comments should tell me WHY, not WHAT. I told them to write the kind of comments they would want to read if they had to debug their own code in 6 months. Yes, it works. At least, for some of them. I give grades to distinguish between those who pick up good techniques and those who don't. Wanna see some well-commented assembly code? Wanna hire one of my brighter kids? (They even use metric units...)