Announcement

Collapse
No announcement yet.

Unused allocations

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unused allocations

    One thing that I would like in the IDE is a 'tick' or something next to any GLOBAL or DIM which I then do not use.

    This would save me time and might even contribute to finding logic errors.

    Would anyone else find this useful? And should we pressure Adam?

    Kerry
    [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
    Kerry Farmer

  • #2
    If I have forgotten what is used and what is not, I comment suspect ones out and compile to see if it was missed. You could write it yourself but you would have to scan each sub/function for locals as well as dealing with globals.
    hutch at movsd dot com
    The MASM Forum - SLL Modules and PB Libraries

    http://www.masm32.com/board/index.php?board=69.0

    Comment


    • #3
      I'm sure that Adam has far more pressing issues

      That would really require the compiler to edit the source code file(s) and it would be a very complex operation.
      Far easier just to comment out any you are unsure of yourself and keep re-compiling until you don't get an "undeclared variable"

      Comment


      • #4
        Let Adam concentrate on the new compiler...

        You can use another IDE like JK-IDE which already does that, plus code folding and much more.
        I use use it regularly to cleanup unused variables, that I may have used during development and testing

        Pink is no longer referenced in code (Unused)
        Both in function (Local) and (Global)


        Click image for larger version

Name:	JK1.png
Views:	166
Size:	9.2 KB
ID:	817893

        Click image for larger version

Name:	JK2.png
Views:	156
Size:	10.2 KB
ID:	817894

        Comment


        • #5
          Or you could check your source file by dropping it onto Borje's PBCodec utility.

          That wiil show you any Local / Global duplicates, unused Variables, Functions and Subs..

          Jim Fritts posted an updated version here. It's a PBWin program but the executable (PBCODEC_1_6.EXE) is in the zip file that is attached there.

          Click image for larger version  Name:	PBCodec.png Views:	0 Size:	7.7 KB ID:	817900
          Rgds, Dave

          Comment


          • #6
            I never have any problem with the kind of declared variables.

            I always use:

            1. $DIM ALL

            2. a prefix for the types
            - GLOBAL g_xxx
            - LOCAL l_xxx
            - STATIC s_xxx
            - Function parameters without prefix

            => Sorry I misread the 1st amount.

            I use also PBCODEC.EXE to recognize unused variables.




            Comment


            • #7
              FWIW, simply declaring a variable allocates no memory unless that variable is actually used in executable code. Been like that since PB/DLL I. (ONE)

              BTW, I was a PBCodec user, too.

              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Thanks Guys

                There seems to be some consensus that it is a good idea to have a function to check for unused variables.

                Steve - this is what I do! I always find some. It is a pain for a big program with pages of variables.

                Stuart - I am happy to pressure Adam! But he does not have to agree. I am surprised you think it is such a big exercise - I think I could write it myself!

                Rod - I wondered about JK-IDE. I tried to use it myself ages ago and ran into some issues (forget what they were) but gave up. Perhaps it is time for a new look. I always wondered if it was so good, why Adam did not endorse it - his call of course

                Dave - Thanks. I have got PBWIN but I never use it. It would take some time to do all that!

                Norbert - Thanks where do I get PBCODEC.EXE from?

                Michael - Your opinion is always worth reading!

                Thank you everyone - great forum.
                [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                Kerry Farmer

                Comment


                • #9
                  Originally posted by Kerry Farmer View Post
                  Thanks Guys

                  There seems to be some consensus that it is a good idea to have a function to check for unused variables.

                  Norbert - Thanks where do I get PBCODEC.EXE from?

                  Thank you everyone - great forum.
                  Good Idea yes, do I need it in PB IDE no, Not if it's going to delay the compiler more.
                  We already have simple ways of doing that.

                  Were do you get PBCodec? see link given in post#5 look at word HERE
                  "Jim Fritts posted an updated version here. It's a PBWin program but the executable (PBCODEC_1_6.EXE) is in the zip file that is attached there."

                  Comment


                  • #10
                    It is a pain for a big program with pages of variables.
                    It's a lot easier if you write using lots of procedures, without GLOBALs. Makes it tough for variables to get lost too badly.

                    Of course with the later compilers, there's also the #UNIQUE compiler directive to save your butt.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Originally posted by Kerry Farmer View Post
                      Stuart - I am happy to pressure Adam! But he does not have to agree. I am surprised you think it is such a big exercise - I think I could write it myself!.
                      In that case, take a look at PBCodec and upgraded it to modify your source file

                      Originally posted by Kerry Farmer View Post
                      Norbert - Thanks where do I get PBCODEC.EXE from?
                      .
                      Dave's link above. But note that it has a number of hard coded paths in it , so it will probably need to be recompiled.

                      Comment


                      • #12
                        Rod

                        I agree with you about compiler speed - I love it. [I still have vague memories of a compile taking all night - batch compiles at a bureau!]

                        We could have an option in the compiler

                        #UNUSED ON/OFF

                        I would usually turn it on only near the end of the project and then only once or twice.

                        Kerry
                        [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                        Kerry Farmer

                        Comment


                        • #13
                          Michael

                          #UNIQUE only does half the job - but I never noticed it before!
                          [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                          Kerry Farmer

                          Comment


                          • #14
                            Thanks Stuart

                            I will
                            [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                            Kerry Farmer

                            Comment


                            • #15
                              agree with you about compiler speed - I love it. [I still have vague memories of a compile taking all night
                              You forgot the time it takes to wait in line to get access to the keypunch machine and then create your program source code.
                              Michael Mattias
                              Tal Systems (retired)
                              Port Washington WI USA
                              [email protected]
                              http://www.talsystems.com

                              Comment


                              • #16
                                Originally posted by Michael Mattias View Post

                                You forgot the time it takes to wait in line to get access to the keypunch machine and then create your program source code.
                                If you were fortunate enough to have access to a keypunch machine rather than have your job go into the pile assigned to a keypunch operator
                                Last edited by Stuart McLachlan; 28 Jul 2022, 12:06 AM.

                                Comment


                                • #17
                                  MCM - At least I got to flirt with the punch girls (always 'girls' although today we would call them 'women')

                                  Stuart - Yep I used to be able to use one of those hand punches - is that what you meant?

                                  AND I have a punched card in a frame hanging on the wall next to my computer

                                  You young guys do not know how tough it was for us!!!
                                  [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                                  Kerry Farmer

                                  Comment

                                  Working...
                                  X