Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TASM 2.x / MASM 6.x Assembly Language - <b>proc initiate procedure definition directive</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
PROC             Initiate Procedure Definition                      Directive

  name PROC [distance] [USES registers,] [arg [RETURNS arg [,arg]...]

  TASM Ideal mode:
  PROC name [distance] [USES registers,] [arg [RETURNS arg [,arg]...]

     PROC starts the definition of a procedure. The quickest version is
     simply like this:

              MY_PROC    PROC
                      :

     The procedure definition follows, ending with a return instruction,
     RET, and an ENDP directive (see the separate entries under RET and
     ENDP). A distance is associated with the procedure, since the
     assembler has to encode the one- or two-word return address. If you
     do not specify a distance, the default is NEAR. You can indicate
     NEAR or FAR as in the following example:

              MY_PROC    PROC    FAR
                      :

     Note: You need at least MASM 5.1 or TASM 1.0 to use any of the
     following features.

     If you specify a memory model with the .MODEL directive, the default
     distance for procedures is set by the memory model used.

     In addition, you can have the assembler push the registers the
     procedure uses automatically, and restore them at the end with the
     USES keyword. Specify the registers you want to preserve like
     this (notice that there are no commas between them):

              MY_PROC    PROC    FAR USES AX BX
                      :

     The assembler adds the code for the necessary pushes and pops at the
     beginning and end of the code.

     You can set up a stack frame with PROC by specifying the arguments
     that the procedure is called with (from a high level language).
     Before you do, the assembler must know what calling convention to
     use; you must specify a high level language name when you use the
     .MODEL directive (see .MODEL). After the calling convention has been
     set, you can add argument names to the PROC definition. For example:

              MY_PROC    PROC    FAR USES AX BX, ARG1:BYTE, ARG2:WORD
                      :

     You can now refer to the arguments ARG1 and ARG2 in your
     assembly language source code, and the assembler will substitute the
     correct [BP+n] reference to take these arguments off the stack.

     The optional RETURNS keyword indicates which (if any) arguments
     should not be popped from the stack when the procedure returns. For
     example, you must define a Pascal string return value by placing it
     after the RETURNS keyword.

See Also: ARG ENDP

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson