Identifiers In Assembler Instructions

This function checks if identifier in instruction is valid and returns its data. Identifier can be a local lable starting with the @ sign or any other declared Turbo Pascal identifier.
Function IsValidAsmIdentifier (P: Pointer; Var Tok: TToken; Var IdentifierData: Pointer; Var IdentifierPointer: Word): Boolean;
Var RecordTypeDefinition: PRecordTypeDefinition absolute P;
    VariableIdentifierData: PVariableIdentifierData absolute IdentifierData;
    NewIdentifier: PIdentifier;
begin
  If CurrentIdentifier [1] = '@' then
    begin
      If IsIdentifierInSymbolTable (@SpecialAsmIdentifiers, Tok, IdentifierData, IdentifierPointer) then
        IsValidAsmIdentifier := True else
          If IsIdentifierInSymbolTable (Ptr (SymbolTable [stMain].Segment, TemporaryAssemblerStatementIdentifierTable),
                                 Tok, IdentifierData, IdentifierPointer) then
            IsValidAsmIdentifier := True else
              begin
                IdentifierData := StoreCurrentIdentifierToSymbolTable (Ptr (SymbolTable [stMain].Segment,
                                    TemporaryAssemblerStatementIdentifierTable), 2, NewIdentifier);
                NewIdentifier^.Token := Token_LabelIdentifier;
                IdentifierPointer := Ofs (NewIdentifier^);
                Tok := Token_LabelIdentifier;
                IsValidAsmIdentifier := True;
              end;
      Exit;
    end;
  If P = nil then IsValidAsmIdentifier := FindCurrentIdentifier (Tok, IdentifierPointer, IdentifierData) else
    If Ofs (P^) = 0 then
      begin
        If FindIdentifierInUnit (P, Tok, IdentifierPointer, IdentifierData) then IsValidAsmIdentifier := True else
          IsValidAsmIdentifier := FindCurrentIdentifier (Tok, IdentifierPointer, IdentifierData);
      end else
        begin
          If IsCurrentIdentifierDeclaredAsMemberInRecordOrObject (RecordTypeDefinition,
                                                                  VariableIdentifierData,
                                                                  Tok,
                                                                  IdentifierPointer) then
            IsValidAsmIdentifier := True else
              IsValidAsmIdentifier := FindCurrentIdentifier (Tok, IdentifierPointer, IdentifierData);
        end;
end;
 
 
 
© 2017 Turbo Pascal | Privacy Policy