next up previous
Next: Class Assignments Up: A Microprogramming Animation Previous: Overview of the

Animation Interface

The XTANGO animation package is a powerful tool for showing the dynamic behavior of a program. A simplified interface to XTANGO is provided by the animator which was written by John Stasko of Georgia Tech [7] specifically for use by undergraduates doing computer animation. This program simply reads ASCII text, one command per line. Since the animator 's input comes from standard input, a C program can send commands to it with simple printf statements. The simulator might be run by the following command:

        mic1 control.store assembly.prog | animator

The simulator executable is called mic1. The control store is contained in the file control.store. The contents of the main memory are held in the file assembly.prog. The standard output of the simulator is redirected to standard input of the animator through the pipeline |.

The animator allows for drawing text, lines, rectangles, triangles, and circles in various colors. For example, the following animator command would create a rectangle on the screen:

        rectangle 1234 0.3 0.2 0.4 0.5 blue outline

Positions and distances in the default animator display are referenced with rectangular coordinates in the range from 0.0 to 1.0. The above command creates a rectangle whose lower left corner has coordinates (0.3, 0.2) and whose width and height are 0.4 and 0.5 respectively. The outline of the rectangle is displayed in blue. The rectangle can be referenced by its ID, 1234. The animator provides commands to move objects smoothly from one location to another making animation relatively painless. For example, the animator command:

        moveto 1234 0.4 0.7

moves the rectangle with ID 1234 so that its lower left corner now has with coordinates (0.4, 0.7).

The animator interface has been successfully used in our upper division Analysis of Algorithms course, but it is too complicated for the lower division Computer Organization students given the complexity of the display to be produced. We solved this problem by writing an initialize_animator routine which draws and labels all of the boxes and lines in the diagram. The sample animator display from the first version of the Mic-1 simulator shown in Figure 2 corresponds to the drawing from the Tanenbaum book shown in Figure 1. Color is automatically used on a color display. Approximately 40 additional routines are provided to fill values in the various boxes and to move values from one place to another. These library routines hide the details of the animation from the students. A sample of some of these library routines is shown in Table 1. Their functions should be evident from their names with a small amount of explanation. For example, the routine:

        ani_move_value_from_reg_to_alatch(value,reg);

takes the given value, highlights it in the given register, smoothly moves it to and then along the A bus to the A latch, and changes the value displayed in the A latch.

  
Figure 2: The animator display for the first version of the simulator.

`_=11

  
Table 1: Some of the routines used to modify the animator display.

The students are shown a very simple Mic-1 simulator for demonstration purposes so that they can see what is expected of them. The sample simulation allows for single stepping through the Mic-1 subcycles, dynamically showing the execution of the Mic-1 machine. For example, on the second Mic-1 subcycle, data in one of the registers is highlighted, moved from the register to the A bus and down the A bus into the A latch. Data in another register is highlighted and moved to the B bus and down into the B latch. The entire program (excluding the animator library) can be implemented in about 300 lines of code.

Figure 2 shows the animator output. The snapshot of the display was taken in the middle of executing the second subcycle of the first Mic-1 instruction which executes the Mac-1 POP instruction. The details of this execution are described in the appendix. The simulator displays the decoded MIR by calling a routine from the animation library package for each field of the MIR. For example:

        ani_set_mir_A_value(6);

displays +1 in the A field of the MIR, since the animator library knows that register 6 of the Mic-1 contains the constant +1. The instruction POP is shown in the decoded IR box of the display with the command:

        ani_set_decoded_ir(registers[IR]);

The animator library knows about the Mac-1 assembly language and can disassemble its instructions. The display in the decoded MIR box can be set with:

        ani_set_decoded_mir(control_store[MPC]);

In subcycle 2, the routines:

        ani_move_value_from_reg_to_alatch(registers[MIR.Areg],MIR.Areg);
        ani_move_value_from_reg_to_blatch(registers[MIR.Breg],MIR.Breg);

are used. The first of these highlights the value in register 6, which is 0001 and shows it moving to the A bus, down the A bus, and into the A latch. The A latch is then filled with that value. The snapshot of Figure 2 was captured just as this value was to enter the A latch.



next up previous
Next: Class Assignments Up: A Microprogramming Animation Previous: Overview of the



Steven Robbins
Mon May 22 19:41:14 CDT 1995