home *** CD-ROM | disk | FTP | other *** search
- Program TestOne;
- { This sample program illustrates calling a function that }
- { contains an inline function. It will simply add two byte }
- { sized parameters, and place the result into the temporary }
- { memory location that the Turbo Pascal code generator will }
- { allocate on the stack. This is illustrated by the last MOV }
- { instruction before the end of the function. }
-
- Var
- X, Y : Byte; { Variables that will be passed to function }
- Result : Word; { Result of the call to function AddBytes }
-
- Function AddBytes( X, Y : Byte ) : Word;
- { This function will simply transfer the two parameters passed }
- { into the AX and BX registers and add them. It will then }
- { place the result of the function into the memory locations }
- { That Turbo Pascal has allocated for the function result. }
- Begin
- Inline( $31/$C0/ { XOR AX,AX }
- $8B/$46/$04/ { MOV AX,[BP+04] }
- $8B/$5E/$06/ { MOV BX,[BP+06] }
- $01/$D8/ { ADD AX,BX }
- $89/$46/$FE ); { MOV [BP-02],AX }
- End;
-
- Begin
- X := 20; { First operand to be passed to the function }
- Y := 30; { Second operand to be passed to function }
- Result := AddBytes( X, Y ); { Call the function }
- WRiteln( Result ); { Echo result of function to the screen }
- Readln; { Pause till return is hit to view output }
- End.
-