\chapter{The CAL Tool {\rm newogg} Versus {\rm oggin}} The purpose of both {\rm oggin} and {\rm newogg} is to allow the operation of instructions to be examined step by step. {\rm oggin}, developed on VAX and UNIX, is a simplified assembler and interpreter, while {\rm newogg}, developed on UNIX, is a complex interpreter demonstration program. Obviously, there must be some difference between them though both start running from address 0. The existence of the dissimilarity lies in three aspects: \section{Structure} The {\rm oggin} is composed of two parts, an assembler and an interpreter. Instructions from the source file are assembled and loaded into {\rm oggin}'s `memory'. If there are no errors during assembly then control is passed to the interpreter, which executes the instruction stored in {\rm oggin}'s memory and prints out the state of the main components of the machine after each instruction has been executed. All the instructions stored in {\rm oggin}'s memory are executed in one breath, and the output as well. \\ \\ {\rm newogg} consists of an interpreter only, which decodes and executes instructions from the source file; displays the state of the main components of cpu, memory and other information concerned on screen after an instruction has been executed. {\rm newogg} needs to get a character from the user through the terminal before the next instruction is executed. The period of time between each instruction cycle depends on the time it takes for the user to press a key, and the output is displayed one by one. \section{Input Data} {\rm oggin} interprets a program that it has just assembled. The input data is {\rm oggin} assembly language which will be assembled by the assembler part of {\rm oggin}. \\ \\ {\rm newogg} interprets a program that has been assembled elsewhere. The input data is octal values each of six digits, one value per line. \section{Error Messages} Usually, error messages are generated during the assembly-time or run-time. The assembly-time errors are when you try to assemble something like : \\ {\it stb,d,100} istead of {\it sta,d,100}. \\ It is an error made by the person typing in the program. It is a syntactical error. \\ \\ Run-time errors are when the program consists of correct opcodes and has been assembled correctly, but what the program actually does is wrong, for instance, jumping to the same instruction or dividing by zero. This is a logical error. An interpreter can never recognise run-time errors. The responsibility of looking after run-time errors in a program rests with the person writing that program, not the thing trying to execute or interpret it. \\ \\ \noindent{\rm oggin} is generous in giving error messages while {\rm newogg} is stingy in displaying error messages because {\rm oggin} has an assembler that generates assembly-time error messages and {\rm newogg} is only an interpreter. \\ \\ \noindent The input data for {\rm oggin} is supposed to be raw data which will be screened by the assembler first; it is necessary to prepare more possible error messages for the potential errors on the input data. \\ \\ {\rm newogg} is an interpreter, to which the input data is supposed to have been screened by the assembler already. Furthermore, it is a demonstration program, no error is expected at all. ({\rm newogg} run-time errors are discussed in section 7.3.) Subsequently, error messages are almost unnecessary, save when the accessed location of memory is out of range; when a constant in the input data is larger than 16 bits, outside the range -32768 to 32767; or when the {\rm newogg} program has gone out of control and cannot find a selection for a `case' statement to switch. This final error should never occur as all the {\it case} statements are completely fulfilled and will never select the default. \section{Benefits of Output} {\rm oggin} is designed for the purpose of informing the user of the state of the processor through examining the one-line output after each instruction cycle. The one-line output contains messages of the address of current instruction being executed, the five registers of the cpu, and the address of next instruction. As introduced in chapter 2, the one-line output looks like: \\ pc=000000 inst=000000 acc=000000 sp=000000 index=000000 CNZV=0000 pc$<$-000000 \\ and the output file is composed by lines of such one-line messages. \\ \\ The user wants to trace the operation of instructions, it always takes time and effort to match the output lines with instructions in the source file. It is not easy to locate the exact output line, but it is easy to lose the located one with the need to trace again. \\ \\ Memory dumps of {\rm oggin} are useful for checking the results of data manipulation exercise. However, it also needs some time and effort to find the location required, and it is not a pleasant experience to examine data in the output like a honeycomb. Additionally, the memory dump is a copy of final result of memory. Contents of some locations which were changing during the program run cannot be seen. \\ \\ Compared with that of {\rm oggin}, the output of {\rm newogg} is more informative, interesting and impressive. \subsection{Informative} >From chapter 5, we have seen the output of {\rm newogg} is comprehensive. Besides the one-line output, like that of {\rm oggin}, {\rm newogg} displays the binary code of the current instruction being executed, which can be used to match the octal code held in the instruction register or displayed at the right under the explanation part. It supplies an exercise for the user to convert binary to octal, and vice versa. \\ \\ Additionally, the octal code can be used to match with the current instruction, highlighted amongst the three assembly codes. The associated information displayed at the same time certainly can save time and effort to match the output line with the instruction. \\ \\ Comments for each instructions are particularly useful for examining and understanding the operation of each instruction, especially comments for the arithmetic and logical operations. Binary values of old acc, the source and the operation result are helpful for the user to visualise the actual change in the components concerned. \\ \\ Each time, forty locations of memory are displayed, and the accessed location is highlighted. The beginning of each line shows the location address of memory, so the user can easily locate the contents required. Moreover, the last line of the explanation part tells the user which location is accessed. Together with the comment, it is very clear and quick for the user to check the results of data manipulation exercises. \subsection{Interesting} The program is run partly under the control of the user, who would be more concentrated and pleased because of the feeling (sense) of participation. Besides that, the next instruction has appeared on screen, so the user can guess or expect the next output, which seems to be challenging and exciting. The appearance of each output, especially the highlighted positions, is always different, so the user will not feel bored easily. \subsection{Impressive} Outputs of {\rm newogg} are just like a series of pictures. It is said that a picture tells more than a thousand words. Furthermore, locations are highlighted when significant changes occur or special attention is required, which will result in an impact to the user. With changes of the registers and contents of memory shown on the screen immediately after each instruction cycle, the user seems to be able to visualise a bare machine working. Consequently, what the user has watched on the screen will be deeply impressed on their mind. \section{Conclusion} Besides the interpreter, {\rm oggin} consists of an assembler, which makes the acceptance of {\rm oggin} assembly language possible. It would be more practical and general to read in mnemonic assembly language than octal codes since most people will be happier to write mnemonic assembly. The output of {\rm oggin} can be printed and kept for as long a time as one likes for slow examining from the beginning to the end. \\ \\ Outputs of {\rm newogg} cannot be printed except using a screen printer since it is supposed to be a demonstration program. If the user needs the output of the previous instruction, they have to start the program again and pay particular attention to the output, or prints the output by a screen printer. If the user needs a complete output, they could run {\rm oggin} and print the results of components of the cpu. \\ \\ Despite the unusual input format of data and the inconvenience in printing the output, there can be no doubt in my mind that the CAL tool is more effective and impressive for examining the operation of instructions step by step, compared with {\rm oggin}.