Loading ...
Sorry, an error occurred while loading the content.

Urgent help with hc11!!!

Expand Messages
  • hombre_kenno69
    Hi all, i m doing a course on the HC11 and i ve been assigned a project that computes the distance between two points (given the change in height and length)
    Message 1 of 20 , Oct 4, 2005
    View Source
    • 0 Attachment
      Hi all, i'm doing a course on the HC11 and i've been assigned a
      project that computes the distance between two points (given the
      change in height and length) thus using pythagoras to compute the
      hypoutenuse. I'm totally lost and stuck, since i'm not much of a
      programmer...at all
      So i'd appreciate any help at all!

      here's the question:
      The distance function, L2(¢x,¢y) computes the Euclidean distance
      between two points, whose x
      coordinates differ by ¢x and whose y coordinates differ by ¢y.
      Mathematically, the distance function
      is given by L2(¢x,¢y) = p(¢x)2 + (¢y)2.
      Your job will be to write a subroutine that computes L2(¢x,¢y), but
      only for unsigned integers.
      • Download and unzip the care package a3-care.zip to your floppy drive
      A:.
      • Again, these contain the skeleton and a sample A3Q3.ASM subroutine
      which you will complete.
      The Specification:
      • The subroutine L2 takes two 8-bit parameters as input on the stack.
      These represent the unsigned
      integers ¢x and ¢y.
      • The stack frame is set up by the skeleton. One byte is reserved for
      the return value, and then
      both parameters are pushed.
      • L2 will compute the function L2(¢x,¢y) = jp(¢x)2 + (¢y)2k and store
      the result on the stack.
      [Note the addition of the floor function.]
      • In the cases for which L2(¢x,¢y) > 255, L2 shall return 255.
      • You will use a working version of the sqrt function from Assignment
      2 to simplify your code.
      The model solution for sqrt is included within the care package. Be
      sure to properly observe the
      function protocols!
      • Once done the computation, your code shall perform an rts operation.
      • Your code may not use any fixed memory to complete its task, but may
      use the stack.
      • There are no scratch registers available, so make sure you save and
      restore any registers you use.
      • You will not modify the skeleton code, except in the inputs.


      Thnx guys!
    • Anders Friberg
      Be careful! Your professor is also reading this list! Regards, AF On Wed, 05 Oct 2005 06:58:11 -0000
      Message 2 of 20 , Oct 5, 2005
      View Source
      • 0 Attachment
        Be careful!

        Your professor is also reading this list!

        Regards,
        AF

        On Wed, 05 Oct 2005 06:58:11 -0000
        "hombre_kenno69" <hombre_kenno69@...> wrote:
        > Hi all, i'm doing a course on the HC11 and i've been
        >assigned a
        > project that computes the distance between two points
        >(given the
        > change in height and length) thus using pythagoras to
        >compute the
        > hypoutenuse. I'm totally lost and stuck, since i'm not
        >much of a
        > programmer...at all
        > So i'd appreciate any help at all!
        >
        > here's the question:
        > The distance function, L2(¢x,¢y) computes the Euclidean
        >distance
        > between two points, whose x
        > coordinates differ by ¢x and whose y coordinates differ
        >by ¢y.
        > Mathematically, the distance function
        > is given by L2(¢x,¢y) = p(¢x)2 + (¢y)2.
        > Your job will be to write a subroutine that computes
        >L2(¢x,¢y), but
        > only for unsigned integers.
        > • Download and unzip the care package a3-care.zip to
        >your floppy drive
        > A:.
        > • Again, these contain the skeleton and a sample
        >A3Q3.ASM subroutine
        > which you will complete.
        > The Specification:
        > • The subroutine L2 takes two 8-bit parameters as input
        >on the stack.
        > These represent the unsigned
        > integers ¢x and ¢y.
        > • The stack frame is set up by the skeleton. One byte is
        >reserved for
        > the return value, and then
        > both parameters are pushed.
        > • L2 will compute the function L2(¢x,¢y) = jp(¢x)2 +
        >(¢y)2k and store
        > the result on the stack.
        > [Note the addition of the floor function.]
        > • In the cases for which L2(¢x,¢y) > 255, L2 shall
        >return 255.
        > • You will use a working version of the sqrt function
        >from Assignment
        > 2 to simplify your code.
        > The model solution for sqrt is included within the care
        >package. Be
        > sure to properly observe the
        > function protocols!
        > • Once done the computation, your code shall perform an
        >rts operation.
        > • Your code may not use any fixed memory to complete its
        >task, but may
        > use the stack.
        > • There are no scratch registers available, so make sure
        >you save and
        > restore any registers you use.
        > • You will not modify the skeleton code, except in the
        >inputs.
        >
        >
        > Thnx guys!
        >
        >
        >
        >
        > ------------------------ Yahoo! Groups Sponsor
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
      • BobGardner@aol.com
        In a message dated 10/5/2005 7:01:38 A.M. Eastern Standard Time, anders.friberg@iba.se writes: Be careful! Your professor is also reading this list!
        Message 3 of 20 , Oct 5, 2005
        View Source
        • 0 Attachment
          In a message dated 10/5/2005 7:01:38 A.M. Eastern Standard Time,
          anders.friberg@... writes:

          Be careful!

          Your professor is also reading this list!



          ===========================
          Couldnt possibly be. He's like old... must be 35 or something... they didnt
          even have the internat when he was in school. This is our secret weapon! We
          rely upon the generosity of nice folks around the world to help us with our
          problems, and life is wonderful! Hey! What Happened! I cant log on! The cable
          system and phone system is down! Cant get to the internet! Wont be able to do
          homework! Wont be able to get a job! Wont be able to pay house payment! Will
          soon be living under an overpass! Aieeeeee!


          [Non-text portions of this message have been removed]
        • ahmsmith
          The problem seems straightforward. Which part is giving you trouble? I guess it would help if we knew what parts you have done or can do and had access to the
          Message 4 of 20 , Oct 5, 2005
          View Source
          • 0 Attachment
            The problem seems straightforward.

            Which part is giving you trouble?

            I guess it would help if we knew what parts you have done or can do
            and had access to the skeleton code and your current version of it.

            I doubt that anyone on this list is going to take the time to do
            your college work for you. On the other hand, if you do some work on
            it first, you can probably get some help with a particular issue if
            you get stuck.

            I would suggest that you start by outlining the several individual
            parts of the problem, then try to solve these, create code to
            perform the operations, then put it all together withing the
            skeleton code that you have.

            For example, detail each of the math operations necessary to do the
            Pythagorean function. Noting that the parameters and result are 8
            bit (one byte) unsigned integers, consider how large the
            intermediate values will need to be.

            You will need to allocate somewhere to store each of the
            intermediate values. The ninth bullet on your list will give you a
            hint about how to do this.

            The HC11 can do many math operations (add, subtract, multiply)
            directly, especially with 8 bit values. Other math operations can be
            done by a sequence of operations, for example squaring an 8 bit
            number can be done by mutiplying the byte by itself.

            You will need to understand how HC11 application passes the
            parameters to your subroutine and how you will pass the result back.
            To try out this process initially, make a simpler function that
            returns the sum of the two parameters.

            I don't know what tools you have access to, but you can download an
            HC11 simulator that will run on your PC and let you step through
            your code and verify the operation of your code.

            The good thing about a simulator is that it wont stop or crash if
            you have a bug in your code.

            Good Luck




            --- In m68HC11@yahoogroups.com, "hombre_kenno69"
            <hombre_kenno69@y...> wrote:
            > Hi all, i'm doing a course on the HC11 and i've been assigned a
            > project that computes the distance between two points (given the
            > change in height and length) thus using pythagoras to compute the
            > hypoutenuse. I'm totally lost and stuck, since i'm not much of a
            > programmer...at all
            > So i'd appreciate any help at all!
          • Anders Friberg
            On Wed, 5 Oct 2005 10:17:01 EDT ... LOL Maybe the cable and phone system was programmed by a student from last years class?
            Message 5 of 20 , Oct 5, 2005
            View Source
            • 0 Attachment
              On Wed, 5 Oct 2005 10:17:01 EDT
              BobGardner@... wrote:
              >
              > In a message dated 10/5/2005 7:01:38 A.M. Eastern
              >Standard Time,
              > anders.friberg@... writes:
              >
              > Be careful!
              >
              > Your professor is also reading this list!
              >
              >
              >
              > ===========================
              > Couldnt possibly be. He's like old... must be 35 or
              >something... they didnt
              > even have the internat when he was in school. This is
              >our secret weapon! We
              > rely upon the generosity of nice folks around the world
              >to help us with our
              > problems, and life is wonderful! Hey! What Happened!
              >I cant log on! The cable
              > system and phone system is down! Cant get to the
              >internet! Wont be able to do
              > homework! Wont be able to get a job! Wont be able to pay
              >house payment! Will
              > soon be living under an overpass! Aieeeeee!
              >
              >


              LOL

              Maybe the cable and phone system was programmed by a
              student from last years class?


              > [Non-text portions of this message have been removed]
              >
              >
              >
              > ------------------------ Yahoo! Groups Sponsor
              >
              >
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
              >
            • hombre_kenno69
              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
              Message 6 of 20 , Oct 5, 2005
              View Source
              • 0 Attachment
                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...

                My Code for L2, the subroutine to compute the length...so far..still
                very rough, but runs ok...

                L2: pshx
                pshy
                psha
                pshb

                tsx
                ldaa 9,x
                ldab 9,x ;load 5
                mul
                std 9,x
                psha
                pshb
                ldaa 8,x
                ldab 8,x
                mul
                std 8,x
                psha
                pshb
                ldab 10,x
                ldaa 9,x
                aba
                staa 8,x
                pula
                jsr sqrt


                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

                sqrt: psha ; save all registers and then
                pshb ; restore them just before
                pshx ; returning to the caller

                tsx ; IX points to the top of the
                ; stack frame

                ldaa #15 ; index <- 255

                loop: psha
                pulb
                des
                mul
                cpd 6,x
                bls endl ; while (index*index > param)

                pula
                deca ; index--
                bra loop

                endl: pula
                staa 8,x ; return index

                pulx
                pulb ; restore registers
                pula ; and return to caller
                rts

                If anyone could point me in the right direction for passing the
                results of the added squares which is A9 (hex) to the sub routine
                sqrt, that'd be greatly appreciated!!

                thnx guys
              • Tom Sefranek
                You SERIOUSLY need to comment your code. Line by line! Tell us what you MEAN to be doing, NOT what the assembly indicates. A paragraph describing what the
                Message 7 of 20 , Oct 5, 2005
                View Source
                • 0 Attachment
                  You SERIOUSLY need to comment your code.
                  Line by line!
                  Tell us what you MEAN to be doing, NOT what the assembly indicates.

                  A paragraph describing what the module is supposed ot do helps too.

                  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...
                  >
                  >My Code for L2, the subroutine to compute the length...so far..still
                  >very rough, but runs ok...
                  >
                  >L2: pshx
                  > pshy
                  > psha
                  > pshb
                  >
                  > tsx
                  > ldaa 9,x
                  > ldab 9,x ;load 5
                  > mul
                  > std 9,x
                  > psha
                  > pshb
                  > ldaa 8,x
                  > ldab 8,x
                  > mul
                  > std 8,x
                  > psha
                  > pshb
                  > ldab 10,x
                  > ldaa 9,x
                  > aba
                  > staa 8,x
                  > pula
                  > jsr sqrt
                  >
                  >
                  >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
                  >
                  >sqrt: psha ; save all registers and then
                  > pshb ; restore them just before
                  > pshx ; returning to the caller
                  >
                  > tsx ; IX points to the top of the
                  > ; stack frame
                  >
                  > ldaa #15 ; index <- 255
                  >
                  >loop: psha
                  > pulb
                  > des
                  > mul
                  > cpd 6,x
                  > bls endl ; while (index*index > param)
                  >
                  > pula
                  > deca ; index--
                  > bra loop
                  >
                  >endl: pula
                  > staa 8,x ; return index
                  >
                  > pulx
                  > pulb ; restore registers
                  > pula ; and return to caller
                  > rts
                  >
                  >If anyone could point me in the right direction for passing the
                  >results of the added squares which is A9 (hex) to the sub routine
                  >sqrt, that'd be greatly appreciated!!
                  >
                  >thnx guys
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >Yahoo! Groups Links
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >

                  --
                  *
                  | __O Thomas C. Sefranek WA1RHP@...
                  |_-\<,_ Amateur Radio Operator: WA1RHP
                  (*)/ (*) Bicycle mobile on 145.41, 448.625 MHz

                  http://hamradio.cmcorp.com/inventory/Inventory.html
                  http://www.harvardrepeater.org
                • Tom Sefranek
                  You SERIOUSLY need to comment your code. Doccument! It will save you a LOT of time. Line by line! Tell us what you MEAN to be doing, NOT what the assembly
                  Message 8 of 20 , Oct 5, 2005
                  View Source
                  • 0 Attachment
                    You SERIOUSLY need to comment your code.
                    Doccument! It will save you a LOT of time.
                    Line by line!
                    Tell us what you MEAN to be doing, NOT what the assembly indicates.

                    A paragraph describing what the module is supposed to do helps too.

                    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...
                    >
                    >My Code for L2, the subroutine to compute the length...so far..still
                    >very rough, but runs ok...
                    >
                    >L2: pshx
                    > pshy
                    > psha
                    > pshb
                    >
                    > tsx
                    > ldaa 9,x
                    > ldab 9,x ;load 5
                    > mul
                    > std 9,x
                    > psha
                    > pshb
                    > ldaa 8,x
                    > ldab 8,x
                    > mul
                    > std 8,x
                    > psha
                    > pshb
                    > ldab 10,x
                    > ldaa 9,x
                    > aba
                    > staa 8,x
                    > pula
                    > jsr sqrt
                    >
                    >
                    >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
                    >
                    >sqrt: psha ; save all registers and then
                    > pshb ; restore them just before
                    > pshx ; returning to the caller
                    >
                    > tsx ; IX points to the top of the
                    > ; stack frame
                    >
                    > ldaa #15 ; index <- 255
                    >
                    >loop: psha
                    > pulb
                    > des
                    > mul
                    > cpd 6,x
                    > bls endl ; while (index*index > param)
                    >
                    > pula
                    > deca ; index--
                    > bra loop
                    >
                    >endl: pula
                    > staa 8,x ; return index
                    >
                    > pulx
                    > pulb ; restore registers
                    > pula ; and return to caller
                    > rts
                    >
                    >If anyone could point me in the right direction for passing the
                    >results of the added squares which is A9 (hex) to the sub routine
                    >sqrt, that'd be greatly appreciated!!
                    >
                    >thnx guys
                    >
                    >
                    >
                    >
                    >
                    >
                    >
                    >
                    >Yahoo! Groups Links
                    >
                    >
                    >
                    >
                    >
                    >
                    >
                    >
                    >
                    >
                    >

                    --
                    *
                    | __O Thomas C. Sefranek WA1RHP@...
                    |_-\<,_ Amateur Radio Operator: WA1RHP
                    (*)/ (*) Bicycle mobile on 145.41, 448.625 MHz

                    http://hamradio.cmcorp.com/inventory/Inventory.html
                    http://www.harvardrepeater.org
                  • Paul B. Webster VK2BZC
                    ... And part of the commentary - a most *important* part, probably *more* so than the end-of-line comments, is to use defined symbols as mnemonics for
                    Message 9 of 20 , Oct 5, 2005
                    View Source
                    • 0 Attachment
                      On Wed, 2005-10-05 at 18:10 -0400, Tom Sefranek wrote:
                      > You SERIOUSLY need to comment your code.

                      And part of the commentary - a most *important* part, probably *more*
                      so than the "end-of-line" comments, is to use defined symbols as
                      mnemonics for constants and displacements.

                      You have for example, given us a code segment which refers to
                      variables pushed on the stack before the subroutine call. These
                      variables should be given *names*, not numbers (and you will likely be
                      marked on this point!). In addition, there are a few other apparent
                      blunders, some merely semantics, some important.

                      > >L2: pshx
                      > > pshy
                      > > psha
                      > > pshb

                      Someone correct me if I am wrong, but the HC11 is "big-endian" and
                      "pshd" would actually be "pshb ... psha" - just in case you were to use
                      it?

                      > > tsx
                      > > ldaa 9,x
                      > > ldab 9,x ;load 5
                      > > mul
                      > > std 9,x
                      > > psha
                      > > pshb
                      > > ldaa 8,x
                      > > ldab 8,x
                      > > mul
                      > > std 8,x

                      Courting trouble:

                      > > psha
                      > > pshb

                      > > ldab 10,x
                      > > ldaa 9,x
                      ... Should have been ldd 9,x

                      > > aba
                      > > staa 8,x
                      > > pula

                      You now have three more things on the stack than when you started. Is
                      that what you wanted?

                      > > jsr sqrt

                      So you jump to the subroutine and come back with all sorts of things
                      on the stack. You are going to clean them up now?

                      > >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
                      > >
                      > >sqrt: psha ; save all registers and then
                      > > pshb ; restore them just before
                      > > pshx ; returning to the caller
                      > >
                      > > tsx ; IX points to the top of the
                      > > ; stack frame
                      > >
                      > > ldaa #15 ; index <- 255
                      > >
                      > >loop: psha
                      > > pulb
                      > > des

                      Pray no-one *ever* uses interrupts with this code!

                      > > mul
                      > > cpd 6,x

                      Arguably, if the prof does this himself, he won't mark you down.

                      > > bls endl ; while (index*index > param)
                      > >
                      > > pula
                      > > deca ; index--
                      > > bra loop
                      > >
                      > >endl: pula
                      > > staa 8,x ; return index
                      > >
                      > > pulx
                      > > pulb ; restore registers
                      > > pula ; and return to caller
                      > > rts
                      > >
                      > >If anyone could point me in the right direction for passing the
                      > >results of the added squares which is A9 (hex) to the sub routine
                      > >sqrt, that'd be greatly appreciated!!

                      I thought from your imitation of the same techniques, you understood
                      this? I think you need to sit and work out what is going on on the
                      stack all through this code.

                      --
                      Cheers,
                      Paul B.
                    • Mike McCarty
                      ... 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
                      Message 10 of 20 , Oct 6, 2005
                      View Source
                      • 0 Attachment
                        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
                        --
                        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!
                      • Gordon Couger
                        Mike, I strongly disagree with commenting every line. Its been 5 years ... 16-bit ... each loop. ... Figuring this out is part of the exercise it is extremely
                        Message 11 of 20 , Oct 6, 2005
                        View Source
                        • 0 Attachment
                          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
                        • Mike McCarty
                          ... 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
                          Message 12 of 20 , Oct 6, 2005
                          View Source
                          • 0 Attachment
                            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!
                          • BobGardner@aol.com
                            In a message dated 10/6/05 4:08:11 P.M. Eastern Daylight Time, ... ========================== OK, good so far. No comments......bad Comments every
                            Message 13 of 20 , Oct 6, 2005
                            View Source
                            • 0 Attachment
                              In a message dated 10/6/05 4:08:11 P.M. Eastern Daylight Time,
                              Mike.McCarty@... 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?


                              [Non-text portions of this message have been removed]
                            • Mike McCarty
                              ... HEY! I DIDN T WRITE THAT! Take a little more care with your attributes? ... I gave several examples in my message. Mike --
                              Message 14 of 20 , Oct 6, 2005
                              View Source
                              • 0 Attachment
                                BobGardner@... wrote:
                                >
                                > In a message dated 10/6/05 4:08:11 P.M. Eastern Daylight Time,
                                > Mike.McCarty@... 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!
                              • Paul B. Webster VK2BZC
                                ... 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
                                Message 15 of 20 , Oct 6, 2005
                                View Source
                                • 0 Attachment
                                  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.
                                • BobGardner@aol.com
                                  ... ================================= 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
                                  Message 16 of 20 , Oct 6, 2005
                                  View Source
                                  • 0 Attachment
                                    > 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?





                                    [Non-text portions of this message have been removed]
                                  • Mike McCarty
                                    ... 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
                                    Message 17 of 20 , Oct 6, 2005
                                    View Source
                                    • 0 Attachment
                                      BobGardner@... 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!
                                    • David Kelly
                                      ... 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
                                      Message 18 of 20 , Oct 6, 2005
                                      View Source
                                      • 0 Attachment
                                        On Oct 6, 2005, at 7:26 PM, BobGardner@... 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@...
                                        ========================================================================
                                        Whom computers would destroy, they must first drive mad.
                                      • BobGardner@aol.com
                                        Well, Mike and David, this hc11 group is for the most part very well restrained. Those alt.hydrogen newsgroups have some VERY opinionated selfproclamied
                                        Message 19 of 20 , Oct 6, 2005
                                        View Source
                                        • 0 Attachment
                                          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


                                          [Non-text portions of this message have been removed]
                                        • Paul B. Webster VK2BZC
                                          ... OK, I shall regard myself as duly admonished. -- Cheers, Paul B.
                                          Message 20 of 20 , Oct 6, 2005
                                          View Source
                                          • 0 Attachment
                                            On Thu, 2005-10-06 at 22:11 -0400, BobGardner@... 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.
                                          Your message has been successfully submitted and would be delivered to recipients shortly.