More often than not, infinite loops are created by programming errors and are quickly dealt with. In sympathy for this highly persecuted group of programs, a safe haven has been created on
retro code. The two infinite loops below are highly optimized examples. In fact, the actual loops are only 1 byte long!
Z80 Infinite Loop ld hl, HERE
HERE:jp (hl)
8080 Infinite Loop lxi h, HERE
HERE:pchl
Corewar Infinite Loop jmp #0, <-5
In
Corewar, the infinite loop finds its niche destroying small mobile programs called imps!
If you know any infinite loops in need of shelter, please post them in the comments below.
while(1);
ReplyDeletelabel: goto label;
ReplyDeletefor(;;);
ReplyDeletejmp $
ReplyDeleteThe 8080 & Z80 infinite loops are one instruction long but not one byte long. The 8080 JMP instruction is three bytes long. The Z80 added relative jumps which decreased local jumps to two bytes. I believe some processors (6502 maybe?) had a one-byte HLT instruction which was implemented as a jump to current location.
ReplyDeletemain = main
ReplyDelete(let loop ()
ReplyDelete(loop))
@fgb: the Z80 code looks like 4 bytes, 3 bytes setup code and 1 byte for the actual loop.
ReplyDelete(Y (lambda (loop) (loop)))
ReplyDeleteEB FE <-- x86 machine code for "jmp $"
ReplyDeleteBefunge:
ReplyDelete>v
^<
label: push word label
ReplyDeleteretn
asm{
ReplyDeletestart: nop;
jmp start;
}
while True: pass
ReplyDeleteBrainf***:
ReplyDelete+[]
Underload:
(:^):^
M68K assembly, 1 instruction, 2 bytes:
ReplyDeletebra.b *
MIPS:
ReplyDeletelabel: add $0, $0, $0 #add can be anything
j label
c beginners samples on Beginners Lab Assignments Code Examples
ReplyDeleteSteve Wozniak thinks that education technology of the future will be game-alike, but even as it is today, technology is changing the face of the old analog school. Can computers really be tutors? Programming Help
ReplyDeleteSome of them are a good light in the dark, some are rather misleading. And while many people may argue whether creating software is an art, a science, or a precisely elaborated process, we'd leave that choice to someone else. It cannot be described sparsely. best books for project manager
ReplyDelete