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

  1. Program HiLoWordDemo;
  2. { This is a very simply example of the power of an Inline     }
  3. { Macro.  All that the two routines will do is return the Low }
  4. { and High words of the long integer value parameter that was }
  5. { passed.                                                     }
  6. Var
  7.   L : LongInt;        { Variable to be passed to the function }
  8.   W : Word;           { Variable for function result          }
  9.  
  10. Function HiWord( L : LongInt ) : Word;
  11. { THis function will return the high word of the longint      }
  12. { varible that was passed.                                    }
  13. Inline( $5B/          {  POP BX  }
  14.         $58 );        {  POP AX  }
  15.  
  16. Function LoWord( L : LongInt ) : Word;
  17. { This function will return the low word of the longint value }
  18. { that was passed to this function.                           }
  19. Inline( $58/          {  POP AX  }
  20.         $5B );        {  POP BX  }
  21.  
  22. Begin
  23.   WRiteln( 'HiWord = ', HiWord( $FFFF0000 ) );
  24.                       { Call the routine with a value         }
  25.   Writeln( 'LoWord = ', LoWord( $FFFF0000 ) );
  26.                       { Call the routine with a value         }
  27.   L := $0000FFFF;
  28.   W := HiWord( L );   { Call the function with a variable     }
  29.   Writeln( 'HiWord = ', W );{ Echo result to screen           }
  30.   L := $0000FFFF;
  31.   W := LoWord( L );   { Call the function with a variable     }
  32.   Writeln( 'LoWord = ', W );{ Echo results to the screen      }
  33.   Readln;             { Pause for screen viewing              }
  34. End.
  35.  
  36.