When a parameter is passed by reference (the
default method), PowerBASIC passes a 32-bit
SUB MyProc(xyz&) ' This will increment the
' parameter variable by one
! PUSH EBX
! MOV EBX, xyz&
! INC DWORD PTR [EBX]
! POP EBX
END SUB
Parameters passed by copy (such as expressions
or constants) also take precisely 4 bytes on the stack. In this
case, just as in parameters by reference, the item on the stack is not
the value of the parameter. Rather, it is the address of a temporary
location in memory where the value is stored. This may seem roundabout,
but it has two distinct advantages. First, assembler routines can
handle parameters
Suppose the first and only parameter is a Long-integer. In that case, you can put the integer value into the ECX register by writing:
SUB MySub(xyz&)
! PUSH EBX
! MOV EBX, xyz& ; EBX is a pointer to xyz&
! MOV ECX, [EBX] ; ECX now contains xyz&
' ...more code would go in here
! POP EBX
END SUB
In these cases, you must use the correct and complete address to access the value. But regardless of whether the parameter represents a variable, an expression, or a literal constant, or whether it was passed by reference or by copy, the routine will always work correctly.
See Also