home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST0508.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-31  |  1.2 KB  |  43 lines

  1. Program VarParamTest;
  2. { This program is a demonstration of how Turbo Pascal will     }
  3. { replace the occurrence of a pointer that is passed to a      }
  4. { procedure with its address, the same way it will when passed }
  5. { a Var parameter.                                             }
  6.  
  7. Type
  8.   WordPtr = ^Word;
  9.  
  10. Var
  11.   VarParam : Word;
  12.   Ptr : WordPtr;
  13.  
  14. Procedure IncPtrReferent( Target : WordPtr );
  15. { This procedure will increment the referent of the pointer    }
  16. { that has been passed to the routine.                         }
  17. Begin
  18.   Inline( $C4/$BE/Target/        { LES  DI,[BP+offset]   }
  19.           $26/$FE/$05 );            { INC  BYTE PTR ES:[DI] }
  20. End;
  21.  
  22. Procedure IncVarParameter( Var Target : Word );
  23. { This is a procedure that will increment the var parameter     }
  24. { that has been passed to this routine.                         }
  25. Begin
  26.   Inline( $C4/$BE/Target/        { LES  DI,[BP+offset]   }
  27.           $26/$FE/$05 );            { INC  BYTE PTR ES:[DI] }
  28. End;
  29.  
  30. Begin
  31.   New( Ptr );
  32.   VarParam := 12;
  33.   Ptr^ := 12;
  34.   Writeln( 'VarParam = ', VarParam );
  35.   Writeln( 'Ptr^     = ', Ptr^ );
  36.   IncPtrReferent( Ptr );
  37.   IncVarParameter( VarParam );
  38.   Writeln( 'VarParam = ', VarParam );
  39.   Writeln( 'Ptr^     = ', Ptr^ );
  40.   Readln;
  41. End.
  42.  
  43.