This is my code below.
1) How do I implement a simple looping program?
2) How do I implement a program that wins against the relocate.txt program in a 100 battle scenario with 5000 iterations (should be close to 100 wins out of 100 battles)?
3. Please explain the design that you are using for the code. What tactics did you implement to win against the relocate program?
Relocate.txt:
; Simple relocate program
COPY #-9, Loc ; Offset from Loc to start of relocate program
COPY #50, NewLoc ; Offset from NewLoc to relocate program
Loop:
COPY @Loc, @NewLoc ; Move an instruction
ADD #1, Loc ; Increment pointer to next instruction
ADD #1, NewLoc ; Increment pointer to next location to move it to
JUMPZ Done, Loc ; If Loc is zero, we are done
JUMP Loop ; Otherwise, move to the next instruction
Done:
COPY #50, NewLoc ; Reset the beginning of the relocated program
JUMP @NewLoc ; And jump to it
Loc:
DATA 0 ; Pointer to program to move
NewLoc:
DATA 0 ; Pointer to location to move to