Assignment 2: Getting more 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.

   assign2.h
   control_store
   errout
   makefile
   memory
   testassign2
Milestone 1:

Copy assign12.c to assign21.c and modify it so that if a . is given as a command line argument the default will be used. Answer the following on the cover sheet of your assignment:
Symbols other than a . could have been used here. What would happen if instead of a . the assignment asked you to use a *? Milestone 2:

Copy assign21.c to assign22.c and modify it so that it reads in the memory file. Write a function:

   int initialize_memory(char *fn, memory_t *memp, int max)
This function will open the file named fn and read in values until an end of file occurs or more than max values have been read. Values will fill the appropriate array in the structure pointed to by memp. Only max elements of the array should be accessed. The function returns -1 if there was an error opening the file, -2 if too many values were read in, and the number of values successfully read in otherwise. You may assume that the file being read in consists of numbers stored as hexadecimal character strings without the leading 0x. The file assign2.h contains a typedef for memory\_t. Fields will be added to this structure as needed. The file memory contains a sample input file. Write a program:
   void show_memory(memory_t *memp, int size)
which displays size values of the memory in hexadeximal and decimal, one pair per line in right-justifed columns.

Your main program should read in the memory file. If an error occurs, an appropriate error message should be displayed and the program should exit. Otherwise it should call show\_memory to display the memory.

Milestone 3:

Copy assign22.c to assign23.c and modify it so that it also reads in the control store file. Write functions:

   int initialize_control_store(char *fn, control_store_t *csp, int max)
   void show_control_store(control_store_t *csp, int size)
which behave like the functions from Milestone 2. The file control\_store is a sample input file for this.