Press enter to see results or esc to cancel.

Comparing Identifiers

This function case insensitive compares two identifiers and returns false if they are not equal. Otherwise returns true and Id2 points to byte after its end. This function must be as fast as possible! It is called whenever Turbo Pascal needs to compare two identifiers.

Function IdentifiersEqual (Id1: PString; Var Id2: PString): Boolean;
begin
  IdentifiersEqual := False;
  Asm
    PUSH   DS
    LES    DI, Id2
    LDS    SI, ES:[DI]
    LES    DI, Id1
    LODSB
    SCASB
    JNE    @1
    MOV    CL, AL
    XOR    CH, CH
@2:
    LODSB
    XOR    AL, ES:[DI]
    INC    DI
    AND    AL, $DF
    LOOPZ  @2
    JNZ    @1
    INC    @Result
    LES    DI, Id2
    MOV    ES:[DI], SI
    MOV    ES:[DI + 2], DS
@1: POP    DS
  end;
end;