Only two rules appear to govern the behavior of U.S. military personnel in the field in El Salvador: Don't give advice and don't get shot.

U.S. military men cannot give combat advice because doing so would violate the War Powers resolution barring them from "involvement" in hostilities, U.S. officials say. They cannot go anywhere that seems physically dangerous because of the desire to avoid U.S. casualties.

But U.S. military men can travel anywhere in the country within those limits, and the second limit in particular seems to be flexible. It is all right to visit an area where there is fighting "on the periphery" as long as enough Salvadoran troops are on hand to beat back any left-wing guerrilla attacks, according to U.S. Ambassador Thomas Pickering.

"I can't give you a 100 percent rule," Pickering said. "These are judgmental issues."

Officially, the U.S. Embassy insists that the rules are the same as they have been since 1981. In practice, however, U.S. military personnel have been seen more frequently with senior Salvadoran officers in the field near actual combat this year.

Questions on this subject arose Friday after three U.S. military personnel spent Thursday night at a Salvadoran field command post in the heart of rebel-dominated territory in northeastern El Salvador on the first night of a Salvadoran Army offensive there. Journalists on hand asked whether the three had violated the rules barring U.S. military personnel from placing themselves "in situations where combat is likely."

Pickering and the State Department strongly defended the men's action, however. "Areas of likely combat are not static concepts. It depends on what's happening; who is in control," Pickering said.

One of the three military men present put it more succinctly. "I guess the true test of whether you're in combat is whether you're in combat," said the official, who spoke on the condition that he remain anonymous.

It appeared to be a judgment call whether the three were "in combat" at the command post in Perquin. They were no more than 1,000 yards away from a clash between troops and guerrillas on Thursday afternoon. While they were there on Friday morning, a mine on the edge of town exploded and wounded a Salvadoran soldier.

On the other hand, the three Americans reported that they did not come under direct fire during their 17-hour visit. And this journalist, who also spent that night in Perquin, felt fairly safe apart from worries that the guerrillas had left behind booby-traps.

The three U.S. military men were a Marine lieutenant colonel who is the U.S. naval attache to El Salvador, chief of U.S. military trainers Col. James Steele and a sergeant who is Steele's chief aide. They said they had traveled to Perquin at the invitation of the Salvadoran commander in charge of the operation, Lt. Col. Domingo Monterrosa, who assured them that they would not be involved in combat.

The presence of Steele and his aide was more surprising than that of the naval attache, because members of the defense attache's office travel much more freely and widely in El Salvador than do military trainers. There are at least five U.S. military attaches and assistant attaches whose principal task is to gather information rather than train troops, and they are in the field regularly. A spokesman for the U.S. Embassy declined to say precisely how many military attaches it has. Steele, who heads a contingent of 55 trainers in the field plus about 16 working in the embassy, theoretically must justify his trips to the field on grounds that he is gathering information on how training is progressing.

Pickering said, however, that he has ordered the attaches to follow approximately the same guidelines regarding personal safety as those applicable to the trainers. In practice, therefore, no U.S. military personnel are to go out in the field with Salvadoran patrols seeking combat, U.S. officials said. But they can accompany senior Salvadoran officers to command posts even if those posts are close to the scene of a battle.

U.S. military personnel were barred from carrying automatic rifles in the field until the summer of 1983, when the rules were quietly changed following the killing of Navy Lt. Cmdr. Albert A. Schaufelberger by guerrillas in San Salvador in May of that year. They are now permitted to carry short-barreled automatic rifles, as the three were carrying in Perquin, but not full-barrel M16s.

"After an objective like Perquin has been secured by a large and effective unit -- even if there happens to be firing on the periphery -- it is not in our judgment an area of likely combat," Pickering said. About 400 troops of the elite, U.S.-trained Atlacatl Battalion had fanned out south of Perquin shortly before the U.S. military personnel arrived Thursday, and they met little resistance from guerrillas.

U.S. officials said that U.S. military men gradually are traveling more widely around El Salvador as the Salvadoran Army's fighting capacity improves and makes it safer. In addition, Steele reportedly prefers to spend more time in the field than did his predecessor, Col. Joseph Stringham, who left in June. There was no sign that any of the three U.S. personnel gave advice to Monterrosa during their stay in Perquin.