// Die größte bzw. kleinste von drei Integer-Zahlen wird bestimmt.

// Getestet mit D4 unter XP
function Max3(I1, I2, I3: Integer): Integer; 
asm 
  CMP EAX, EDX 
  JGE @EINS 
  CMP EDX, ECX 
  JGE @DREI 
  JMP @ZWEI 
 @EINS: 
  CMP EAX, ECX 
  JGE @FERTIG 
 @ZWEI: 
  XCHG EAX, ECX 
  JMP @FERTIG 
 @DREI: 
  XCHG EAX, EDX 
 @FERTIG: 
end; 
 
function Min3(I1, I2, I3: Integer): Integer; 
asm 
  CMP EAX, EDX 
  JL  @EINS 
  CMP EDX, ECX 
  JL  @DREI 
  JMP @ZWEI 
 @EINS: 
  CMP EAX, ECX 
  JL  @FERTIG 
 @ZWEI: 
  XCHG EAX, ECX 
  JMP @FERTIG 
 @DREI: 
  XCHG EAX, EDX 
 @FERTIG: 
end; 
 
 
// Beispielaufruf 
 
procedure TForm1.Button2Click(Sender: TObject); 
begin 
  showmessage(inttostr(Min3(Max3(1, 2, 3), 7, 10)));  // 3 
end;



Zugriffe seit 6.9.2001 auf Delphi-Ecke