1.
A game that used to be popular among computer hobbyists is core wars—a variation of battleship. (The term
core
originates from an early memory technology in which 0s and 1s
were represented as magnetic fields in little rings of magnetic material. The rings were
called cores.) The game is played between two opposing programs, each stored in different
locations of the same computer’s memory. The computer is assumed to alternate
between the two programs, executing an instruction from one followed by an instruction from the other. The goal of each program is to cause the other to malfunction by writing
extraneous data on top of it; however, neither program knows the location of the other.
a. Write a program in the machine language of Appendix C that approaches the game
in a defensive manner by being as small as possible.
b. Write a program in the language of Appendix
C that tries to avoid any attacks from the opposing program by moving to different locations. More precisely, beginning at location 00, write a program that will copy itself
to location 70 and then jump to location 70.
c. Extend the program in (b) to continue relocating to new memory locations. In particular, make your program move to location 70, then to E0 (5 70 1 70) then to 60 (5 70 1 70 1 70) etc.