Assignment 3: Almost ready for the MIC-1 Simulator

All programs in this assignment should output a line giving your name before doing anything else. All output from this assignment goes to standard error.

The following files are in a compressed tar file.

   assign3.h
   control_store
   errout
   makefile
   memory
   mic1.h
   micani.h
   micani.o
   runmic
   testassign3
   testassign3.input
   Xdefaults
Milestone 1:

Make a new directory for this assginment. Copy assign23.c into assign31.c and get all of the files above. Modify assign31.c so that it includes assign3.h instead of assign2.h. Make sure the program compiles and runs correctly.

Remove the calls to show_memory and show_control_store. After reading in the files, have the main program go into a loop which reads character strings from standard input until an end of file occurs. Use fgets to read in the string. This returns the constant EOF when an end-of-file is reached. After reading each string, the main program should call a function called handle_input which is passed the input string and takes the appropriate action. For this part of the assignment, the routine handle_input should just display string: followed by the string that was passed to it all on one line.

Milestone 2:

Copy assign31.c to assign32.c and modify handle_input so that it takes the following action:

string description action
starts with i followed by a space print the string after the space
just the letter i print the word instruction
just the letter c print the word cycle
none of the above print the words invalid input

Use strcmp and strncmp. Use global variables to keep track of the number of times the input was c and the number of times it was i. When the program exits, output the count of each.

Milestone 3:

This part does not get turned in, put you will need it for assignment 4. You must run this from the windowing environment on one of ringer's clients.

Copy assign32.c to mic1.c. Modify mic1.c so that it includes mic1.h and micani.h instead of assign3.h. After the files have been read in call initialize_animator before calling handle_input. Run the program using the runmic script. Directions will be displayed telling where to click the mouse. Try it. You may need to click on quit after you exit your program. Now every time you execute the c command, call the function ani_set_cycle_count_value with the count as the first argument and 1 as the second argument. In a similar way, each time the i instruction is executed, call ani_set_instruction_count_value. Try it and observe what happens. Report this on the front page of what you hand in.