In the space environment, a large number of cosmic rays often results in transient faults on on-board computers. And one of the main problems caused by these faults is the control flow errors in the program. This paper proposes a software-implemented control flow error detecting and correcting approach for the linear assembly named DCCLA. DCCLA firstly divides the program into loop blocks and non-loop blocks and assigns the formatted labels for the blocks. Then based on the mechanism of instructions counting, DCCLA inserts counting and comparing instructions into every block, with the purpose of detecting and correcting the control flow errors occurred inter-block and intra-block. In order to correct the data flow errors caused by the control flow errors, DCCLA backups the loop state and live variables. One advantage of DCCLA is that it can be configured flexibly according to the requirement of reliability and performance. The results of fault injection experiment shown that, the average fail rate of programs with DCCLA has decreased to 4.25% with the cost of increasing the average executing time by 41.7% and increasing the average program space by 46.7% DCCLA has the least influence on performance and space overhead and correspondingly higher reliability among three typical control flow detecting algorithms.