News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How do you tell what a name represents?

Started by Sergiu FUNIERU, February 26, 2010, 06:55:39 PM

Previous topic - Next topic

Sergiu FUNIERU

I try to understand an example code that uses sas.
sas txt, "Text string"

What is sas? In the original code, there is a comment next to the line above, which says that sas assigns a string to a local variable.

I tried to find the sas' syntax in the MASM32's chm, in the string macro section : I found there add, cat and so on, but not sas.

1. When you see something like the above, how do you know if you're looking for a macro? That is, can be something else with a syntax like a macro?
2. How do you know what particular library did that macro come from?

I generated a map file, and I found there something like this:
Module: \masm32\lib\masm32.lib(strlen.asm)
004010d0       _StrLen@4
which tells me that strlen came from masm32.lib and, more exactly, from strlen.asm
I didn't find any references to sas in the map file.

qWord

if it is not a keyword of masm or an instruction and has arguments (especially quoted ones) it must be a macro. If not sure take a look in the listing or search the includes.
from macro.inc:
    ; *******************************************
    ;             String Assign                 *
    ; Assign quoted text to a locally declared  *
    ; string handle (DWORD variable) in a proc  *
    ; to effectively have a LOCAL scope strings *
    ; EXAMPLE :                                 *
    ; sas MyVar,"This is an assigned string"    *
    ; *******************************************
      sas MACRO var,quoted_text:VARARG
        LOCAL txtname
        .data
          txtname db quoted_text,0
          align 4
        .code
        mov var, OFFSET txtname
      ENDM
FPU in a trice: SmplMath
It's that simple!

Sergiu FUNIERU

Quote from: qWord on February 26, 2010, 07:06:35 PMfrom macro.inc:
How did you know it was in that particular file? Is there any program that can tell me that?

BlackVortex

#3
Quote from: qWord on February 26, 2010, 07:06:35 PM
if it is not a keyword of masm or an instruction and has arguments (especially quoted ones) it must be a macro.
What he said. So, then you search in macros.inc in the includes

qWord

the masm32-package comes with a large set of macros which mainly resist in macro.inc. Also there are some macros in ucmacros.inc (unicode support) and \include\dialogs.inc (in memory dialogs). In the macros folder you can find lst.exe which list all macros from macro.inc.

BTW: there are two forms of macros: functions and procedures.
The first are called like: MacroName(arg1,arg2...)and the second: MacroName arg1,arg2....
FPU in a trice: SmplMath
It's that simple!

Sergiu FUNIERU

Quote from: BlackVortex on February 26, 2010, 07:27:09 PMWhat he said. So, then you search in macros.asm in the includes
This happens only if I use macros from MASM32. If my program also uses other libraries and the include files also include other inc files, how do I find the location of that particular macro?

I hoped that all the macro names would be listed in the map file, but it seems that some are not.

Is there any editor that can automatically tell me the macros' location when I'm (right) clicking on the macro's name?

qWord

RadAsm recognize macros as long as the corresponding include/asm file is part of the project.
FPU in a trice: SmplMath
It's that simple!

jj2007

Some file managers, such as xPlorer2 lite, have very powerful search functions. I go to \masm32, choose *.asm, *.inc as filter and search for sas in all files. 21 entries, among them \masm32\macros\macros.asm

qWord

making a search with 'sas macro' will bring him directly to the definition   :toothy
FPU in a trice: SmplMath
It's that simple!

jj2007

Quote from: qWord on February 26, 2010, 07:50:44 PM
making a search with 'sas macro' will bring him directly to the definition   :toothy

Maybe. Sometimes there is a tab in between, instead of a space; or two spaces.... No problem for RichMasm, sas*mac will find it inside the macros.asm file, but I have not yet seen a "folder searcher" that performed this simple operation.

BlackVortex

Far Manager does some pretty brutal in-file searching. It has an option to search for "whole words", so you could search for "sas macro" just fine. And more sweet searching and filtering options.