A is a particle used before a noun to put it into the vocative case.
Duine is a masculine noun that means person.
Uasal is an adjective that means noble; also gentle.
Thus, a dhuine uasail: sir (literally, 'noble person'), addressed to the subject.
A dhuine uasail is used to formally address a man. The end of the word uasal is palatalised because the phrase is in the vocative case and is being addressed to a man.
The phrase a fhir uasail is equally valid as is a fhir mhaith (my good man).
The phrase to formally address a woman is a bhean uasal (madam; literally 'noble woman'). Note that ending of the word uasal is not palatalised when the greeting is directed toward a woman.
The plural form of a dhuine uasail is a dhaoine uaisle: gentlemen / sirs (literally, 'noble people'). In practice, this is often used to address groups of both men and women (therefore corresponding to ladies and gentlemen).
Other formal depersonalised greetings include:
These are better suited to everyday use. The following are only examples; there are plenty more.
Further study is strongly encouraged here. Not only is there a great deal of regional variation but the use of diminuatives and adjectival qualifications can cause profound changes to actual meanings; changes which will not be apparent to many learners and L2 speakers. There are enough subtleties to warrant caution.
For instance, a mhaicín, which is a diminuative form of a mhac, will generally carry one of two subtexts in South Connacht: contempt or affection. This inversion of meaning has nothing to do with irony; it simply depends on context. But unless all the participants in the conversation understand that context there is a danger of unintended offence being caused; or indeed of intended offence going straight over the head of the target!
This example is intended to remind the reader that human language involves much more than commonly-comprehended vocabularies and grammatical rules. Pragmatics are equally important.