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

  1. Program TestOne;
  2. { This sample program illustrates calling a function that      }
  3. { contains an inline function.  It will simply add two byte    }
  4. { sized parameters, and place the result into the temporary    }
  5. { memory location that the Turbo Pascal code generator  will   }
  6. { allocate on the stack.  This is illustrated by the last MOV  }
  7. { instruction before the end of the function.                  }
  8.  
  9. Var
  10.   X, Y : Byte;     { Variables that will be passed to function }
  11.   Result : Word;   { Result of the call to function AddBytes   }
  12.  
  13. Function AddBytes( X, Y : Byte ) : Word;
  14. { This function will simply transfer the two parameters passed }
  15. { into the AX and BX registers and add them.  It will then     }
  16. { place the result of the function into the memory locations   }
  17. { That Turbo Pascal has allocated for the function result.     }
  18. Begin
  19.   Inline( $31/$C0/                 { XOR AX,AX      }
  20.           $8B/$46/$04/             { MOV AX,[BP+04] }
  21.           $8B/$5E/$06/             { MOV BX,[BP+06] }
  22.           $01/$D8/                 { ADD AX,BX      }
  23.           $89/$46/$FE );           { MOV [BP-02],AX }
  24. End;
  25.  
  26. Begin
  27.   X := 20;         { First operand to be passed to the function }
  28.   Y := 30;         { Second operand to be passed to function    }
  29.   Result := AddBytes( X, Y ); { Call the function               }
  30.   WRiteln( Result ); { Echo result of function to the screen    }
  31.   Readln;          { Pause till return is hit to view output    }
  32. End.
  33.  
  34.