Lawyer Mary Cox said she was so outraged by the slayings of 18 black protesters in South Africa Thursday that she shut down her Richmond office yesterday and drove to Washington to add her voice to the Free South Africa protest -- now in its 18th week -- outside the South African embassy in Northwest.

"This day meant canceling everything because something has to be done," Cox said, as she marched with a sign emblazoned with the words: Stop Legalized Murder. "That massacre . . . I don't think there are any words in the English language to describe it. I wonder, how long can this go on."

Yesterday, Cox was one of 28 persons, including members of Americans for Democratic Action from all over the country and members of the United Methodist Church, who were arrested in front of the embassy.

The protest, that has become almost a matter of routine, grew emotional yesterday as the demonstrators denounced the slayings by police in South Africa of protesters going to the funeral of a black activist Thursday -- the 25th anniversary of the slaying of 69 protesters at Sharpeville, in South Africa.

"What can we say of a country where blacks are murdered for claiming to be citizens . . . in which people wishing to attend a funeral service become victims of the next round of police violence?" said Ann F. Lewis, ADA national director, who spoke at the protest and was arrested minutes later.

The 28 were charged with demonstrating within 500 feet of the embassy, a misdemeanor that the U.S. attorney has refused to prosecute. They were taken into custody after they tried to see the ambassador and, after being turned away from the door, walked to the sidewalk, linked arms in the rain and sang "We Shall Overcome."

Meanwhile, Randall Robinson, national coordinator of the Free South Africa movement who was speaking elsewhere, lashed out with an uncharacteristic display of emotion and called President Reagan a "racist" for remarks Reagan made at a press conference Thursday.

"I've tried to speak with honesty and restraint," Robinson told an audience of educators at the D.C. Convention Center, "but I say to you this morning . . . from the bottom of my heart, the perception is that at the bottom of [Reagan's] heart is an unbridled and clear racist."

Asked about the slayings at a press conference, Reagan said, "There is an element in South Africa that does not want a peaceful settlement of this, who want a violent settlement, who want trouble in the streets . . . . "

Robinson said in his speech that "to suggest that these people can be responsible for the massacre of themselves is tantamount to the vilest racism."

Robinson also called on the D.C. educators to "stand up for what is right . . . set an example for the students."