## ALP Programming Guide and Reference

[prev][next][parent][TOC]

### Parameter List

The optional Parameter-List defines the parameters that the caller passes to the procedure on the run-time stack.

Syntax

    [ ,   [ LineBreak ] ]   Parm - List

Parm-List:
Parm-Spec [, [LineBreak] Parm-Spec ...]

Parm-Spec:
Parameter-Name [:Type]

The introductory comma in front of the Parm-List is only required if a LineBreak is used to put the first Parm-Spec on the line following the PROC directive.

The optional LineBreak entry allows you to end a Parm-Spec entry with a comma, enter an optional EndOfLine-Comment followed by a physical NewLine character, then continue the Parm-List on the next line.

Remarks

Each Parameter-Name is defined as a Numeric-EquateName that is visible only from within the body of the procedure. The value assigned to the parameter name is an expression that defines the parameter type and its location on the stack relative to the value of the frame pointer (the BP or EBP register). The assembler automatically calculates the correct offset value based upon the size of the parameter type.

The Type field is specified as a Type-Declaration and defines the data type associated with the Parameter-Name. If this field is omitted, the data type defaults to WORD if the procedure is defined within a USE16 segment, and DWORD if the procedure is defined within a USE32 segment.

The programmer can read from and store into the locations defined by the Parm-Spec entries as though they were regular named variables, but if the parameter names are to be combined in indexed expressions with other registers, the normal rules for specifying BP- and EBP-relative expressions must be followed.

Example

This example defines a ReadBuffer procedure to accept four arguments passed on the stack.

             . 386                          ;   Assemble   for   32 - bit   processors
             . model   flat , syscall         ;   OS / 2   programming   model / calling   convention

             EXTERN   DosRead : PROC         ;   OS / 2   DosRead ( )   API
             INCLUDELIB   os2386 . lib       ;   This   lets   us   link   to   the   API

             . code                         ;   Open   the   code   segment

    ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ;   Call   operating   system   to   read   input   into   a   buffer
    ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ReadBuffer   PROC ,                     ;   need   comma   to   continue   the   PROC   statement
                    hFile : dword ,          ;   parm   1 :   Read   handle
                    pBuffer : ptr   byte ,     ;   parm   2 :   Address   of   input   buffer
                    cbRead : dword ,         ;   parm   3 :   Size   of   input   buffer
                    pulActual : ptr   dword   ;   parm   4 :   Address   of   byte   count   from   read

             ;   set   up   to   call   the   OS / 2   DosRead   entry   point

             PUSH    pulActual              ;   arg   4
             PUSH    cbRead                 ;   arg   3
             PUSH    pBuffer                ;   arg   2
             PUSH    hFile                  ;   arg   1
             CALL    DosRead                ;   Invoke   syscall   ( SYSTEM )   function
             ADD     ESP , DWORD   *   4         ;   Remove   the   four   parameters   we   pushed
                                          ;     onto   the   stack   for   the   DosRead   call
             RET
    ReadBuffer      ENDP