Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

the purpose of this line of assembly code

Status
Not open for further replies.

McMurry

Member level 3
Member level 3
Joined
Feb 16, 2008
Messages
56
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,746
i have come upon this line of code

;the main program goes here.....
;then before it ends... there's this line of code

LOOP GOTO LOOP

END


Can anyone explain the purpose of having that loop?
Thanks.
 

it is an infinite loop , mostly the controller is waiting for interupts.

it is added to make the program endless.
 

    McMurry

    Points: 2
    Helpful Answer Positive Rating
The First LOOP is defining a point, so the first LOOP is a location. The second statement says, GOTO LOOP, meaning goto the LOOP location. This code is what we call an infinite loop, and in assembly is the proper way to terminate code that only has to run once. Once you reach the end of the code, this is what happens:

LOOP
GOTO LOOP

We jump back to LOOP and continue executing, but the next statement is GOTO LOOP. We jump back to LOOP and continue executing, and so it goes on forever...

We do this because we don't know what's in memory above LOOP, and you could start to do random things ... the program would continue executing and incrementing through memory. This technique keeps the properties of the program known.
 

    McMurry

    Points: 2
    Helpful Answer Positive Rating
thanks for the explanation =)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top