Final answer:
The code of ethics that knights were supposed to uphold was known as chivalry, which encompassed ideals of protecting the weak and conducting oneself with honor, particularly in warfare, and was part of the broader feudal system and culture.
Step-by-step explanation:
The code of ethics that knights were supposed to uphold is known as chivalry. Chivalry was a code of ideal conduct that sought to Christianize knightly violence and behavior. The principles of chivalry expected knights to not loot monasteries, hold clergy for ransom, to protect the church, women, and the defenseless, observe publicly declared truces, and refrain from fighting on religiously significant days. Although an overarching system for Christianized warfare was not fully successful in curbing violence, it emerged within the broader context of a secular interest in a defined chivalric culture of knighthood and the valorizing legends and stories told by troubadours.
Fulfilling the ideals of chivalry was intended to go hand in hand with the feudal system, a hierarchical structure of land ownership and military service, but it often conflicted with the nobility's social role to engage in armed struggle. Feudalism, which rose from the ashes of the Carolingian world, was characterized by lords granting lands (fiefs) to vassals, who in turn pledged military service among other duties. The mutually supportive system of the time was built on these relationships bound by codes of honor and reciprocity, contrasting strongly with the written codes of Roman law.
Because the ideals of chivalry were so closely tied with feudal obligations and the system of nobility, they also helped shape the culture of courtly love and the traditions carried on by troubadours in royal and noble courts, adding to the romanticized image of knights and their conduct.