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

func nmcall

MPE documents

Complete PDF
Table of Contents
Index

E0201 Edition 4 ♥
E0300 Edition 3
E0692 Edition 3

Dynamically calls a procedure/function, passing up to four parameters.

Syntax



   nmcall (path) [parm1] [parm2] [parm3] [parm4]

This function is used to perform a dynamic procedure call. It is implemented by calling the HPGETPROCPLABEL intrinsic to ensure the desired routine is loaded, and then uses the FCALL routine in the Pascal/XL compiler to invoke the routine. The called code is invoked at the same privilege level as the routine that invoked Debug (for example, the privilege level contained in the PRIV environment variable). DAT invokes the routine from privilege level 2. This function is not available from SAT. Four parameters are always passed to the indicated routine. These values are placed in the argument registers (arg0..arg3). It is up to the called code to correctly define its parameter list and interpret the parameters appropriately.

If you are not familiar with the procedure calling conventions as used by the language compilers, please refer to the Procedure Calling Conventions Reference Manual

The value returned by the called routine (if any) in the function return register (R28), is used as the result of the NMCALL function. Because this register contains only a 32-bit value, code that returns data larger than 32 bits should not be invoked. If the called routine does not return a value, whatever value that happens to be in R28 is used as the value of this function (for example, the function is undefined).

Formal Declaration



  nmcall:s32 (path:str) [parm1:sptr=0] [parm2:sptr=0]
                        [parm3:sptr=0] [parm4:sptr=0]

Parameters


path

The code path specification for the NM procedure/function to be called. The format of this parameter is:


   file_name/procname

The file_name part specifies the library to be searched for procname. The file_name part is optional. If it is not provided, the current list of loaded files for the process (see the LOADINFO command) will be searched. Refer to the HPGETPROCPLABEL intrinsic for additional details, assumptions, and restrictions involving searching libraries.


NOTE: Unlike the other forms of procedure PATH specifications (for example, the NMADDR function), module names and nested procedures are not supported by this function.

parm1,2,3,4

These parameters are used to pass values to the routine being called. They are passed in arg0 (r26), arg1 (r25), arg2 (r24), and arg3 (r23). Each may contain any value up to 32 bits in length. The called code must know how to interpret these values. If the called routine has fewer parameters, the zeros passed in the remaining argument registers are harmless. If the called routine has additional parameters, their values are undefined. Be sure you understand the procedure calling conventions and the parameter type alignment restrictions imposed by the various language compilers before trying to pass complicated parameters.

Examples



    $nmdat > wl nmcall("nl.pub.sys/CLOCK")
    $d1f3709

    $ nmdat > wl nmcall("CLOCK")
    $d1f3b00

Call the CLOCK intrinsic which is in the system library. Since that library is part of every process's loaded file list, the library name is optional.

Limitations, Restrictions


This function is not supported in SAT.

Debug only is affected by the following restrictions. Currently, you must have privileged mode (PM) to call this function. Furthermore, only code that has been running at privilege level 0, 1, or 2 (see the PRIV environment variable) is able to use this function. This is due to security problems that would occur due to the internal implementation of the function.


CAUTION: Because the called code runs on the stack above the debugger, it is possible for the called code to write into the stack space where the debugger currently exists. It is conceivable that a process abort or even system abort could result when returning from the called code due to modification of the debugger's portion of the stack.




func nmbpinstr


func nmentry