## ALP Programming Guide and Reference

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

### Attributes

The optional fields in the Attributes argument control how the procedure is defined.

Syntax

    [ Distance ]   [ Language ]   [ Visibility ]

Remarks

The various Attribute fields are defined as follows:

Distance Determines the type of CALL instruction that should be used to invoke the procedure, and the type of RET instruction generated by the assembler. The default is NEAR if no .MODEL directive has been specified, or if the model has been set to TINY, SMALL, COMPACT, or FLAT. The default is FAR if the model has been set to LARGE, MEDIUM, or HUGE. If the programmer is using segments with mixed address sizes (USE16 and USE32) on a 32-bit processor, then the NEAR16, FAR16, NEAR32, and FAR32 keywords may also be used.

Language Determines the calling convention used by the procedure, and the naming convention used when writing the procedure name to the object file. The calling convention defines the layout of the stack frame upon entry to the procedure and how the stack frame is destroyed upon procedure exit. See the section on LabelName s for more information on language naming conventions.

With the BASIC, FORTRAN, and PASCAL calling conventions, the called procedure expects arguments to be pushed on the stack from left to right, causing the rightmost parameter to be at the lowest stack address and closest in proximity to the frame pointer (the BP or EBP register). With this arrangement, the called procedure always knows the exact amount of stack space used by the parameters, and is responsible for removing them from the stack with a RET Constant instruction when the procedure exits. Such procedures are unable to accept a variable number of arguments.

With the C, STDCALL, SYSCALL, and OPTLINK calling conventions, the called procedure expects arguments to be pushed on the stack from right to left, causing the leftmost parameter to be at the lowest stack address and closest in proximity to the frame pointer (the BP or EBP register). With this arrangement, the calling procedure is free to push additional arguments on the stack, and is responsible for restoring the stack after the called procedure returns (STDCALL requires the called procedure to restore the stack if a fixed number of arguments is being passed).

With the OPTLINK 32-bit calling convention (as defined by the IBM VisualAge C/C++ Compiler environment), up to three parameters will be passed in machine registers to the called procedure, provided they not larger than a DWORD in size. The EAX, EDX, and ECX registers (respectively) are used for this purpose. Stack space for the parameters is still allocated, but the parameter values are not actually copied onto the stack. Refer to the documentation for the IBM VisualAge C++ compiler for more information on the OPTLINK calling convention.

Visibility Determines if the procedure name is written to the object file as a global identifier, allowing it to be referenced by other modules. The allowable values are PRIVATE, PUBLIC, and EXPORT. If operating in M510 mode and no .MODEL directive with a Language-Name has been specified, then the default visibility is PRIVATE. In all other situations, the default visibility is PUBLIC unless the default has been overridden by an OPTION LANGUAGE directive.

When the PRIVATE keyword is used, the procedure name is visible only within the defining module at assembly-time. When the visibility is PUBLIC, the procedure name is made visible to other modules at link-time. The same is true of EXPORT visibility, but in this case the assembler emits a special record into the object file that causes the linker to also make the symbol visible as an exported entry point in the executable module , allowing it be called by other modules at program run-time.