GNU Info

Info Node: (nasm.info)Section 4.9.1

(nasm.info)Section 4.9.1


Next: Section 4.9.2 Prev: Section 4.9 Up: Section 4.9
Enter node , (file) or (file)node

4.9.1. `%arg' Directive
-----------------------

   The `%arg' directive is used to simplify the handling of parameters
passed on the stack. Stack based parameter passing is used by many high
level languages, including C, C++ and Pascal.

   While NASM comes with macros which attempt to duplicate this
functionality (see *Note Section 7.4.5::), the syntax is not
particularly convenient to use and is not TASM compatible. Here is an
example which shows the use of `%arg' without any external macros:

     some_function:
     
         %push     mycontext        ; save the current context
         %stacksize large           ; tell NASM to use bp
         %arg      i:word, j_ptr:word
     
             mov     ax,[i]
             mov     bx,[j_ptr]
             add     ax,[bx]
             ret
     
         %pop                       ; restore original context

   This is similar to the procedure defined in *Note Section 7.4.5::
and adds the value in i to the value pointed to by j_ptr and returns
the sum in the ax register. See *Note Section 4.7.1:: for an
explanation of `push' and `pop' and the use of context stacks.


automatically generated by info2www version 1.2.2.9