It was dinner time. A teen-age soldier, an AK47 strapped awkwardly over his shoulder, hungrily eyed some mangoes hanging from a tree above his guard post. Suddenly, he picked up a stick, tossed it at the tree and whacked loose a mango. Dinner was served.

The mango meal, eaten last week near the rear entrance of the heavily guarded Speke Hotel in downtown Kampala, is an apt symbol of how Uganda has been able to feed itself even as two generations of hungry young men with AK47s have ripped much of this verdant East African nation apart. Most of the public works -- roads, schools, hospitals, water systems -- that in the 1960s made Uganda one of Africa's most livable countries have been wrecked by more than 15 years of violence.

In the current civil war, rebels of the National Resistance Army have seized and sealed off access to the southwest third of the country. The rebel-held territory is by far the richest, most fertile part of Uganda. Yet, like the soldier with the stick, the rest of Uganda has had little trouble finding dinner.

"If this violence had happened in Tanzania or Kenya or just about any other place in Africa, there would have been mass starvation," said David Mulira, acting director of the East African Development Bank. "Because we have food, we don't realize how bad off we are."

Kampala's downtown market is a paradigm of plenty amid the accumulated ruins of Uganda's civil war. On Kampala Road, on a hill above the market, tall grass and rank garbage occupy the remains of shops demolished by the artillery of the Tanzanian invasion forces that in 1979 forced Idi Amin into exile.

On surrounding hills, all perpetually green and lush in the highland sun, there are a half dozen or so abandoned construction sites. A huge, modern construction crane has stood idle for nearly a decade above the proposed site of Uganda's social security building. The site is a large hole in the center of Kampala, slowly filling with trash.

Blackened, boarded-up shops, victims of last July's coup, border the market. Army soldiers, after toppling the government of president Milton Obote, looted most of Kampala. They were celebrating, Uganda-style, the fruits of power.

Yet inside the city market this month stalls were bursting with an abundance and variety of food that exists in few African capitals. Passion fruit, eggplant, dates, beefsteak, ground nuts, oranges, papaws, lemons, yams, pork, pineapples, dried grasshoppers, mashed groundnuts and scores of other fruits, vegetables and meats. There were hundreds of bunches of green matoke (a kind of banana), the staple of the Ugandan diet. The market was perfumed with curry powder and cinnamon and the aroma of smoked Nile perch. The giant fish are caught in nearby Lake Victoria, which can be seen from the hills of Kampala.

The Uganda Commercial Bank, in a recent report on agriculture, said that "rich soils and a mild equatorial climate have continued to make Uganda a place where virtually anything can grow luxuriantly . . . . Uganda remains one of the few African states that are self-sufficient in food." It rains nearly every month here, and in one year farmers can often harvest three crops from the same field.

The country has almost no storage for grain or vegetables. But agricultural specialists say this is not a problem. There is always more food ripening in the fields.

Perhaps the best measure of Uganda's irrepressible fertility is what it has survived. As Amin's public safety squads killing Acholi tribesmen the mid-1970s, and as Obote's army was killing Baganda men, women and children in the Luwero Triangle north of Kampala in the early 1980s, the government here all but ignored agriculture. The infrastructure that supported Uganda's farm-based economy fell to pieces.

In the late 1960s, modern water supply facilities served about 70 percent of the rural population and almost everyone living in towns and cities, according to the World Bank. Now, the Bank says only 7 percent of the people in rural areas and 40 percent of those in urban areas have safe drinking water. Visitors to Kampala, according to a publication called "What's Around in Uganda," are advised to "take only boiled water."

There is an array of such before-and-after statistics. In a country that once boasted the best teaching hospital and medical care in East Africa, spending on health care is estimated at $1.70 per person a year, the lowest in East and Central Africa. In a country whose construction industry once was an African model, less than 1 percent of the gross national product is spent on building, the lowest portion in East Africa.

In the past month, the people of Uganda have had reason to believe that the tribally inspired, state-led violence that has crippled their country was coming to an end. A peace agreement, signed in Nairobi on Dec. 17, was supposed to create a coalition government in which the generals who seized power in July would share power with the rebels who hold the south. But rebel leader Yoweri Museveni, thus far, has refused to implement the peace agreement he signed. In government-held parts of Uganda, violence continues.

Earlier this month, this city was crowded with ill-disciplined men in uniform. They raced through town on the wrong side of the road in big military trucks, forcing cars onto sidewalks and into ditches. Uniformed gunmen shot and killed the chauffeur of the country's minister of internal affairs. A Roman Catholic bishop said that, since the peace agreement was signed, men in uniform have stepped up their looting and raping in Mpigi, a suburb of Kampala.

Despite all this, Uganda not only fed itself in 1985, it exported food, as it has every year since its independence in 1962. If the fighting were to stop and a stable government were to assume power, economists and development specialists here say Uganda has a greater potential for economic recovery than any nation on the continent except South Africa. They agree that the same resources -- good land and lots of rain -- that have kept Ugandans from hunger during the years of violence could make the country boom after a few years of peace.

"Within five to ten years, this country could be back to what it was in the 1960s, a solidly based, rural economy without any of the food constraints of other African countries," said Christopher Logan, a British-paid economist who advises Uganda's Ministry of Finance.

Logan estimated it would take about five years for earnings from exports of coffee, tea, maize, fish and cobalt to pay off the country's foreign debt. Service on that debt now eats up about 70 percent of export earnings, Logan said. If the peace accord is implemented and the rebel-held southwest is opened up, Logan says recent sharp increases in the price of coffee (which accounts for 93 percent of export earnings) could cut the debt burden this year to an onerous but manageable 35 percent of earnings.

To supplement its own resources, there are tens of millions of dollars of foreign aid pledged to Uganda. The United Nations Development Program has committed more than $50 million for the next four years. The World Bank plans to spend $70 to $100 million a year. The United States has appropriated $8 million. All the money, however, is on hold, waiting for the peace agreement and for Uganda to become safe enough for aid officials to travel inside the country.

While builders and shopkeepers, bankers and peasants wait to see if soldiers will implement the peace agreement, the value of the Ugandan shilling is collapsing. Officially, it was 600 to the dollar before the July coup; it is now about 1,300 to the dollar. On the black market here, one dollar will buy 5,000 shillings. The cost of food at Kampala's central market increases weekly. Of course, for those who have the money, there is plenty of food to buy.