A conditional jump can help you break an infinite loop.?
- 2 months ago
return OR exit
- brilliant_movesLv 72 months ago
A conditional jump can help you break what would otherwise be an infinite loop.
- rogerLv 72 months ago
You could do that. A better way would be to use a break statement or return from the function that the loop is in.
goto statements are not good practice.
- JohnLv 42 months ago
You explain very little.
One) are you trying to write something?
two) what's it for?
three) don't you think if you ask professionals professional questions you should offer cash in exchange for advice?
four) if not well obviously yes!
- What do you think of the answers? You can sign in to give your opinion on the answer.
- oldprofLv 72 months ago
Of course; but you must ensure that the "condition" will be met during one of the loops.
- PearlLv 72 months ago
it might do that
- SnezzyLv 72 months ago
If you have written an infinite loop, such as "while true", then without any code to cause an exit it will run until some external event stops it.
If your loop contains code to exit on some condition, then if it is possible to reach that condition, the loop will exit.
On the original design of the PDP-1 computer it was possible, so I have heard, to establish a indirect memory reference instruction that never completed. To quote from the PDP-1 reference manual:
"A memory reference instruction which is to use an indirect address will have a ONE in Bit 5 of the instruction word. The original address, Y, of the instruction will not be used to locate the operand, jump location, etc., of the instruction, as is the normal case. Instead, it is used to locate a memory register whose contents in Bits 6 through 17 will be used as the address of the original instruc· tion. Thus, Y is not the location of the operand but the location of the location of the operand. If the memory register containing the indirect address also has a ONE in Bit 5, the indirect addressing procedure is repeated and a third address is located. There is no limit to the number of times this process can be repeated."
The result of that design is that an instruction such as "JMP indirect here" puts the machine into working on fetching the effective address of the "here" address continuously. Because the STOP switch on the front panel halts the machine at the end of an instruction, the only way to stop that malignant program is to shut off the electrical power.
This is more information than you ever could have wanted, and it STILL is an insufficient answer to your question!
- EddieJLv 72 months ago
If there is a conditional jump that can break you out of the loop, then it's NOT really an infinite loop to begin with.
You could say it's in an infinite loop if bad data causes the jump condition to never be true. The operating system may allow you to break out by hitting a key combination.
- RichardLv 72 months ago
Of course, and that should be a fundamental procedure in a program loop - otherwise it could not execute the rest of the program.