## Redcode 94

Edit 2: This is another way to do it. `SPL 0` splits to two threads, where the first one continues and the second one spawns at the same instruction, thus creating infinite amounts of threads, while executing the code following it. When a thread hits `DAT`, it is killed. The famous dwarf:

            org    start
    start   spl    0           ; Split infinitely
            add.ab #4   ,   2  ; Add 4 to the B-field of the dat
            mov.i  1    ,   @1 ; Copy the dat to the location pointed by it's B-field
            dat    #0   ,   #0
            end

----

All this is because of [Ilmari Karonen's self terminating program](https://codegolf.stackexchange.com/a/16606/20356). So, in Redcode looping always requires some kind of jumping. Because of that, I decided to create a program which copies itself completely, and jumps to the start of the new program after that, thus replicating itself infinitely.

Edit: The old version was convoluted.

    ; Set some constants
    length equ 8              ; The program is 8 instructions long
    step   equ length         ; When step equals the length, the program copies itself after one empty space
    jump   equ (step+start+1) ; This points to the start location of the copy
    
            org    start
    ptr     dat    #1        ,    #0
    targ    dat    #1        ,    #0
    leaf1   mov.ab #step     ,    targ  ; Reset the target
    leaf2   mov.i  >ptr      ,    >targ ; Copy *ptr++ -> *targ++
            slt    #length   ,    ptr   ; Jump back if ptr < length
            jmp    leaf2
            jmp    jump                 ; When done, jump to the start of the new program.
    start   ; The loopable code can be placed here
            ; ...all the way until
            jmp leaf1
            end

So, if this code is run, the execution starts from the label `start` (big surprise). The leaf subprogram does the copying. That subprogram can handle any size of a program, as long as it's the first part of it. I'll show you what the program looks like in the memory (hand compiled for brevity):

    Iteration 1
    0000    dat    #1        ,    #0
    0001    dat    #1        ,    #0
    0002    mov.ab #8        ,    -1
    0003    mov.i  >-3       ,    >-2
    0004    slt    #8        ,    -4
    0005    jmp    -2
    0006    jmp    10
    0007    jmp    -5  (execution starts here)
    
    Iteration 2
    0000    dat    #1        ,    #0
    0001    dat    #1        ,    #0
    0002    mov.ab #8        ,    -1
    0003    mov.i  >-3       ,    >-2
    0004    slt    #8        ,    -4
    0005    jmp    -2
    0006    jmp    10
    0007    jmp    -5  (execution starts here)
    0008    <empty>
    0009    dat    #1        ,    #0
    0010    dat    #1        ,    #0
    0011    mov.ab #8        ,    -1
    0012    mov.i  >-3       ,    >-2
    0013    slt    #8        ,    -4
    0014    jmp    -2
    0015    jmp    10
    0016    jmp    -5  (execution continues here)