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

  1. Program AccessVarParam;
  2. { This is an example program that demonstrates how to access a  }
  3. { var parameter from a inline code.  It involves using the LES  }
  4. { operator to Load into the Extra Segment the segment address   }
  5. { of the address passed for the var parameter, and then request }
  6. { the offset be placed into the DI register.  We can then use   }
  7. { this as a pointer to where the parameter is actually stored.  }
  8. { After all, that is what we receive - a pointer.               }
  9.  
  10. Var
  11.   Result : Word;     { This is the variable that will be passed }
  12.                      { as a Var parameter to the procedure.     }
  13.   IncValue : Byte;   { Value we will add to the var parameter   }
  14.  
  15. Procedure AddValue( Var X : Word; Y : Byte );
  16. { This inline procedure will accept a Var parameter, and then   }
  17. { add to it the second parameter that has been passed to this   }
  18. { procedure.  It serves no other purpose other than to show how }
  19. { to access a Var parameter.                                    }
  20. Begin
  21.   Inline( $8B/$46/$04/         { MOV  AX,[BP+04] }
  22.           $C4/$7E/$06/         { LES  DI,[BP+06] }
  23.           $26/$01/$05 );       { ADD  ES:[DI],AX }
  24. End;
  25.  
  26. Begin
  27.   Result := 10;      { Initialize the var parameter to 10       }
  28.   IncValue := 40;    { Set the value to increment the Var param }
  29.   AddValue( Result, IncValue );
  30.   Writeln( Result ); { Echo results to the screen               }
  31.   Readln;            { Pause for screen viewing                 }
  32. End.
  33.  
  34.