home *** CD-ROM | disk | FTP | other *** search
- Program VarParamTest;
- { This program is a demonstration of how Turbo Pascal will }
- { replace the occurrence of a pointer that is passed to a }
- { procedure with its address, the same way it will when passed }
- { a Var parameter. }
-
- Type
- WordPtr = ^Word;
-
- Var
- VarParam : Word;
- Ptr : WordPtr;
-
- Procedure IncPtrReferent( Target : WordPtr );
- { This procedure will increment the referent of the pointer }
- { that has been passed to the routine. }
- Begin
- Inline( $C4/$BE/Target/ { LES DI,[BP+offset] }
- $26/$FE/$05 ); { INC BYTE PTR ES:[DI] }
- End;
-
- Procedure IncVarParameter( Var Target : Word );
- { This is a procedure that will increment the var parameter }
- { that has been passed to this routine. }
- Begin
- Inline( $C4/$BE/Target/ { LES DI,[BP+offset] }
- $26/$FE/$05 ); { INC BYTE PTR ES:[DI] }
- End;
-
- Begin
- New( Ptr );
- VarParam := 12;
- Ptr^ := 12;
- Writeln( 'VarParam = ', VarParam );
- Writeln( 'Ptr^ = ', Ptr^ );
- IncPtrReferent( Ptr );
- IncVarParameter( VarParam );
- Writeln( 'VarParam = ', VarParam );
- Writeln( 'Ptr^ = ', Ptr^ );
- Readln;
- End.
-