HPlogo System Debug Reference Manual > Chapter 10 System Debug Standard Functions

func nmaddr

MPE documents

Complete PDF
Table of Contents
Index

E0201 Edition 4 ♥
E0300 Edition 3
E0692 Edition 3

Returns the virtual address of the specified NM procedure/data path.

Syntax



   nmaddr (path [lookupid])

The values returned by this function are the values as found in the symbol table that is searched. This function does not perform any form of symbol location fixups. The address returned for most data symbols must be relocated relative to DP to be useful.

Formal Declaration



   nmaddr:long (path:str [lookupid:str="PROCEDURE"])

Parameters


path

The path specification for the NM procedure or data specified in the form:


   file_name/module_name:procedure/dataname

or, for nested procedures:

   file_name/module_name:parent_procedure.procedure

lookupid

A keyword indicating where to look for the code path specification given above. Refer to the "Procedure Name Symbols" section in chapter 2 for additional details. Valid keywords and their meanings are as follows:

Keyword

Meaning

UNIVERSAL

Search exported procedures in the SOM symbols.

LOCAL

Search nonexported procedures in the SOM symbols.

NESTED

Search nested procedures in the SOM symbols.

PROCEDURES

Search local or exported procedures in the SOM symbols.

ALLPROC

Search local/exported/nested procedures in the SOM symbols.

EXPORTSTUB

Search export stubs in the SOM symbols.

DATAANY

Search exported and local data SOM symbols.

DATAUNIV

Search exported data SOM symbols.

DATALOCAL

Search local data SOM symbols.

LSTPROC

Search exported level 1 procedures in the LST.

LSTEXPORTSTUB

Search export stubs in the LST.

ANY

Search for any type of symbol in the SOM symbols.

If a keyword is not given, the default PROCEDURES is used. In all cases, if the path contains a procedure name that appears as a nested procedure (for example: name.name), the function assumes the caller meant to use the NESTED keyword.

The keyword may be abbreviated. The table of keywords (above) is searched from top to bottom. Thus DATA is resolved as DATAANY.


NOTE: Searching the SOM symbols is noticeably slower than searching the LST symbols.

Examples



   $nmdebug > wl processstudent
   PROG $4d5.5d24
   $nmdebug > wl nmaddr("processstudent")
   PROG $4d5.5d24

Write the address for the processstudent procedure. The expression evaluator can locate the procedure since it is an exported universal procedure. The procedure may also be located by using the NMADDR function. The default lookupid PROCEDURES is used.

   $nmdebug > wl processstudent.highscore
   Expected a number, variable, function, or procedure (error #3720)
     undefined operand is: "processstudent"
     wl processstudent.highscore

The above example attempts to locate the nested procedure highscore. The expression evaluator fails. This is due to the fact that a dot "." is used to separate parts of a long pointer by the expression evaluator. The correct method of locating a nested procedure is demonstrated in the following example.

   $nmdebug > wl nmaddr("processstudent.highscore")
   PROG $4d5.5b50

The NMADDR function parses the dot in the nested procedure name and finds it's location.

   $nmdebug > wl nmaddr("highscore")
   Couldn't translate path to an address.  (error #1612)
   Error evaluating a predefined function.  (error #4240)
     function is"nmaddr"
     wl nmaddr("highscore")

   $nmdebug > wl nmaddr("highscore" "nested")
   PROG $4d5.5b50

In the above example an error occurs because the default lookupid of PROCEDURES is used. Since highscore is a nested procedure, NMADDR fails to locate it. When the NESTED lookupid parameter is specified, the search succeeds.

   $nmdebug > wl nmaddr("input" "data")
   PROG $4d5.400003a8

The NMADDR function is also able to look up data symbols. The above example locates the address for the symbol input. The value returned is the value found in the SOM symbol table. This function does not perform data symbol location fixups. Only those data symbols placed into the SOM symbol table by the language compilers are locatable. Most language compilers do not place the program's variables into this data structure.

   $nmdebug > wl average
   GRP $4d8.15c88

   $nmdebug > wl nmaddr("average")
   GRP $4d8.15c88

The above example locates the address for the average procedure. Note that this procedure resides in the group library.

   $nmdebug > wl nmaddr('p heap:P NEW HEAP')
   USER $10d.12f3dc

The above example prints out the address of one of the Pascal library routines. Notice the module qualifier.

   $nmdebug > wl FOPEN
   SYS $a.3f8140

   $nmdebug > wl nmaddr("FOPEN")
   SYS $a.3f8140

   $nmdebug > wl nmaddr("nl.pub.sys/FOPEN")
   SYS $a.3f8140

   $nmdebug > wl nmaddr("FOPEN" "LST")
   SYS $a.3f8140

   $nmdebug > wl ?FOPEN
   SYS $a.3f80e4

   $nmdebug > wl nmaddr("FOPEN" "EXPORTSTUB")
   SYS $a.3f80e4

The last set of examples show various methods of locating the entry point and export stub for the FOPEN intrinsic. Notice that the question mark is not used in the NMADDR function when referring to stubs.

Limitations, Restrictions


Only addresses corresponding to the process's loaded file set (program file and libraries) succeed.

System Debug displays stubs by preceding the symbol name with a question mark. For example, the export stub for FOPEN would appear as ?FOPEN. This form is not honored by this function (see the last example above).

The addresses for data symbols are not relocated.




func mapva


func nmbpaddr