# Assemble the program. t1.Addi.o: t1.Addi.dlx dlxasm dlxasm -o t1.Addi.o < t1.Addi.dlx # Run the test t1.Addi: t1.Addi.o t1.Addi.out dlxcpu dlxcpu -b -d -p -a -m 8192 t1.Addi.o > t1.Addi.tmp diff t1.Addi.tmp t1.Addi.out rm t1.Addi.tmp # Rebuild dlxasm or dlxcpu, if necessary dlxasm:... dlxcpu:...This simple makefile tests the assembler and cpu simulator to ensure that they still produce the expected output. This is useful after modifying either program to ensure that new bugs have not been introduced.
The test is executed with the command make t1.Addi. Make then determines that in order to complete the commands for that target, it must have two files: t1.Addi.o and t1.Addi.out, in addition to dlxcpu. t1.Addi.out is created by the person making the test suite and contains the expected output. t1.Addi.o is an object file containing an assembled program used in the test. Since t1.Addi.o is a derived object, make will determine that it matches the target in the first rule and will use that rule to create it if it does not already exist or if any of its dependencies (t1.Addi.dlx) have changed since it was created.
Since dlxasm is listed as a dependency, any modification to the assembler will also cause t1.Addi.o to be rebuilt before running the test. If the assembler has not been modified and t1.Addi.o still exists from a previous test, it will not be recreated. This feature can save lots of time!
Assuming that t1.Addi.o did not exist, make will create it by calling dlxasm. It will then call dlxcpu with the newly assembled program to produce the output from the current version of dlxcpu. As the last step, the current output is compared with the expected output in t1.Addi.out.
Copyright 1996 by Byron Weber Becker