Declaring "national security" his top priority, Gen. Chon Doo Hwan formally resigned from the South Korean military today in preparation for his ascendency to the country's presidency next week.

The four-star general ended 29 years of military life with a review of troops at a divisional command post near this village, about three miles from the demilitarized zone separating South Korea from communist North Korea.

In a brief speech to the 1st Infantry Division he once commanded, Gen. Chon said that while he firmly believed social justice must come one day, "national security should be our country's top priority" now.

Chon declared that "corruption and irregularities" had to be uprooted from the country, adding, "I have chosen the way of difficult justice rather than easy justice."

His remarks apparently referred to the massive purge of political enemies and allegedly corrupt politicians that has already marked his leadership of the tough-minded military regime that has run the country since May 17.

He has shut down parliament, banned political activity and arrested scores of dissidents advocating democratic reforms. The trial of Kim Dae Jung, the main opposition leader, is now under way and the press is already preparing the public for a harsh sentence, possibly death.

The 49-year-old general is to be named president next Wednesday, and he resigned his title today because the constitution forbids a military officer from becoming president.

The ceremony on a divisional parade ground north of Seoul had some of the trappings of Chon's politics. Large placards on a hillside facing Chon's reviewing stand spelled out a version of his regime's slogan: "New History. New Wave. New Determination."

An obscure major general when president Park Chung Hee was assassinated last October, Chon has steadily pressed forward to the leadership left vacant by Park's death. He helped lead a generals' coup within the military on Dec. 12. Then, on May 17, he directed the sweeping crackdown on hundreds of dissidents and placed the country under total martial law.

In the process, he collected two more stars and left the military today as one of its highest ranking generals.Chon also has benefited from a massive publicity buildup in the press his Army command closely censors and is using to depict him as a man of heroic proportions.

For two weeks, news stories have portrayed him as the strong leader South Korea needs to end the period of confusion and drift that followed Park's death. Stories today extolled Chon as a simple man of the people, a devoted family man and a military leader revered by the men who served under him.

Organizations of generals, businessmen, politicians and other segments of society have climbed on the bandwagon with resolutions endorsing him for the presidency in recent days.

Chon already has taken steps to assure continued control within the military after he assumes office. His close friend Gen. Ro Tae Woo, who assisted him in the coup last December, was named yesterday head of the defense security command, a position with vast surveillance powers. Chon held that post at the time of the coup and used it to monitor both civilian and military affairs.

The ceremony here today was attended by businessmen, several political leaders, and many of his classmates from the 1955 graduation at the Korea Military Academy, none of whom rank higher than major general.

Chon first came to national attention when he was commander of the 1st Infantry Division, part of the 3rd Army which defends the western front against possible invasion by North Korean armies.

He won a high national award for participating in the discovery in his sector of a tunnel dug under the demilitarized zone by North Korean forces. However, he was still largely unknown at the time of Park's assassination when he began his rise to power by arresting another general, Chung Sung Hwa, for possible complicity in the assassination.

Today, under a hot sun, Chon toured in front of the ranks in the rear of a jeep and then watched as his old division paraded past the reviewing stand. It was followed by a 19-gun salute and the playing of "Auld Lang Syne."

He said he was retiring from the military to devote his life to creating a "new history and new order, recognizing the fact that the nation is facing a turning point that has to pursue constructive and positive changes."

He called for a new Korean-style democracy, saying "we should plant democracy suitable to our historical background and current circumstances."