News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

variable usage list

Started by jimg, February 23, 2020, 02:26:56 AM

Previous topic - Next topic

jimg

Before I reinvent the wheel, does anyone know of a utility to provide a listing of variables used in a masm program, and all the lines they are used on?

It been at least two decades since I've done such a thing using the old ProgrammersWorkBench source browser.

If not it wouldn't be too hard to modify my tidy program, but I'd rather spend my time elsewhere if such a thing exists.  Google was no help to me.

jj2007

That rings a bell, but I can't find my source any more. What exactly do you want to achieve?

If you are just looking for specific variables, RichMasm's find listbox is an option - see the upper right corner. Given that MASM is case-sensitive, uncheck the case box and check the FW (full word). The list can be exported with Ctrl C.


daydreamer

Quote from: jimg on February 23, 2020, 02:26:56 AM
Before I reinvent the wheel, does anyone know of a utility to provide a listing of variables used in a masm program, and all the lines they are used on?

It been at least two decades since I've done such a thing using the old ProgrammersWorkBench source browser.

If not it wouldn't be too hard to modify my tidy program, but I'd rather spend my time elsewhere if such a thing exists.  Google was no help to me.
I have VC++ and there you can get some performance analyze tools,you can choose,cputest,memtest,gputest
I think it tests different functions(PROC's name in C++) how freqently they are called to help programmer identify where for example 80%+ execution is happening so s/he can concentrate on optimize those functions instead of whole program,maybe memtest checks how freqently mem variables are used is the closest thing I can think of
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jimg

Thanks jj.

I was just turning a large program into a small program that does much less, and wanted to delete all the variables that were no longer used.  In the old days, compilers would routinely give you a list of variables declared but not used.  I can search for each one, one at a time, but I thought there must be a program out there that does it these days for a masm program.

jj2007

Do a find and replace for LOCAL -> ; LOCAL, then assemble the program, and you'll get a list of the variables used :thumbsup:

Post that source, it could be fun:
- look for all instances of endp (case-insensitive, full word)
- for each match, go up until you find the corresponding proc
- get a list of the locals, and check for each variable if they appear between the line after the last local and the endp

jimg

#5
Just for you Jochen.

This is my findall program stripped down to be a super dir program.  So far I have just stripped out the stuff I didn't need and got it working so it produces a listing of files that meet the name criteria and the size of the file.  I haven't added any of the new stuff, e.g. filter on attributes, times, etc.
But here it is if you think it will be fun.  I'll leave it up for a day or so.  Bear in mind, this is a work in progress and currently a real mess.
edit: dead link deleted.

jj2007

Thanks, Jim. In the meantime, I found my plugin:
- extract the DLL to \Masm32\MasmBasic\Plugins\AnalyseVariableUse.dll
- start \Masm32\MasmBasic\RichMasm.exe
- open a source
- goto menu System & plugins, Analyse variable use

Example output:
0617 chrg
0097 wParam
0086 hWnd
0060 lParam
0047 hwnd
0047 hFind
0045 msg
0044 hList
0038 hPipeEdit
0033 Utf8
0032 LcBuffer
...
0002 bubY
0002 BmText
0002 AddInOlly
0002 ActivateAs
0001 upRes3
0001 upRes2
0001 txThisIsJJ
0001 txInvoke
0001 txFont
0001 txErrCPro
0001 txCWC
0001 txAutoCode
0001 txAsmBcw
0001 tfRes2
0001 tfRes1
0001 SnippetTitle
0001 SLmy2
0001 SLmx2
0001 SigSize
0001 SigPattern
0001 SigMask
0001 SigCount
0001 ShowMSG
0001 rPiStart
0001 rPiSrcType
0001 rPiRepl
0001 rPiPipe
0001 rPiPath
0001 rPiOptions
0001 rPiNumBm
0001 rPiLen
0001 rPiFind
0001 rPiDirty
0001 rPiContent
0001 rPiBook
0001 rPiAux
0001 pvReserved
0001 pszFile
0001 prtMarginsMM
0001 pcFlag
0001 opStatic
0001 NullEnv
0001 NotificationUnhook
0001 NotificationHook
0001 nMaxFileTitle
0001 nMaxCustFilter
0001 nFileOffset
0001 MyPublicBuffer
0001 MyLocalBuffer
0001 MimeType
0001 lspTimeout
0001 lspCurPipe
0001 lspBufferStart
0001 lspBufferEnd
0001 lpThreadId
0001 lpTemplateName
0001 lpstrCustomFilter
0001 LocName
0001 ListRC
0001 lCustData
0001 LastVar
0001 LastMy
0001 jwDate
0001 jjMagic9
0001 jjMagic8
0001 jjMagic7
0001 jjMagic6
0001 jjct
0001 jfText
0001 jfLen
0001 ItemID
0001 infHist2
0001 hWriteIn
0001 hMenuWinStc
0001 hBrushMenuWin
0001 grc
0001 gpStringFormat2
0001 gpPen2
0001 gpOtherD
0001 gpOtherC
0001 gpOtherB
0001 gpOtherA
0001 gpOther2D
0001 gpOther2C
0001 gpOther2B
0001 gpOther2A
0001 gpLine2
0001 FormatID
0001 FormatDescription
0001 FlagsEx
0001 findpos
0001 FindArray
0001 FilenameExtension
0001 fbSaveAs
0001 EdRes2
0001 EdRes1
0001 DragFile
0001 DoNotInclude
0001 DllName
0001 DebugMsg
0001 cyBottomHeight
0001 cxRightWidth
0001 cxLeftWidth
0001 CodecName
0001 Clsid
0001 BufStart
0001 bubMarker
0001 AuxMenu
0001 AnotherVar


The lower variables are the ones you are looking for, I guess :biggrin:

jimg

#7
Thanks.

And since you're a freebasic fan, here's the program I just modified to print out all the tokens and the lines they appear on.  A little crude since it counts constants (like 0, 1) and all instructions too, but okay for a first try.
edit: dead link deleted.

jj2007

Thanks, Jim. It compiles but complains that it doesn't know "sort": Shell "sort unsorted.txt /o sorted.txt"
From the commandline the sort command works. I changed it to WinExec(), and that works, too, but the format of sorted.txt looks a bit odd:
.186 .186
.286 .286
.286c .286c
.286p .286p
.287 .287
.386 .386
.386p .386p
.387 .387
.486 .486
.486c .486c
.486p .486p
.586 .586
.586p .586p
.686 .686
.686p .686p
.8086 .8086
.8087 .8087
.alpha .alpha
.break .break
.breakif .breakif
.code .code
.const .const
.continue .continue
.cref .cref
.data .data
.data? .data?
.dosseg .dosseg
.else .else
.elseif .elseif
.endif .endif
.endw .endw


FORTRANS

Hi,

Quote from: jimg on February 23, 2020, 02:26:56 AM
Before I reinvent the wheel, does anyone know of a utility to provide a listing of variables used in a masm program, and all the lines they are used on?

   I may be showing a bit of obsolescence here, but
wasn't that CREF.EXE back in the "good old days"?

Cheers,

Steve N.

jimg

jj- i'll look into it, I just ran it with no problems, so something else is amiss.

Fortrans-  Yes, but it requires two files I no longer have any ability to produce.  I doubt I could get PWB working even if it was worth the effort :)

jimg

jj-
is calling you jj a problem?  If it irritates you, let me know.

anyway,  each line of the sort file contains the lower case version of the keyword, followed by what we want to change it to.  In this particular case, they happen to be the same, but not for other things I use the program for (e.g. great cow basic).

No idea why the shell command doesn't work for you.  I'm using the latest version of fb,  are you using an older version?

jj2007

Quote from: jimg on February 23, 2020, 10:08:51 AM
jj-
is calling you jj a problem?  If it irritates you, let me know.

Not at all, Jim :thup:

Quoteanyway,  each line of the sort file contains the lower case version of the keyword, followed by what we want to change it to.  In this particular case, they happen to be the same, but not for other things I use the program for (e.g. great cow basic).

No idea why the shell command doesn't work for you.  I'm using the latest version of fb,  are you using an older version

Version 1.05 of January 2016. Google shell "Freebasic" to find some threads with similar problems. It's messy.

jimg

I'm using 1.07.1

I've made a lot of changes since I post last.  Grouped types in the reference list,  Variables, Labels, Keywords, and Literals.  I'll put a link in a bit after I get literals a little better.  Kinda fun doing basic again :)

jimg

#14
updated asmtidy- edit: deleted dead link