Odd of an abecedarian of machine process designing advocate the characteristic of function

Be in a few sheet piece when machine abecedarian solves a problem, I discovered a phenomenon, because the effect of C programming is studied on computer,the likelihood is, a lot of people can draw up similar such program:

[Cpp] View Plain Copy#includevoid Main()

{

P1=0x00;

}

Odd of an abecedarian of machine process designing advocate the characteristic of function

Or such program

[Cpp] View Plain Copy#include

Int Main()

{

P1=0xab;

Return 0;

}

If be,move on computer similar such program, the program carries out an end, control advantageous position gives system, have return of value return a system, it is completely feasible, but in sheet piece on machine different, what rely on an operating system to notting comply is odd an engine order, main function is an operating system, should be to cannot be stopped those who move, and should be dead loop of a While(1) .

Without the program that adds While(1) executive end can appear unpredictable result (specific the position that should point to according to finger of assembly language PC judges) , namely the program runs fly.

Although be used actually when STC is odd an opportunity loop executive program (executive end is odd a machine restoration, all variable replacement) , but this is in chip manual and did not give out the government explains, so not certain always can such.

Odd the program carries out a machine stop, can reduce reliability greatly so. Just think your sheet piece machine controlling a large machine, if produce unpredictable result, consequence is very serious; If your watch is odd a machine, how does the program stop carry to guild? Stopped to show; If the operating system of computer moves,stop (close machine except) , also can appear problem.

So odd the program of a machine is a dead loop necessarily, general metropolis has While(1) , do not need to have return of value additionally, form if below two kinds of circumstances.

[Cpp] View Plain Copy#include

Void Main()

{

P1=0x00;

While(1) ;

}

[Cpp] View Plain Copy#include

Void Main()

{

While(1) {

P1=0x00;

}

}

Add a Comment

Your email address will not be published. Required fields are marked *