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

  1. Program FirstInlineMacro;
  2. { This is a sample program that demonstrates the coding if an }
  3. { inline macro that will return the uppercase of a character. }
  4. { It simply compares the value of the character passed to the }
  5. { routine, and determines if it is in the range a to z.  If   }
  6. { so, it will subtract $20 from the value of the character    }
  7. { passed.  This has the effect of changing the character to   }
  8. { its uppercase representation.                               }
  9.  
  10. Var
  11.   S : String;            { Test string used in this example   }
  12.   I : Byte;              { Loop control variable              }
  13.  
  14. Function UpperCase( Ch : Char ) : Char;
  15. { This inline macro will convert the character passed as a    }
  16. { parameter to its upper case representation.                 }
  17.  
  18. Inline( $58/                  {  POP AX        }
  19.         $3D/$61/$00/          {  CMP AX,$0061  }
  20.         $7C/$08/              {  JL  08        }
  21.         $3D/$7A/$00/          {  CMP AX,$007A  }
  22.         $7F/$03/              {  JG  03        }
  23.         $2D/$20/$00 );        {  SUB AX,0020   }
  24.  
  25. Begin
  26.   S := '?@@this is a testz[\'; { Initialize string to boundary }
  27.                               { values.                       }
  28.   Writeln( 'Before translation S = ', S ); { Echo to screen   }
  29.   For I := 1 to Length( S ) Do{ Convert each character        }
  30.     S[I] := UpperCase( S[I] );
  31.   Writeln( 'After translation  S = ', S );{ Echo to screen    }
  32.   Readln;                     { Pause for viewing             }
  33. End.
  34.  
  35.