Morality is a consideration among the living about that which affects survival.
A rock can have no morality.
So that which exists among the living may be said to carry knowledge which assists in it's survival. At it's root, this knowledge is bicameral. Inherited knowledge is instinctual, non-volitional, part of homeostasis. Learned knowledge is empirical, fact based, gained in a learning curve by a theoretical and practical synthesis. These are two distinct intrinsic components of knowledge within any life form. I used the term bicameral because I could use less words with it. I got the idea from Dr. Julian Jaynes. This bicameral knowledge directs a life form to behave in a life enhancing manner.
Instinct is part of the firmware that comes inherited from the species at large to the individual of that species.
Humanity, (although it is in possession of some instinctual behavior) operates using decision trees on the basis of a few simple questions regarding existence and the metaphysically given:
"Is our condition here knowable"? If the answer arrived at is "yes", the following question is: "By what means"?
Sensory data interpreted by a rational perspective leads to a morality of rational self interest.
Whim interpreted by an irrational perspective leads to a morality that is anti- rational self interest.
Survival in the case of the Human being depends on a rational perspective which takes into account the sensory data as part of the metaphysically given. Failure to evaluate sensory data as such can only reduce the proximity of human paradigm to life enhancing outcomes via such encompassing life processes related to the adequate synthesis of sensory data about the metaphysically given.
Morality as it is related to survival may vary as it relates to the temperament involved in choosing a viable route to survival. Survival is markedly different from non-survival however, so any working practice of morality must have results that are absolutely quantifiable as survival if it is to be judged as effective to the living being employing the morality.
Attaining Virtues (character traits and competencies) cumulative to and corollary towards your life (it's survival) plus Values (Nouns) of the same caliber and quality yield a stance of morality.
A great book on the subject is " Introduction to Objectivist Epistemology" by Harry Binswanger and Leonard Peikoff. It contains extensive philosophical material by Ayn Rand.