Retired Army Brig. Gen. S. L. A. Marshall, the military writer and historian who wrote more than 30 books, including the best-seller "Pork Chop Hill," died yesterday of cardiopulmonary arrest at Beaumont Army Medical Center in El Paso, Tex. He was 77.

Gen. Marshall had been hospitalized after suffering a stroke in June, 1976.

For 35 years, except for military service during World War II and the Korean conflict, Gen. Marshall was a foreign correspondent and military analyst for the Detroit News.

During the 1960s, he wrote a column on military affairs for the Los Angeles Times-Washington Post News Service.

As a lieutenant colonel assigned to the Pacific during World War II, he developed the technique of doing battlefield history by assemblying survivors soon after an encounter and interviewing the group about its operations.

He used this method later with American troops in Europe, Korea, and Vietnam, and with the Israeli army after the Sinai War of 1956.

"Pork Chop Hill," Gen. Marshall's best known book, was about the Korean war. It was published in 1956, then turned into a movie, starring Gregory Peck.

Born in Catskill, N.Y., Gen. Marshall grew up there and in California. He enlisted in the Army during World War I in 1917, fought in Belgium and France, and received a battlefield commission as a second lieutenant.

After the war, he attended the Texas College of Mines - now the University of Texas at El Paso, and joined the National Guard.

In 1922, he became a reporter for the El Paso Herald, and remained with the paper as its sports editor and city editor until joining the Detroit News in 1927.

During the 1930s, Gen. Marshall covered uprisings in Latin America and the Spanish Civil War. After World War II broke out in Europe in 1939, he wrote two books on the lightning German invasion of France, Belgium, and the Netherlands.

Again joining the Army in 1942, he was assigned as a consultant to Secretary of War Henry L. Stimson, became chief of orientation, and established the Army News Service.

In 1943, he helped found the Army's historical division and was sent to the Pacific. His first major assignment was writing an analysis of Gen. Jimmy Doolittle's bombing raid on tokyo. Later, he followed American troops through the Gilbert and Marshall Islands.

In 1944, Gen. Marshall was transferred to Europe and covered airborne operations over Germany as well as land operations. He was promoted to colonial and became chief historian for the European theater in early 1945.

He left the Army in 1946 to return to the Detroit News, but was recalled briefly to write a history of the Berlin airlift in 1948. He was promoted to brigadier general in 1951, and spent a year in Korea with the 8th Army as its operations analyst.

While there, he gathered material for "Pork Chop Hill" and for "The River and the Gauntlet," a highly praised book about the Chinese attack across the Chongchon River.

"Marshall specialized in the samll-unit type of action where he would talk to the people involved and elicit the details of what had happened," the Army's current chief of military history, Brig. Gen. James L. Collins Jr., said yesterday. "He was very good at putting it down in a vivid way, and made people read things that professional historians might make dry as dust."

In 1956, Gen. Marshall was given wide access to the Israeli army - from its generals to its enlisted men - after the Israeli sweep across the Sinai Peninsula. He praised the Israelis highly in his book, "Sinai Victory," and for many years afterward was strongly Pro-Israel in his speeches and writings.

He also wrote about military operations in Lebanon in 1958, and in the Congo in 1961.

During 1967 he was sent by the U.S. Army to record his observations on Vietnam, and later strongly defended the record there of American troops.

Later he said the withdrawal of U.S. forces from Vietnam was "an act that foretold ultimate ruin for the Vietnamese."

Yesterday friends described Gen. Marshall as a short, energetic, and somewhat cocky man with strong opinions.

"He was very opinionated," one friend said, "and he said what was on his mind, but he was always willing to argue with you . . . Some historians felt he was more of a journalist than a historian. He probably was the most popular historian the Army has had."

In addition to his books and columns, Gen. Marshall wrote dozens of technical studies and professional papers for military journals, and hundreds of book reviews and articles for magazines, including Saturday Review, Harper's, Life, Look, and the Saturday Evening Post.

He lectured widely at military colleges, not only for the U.S. Army, but also for the armies of Britain, Canada and Israel.

Because of his initials, Gen. Marshall was often called "Slam." His given names were Samuel Lyman Atwood. Forrest Pogue, a military historian and friend, said Gen. Marshall's best friends called him Sam.

In 1974, Gen. Marshall moved from Birmingham, Mich., a Detroit suburb where he had lived for many years, to El Paso.

He is survived by his wife, Cate, of the home there; three daughters, Sharon Hoagg, of Austin, Tex.; Cate Licari, of San Francisco, and Bridget Rhine, of Walkersville, Md.; a son, Sam L. Jr., of St. Louis; a brother, Charles B., of Arlington, Va.; a sister, Alice Willis, of El Paso; and five grandchildren.