Assignment 7: A Complete Mic-1 Simulator

In this assignment you will complete the Mic-1 simulator from assignment 6.

The following are the input sequences you must handle:

InputWhat it doesCall when doneIf
s This executes one subcycle. update_display(ANI_DISPLAY_SLOW the display flag was ANI_DISPLAY_NONE
c Execute until the end of a cycle.
That is, execute at least one cycle and continue until you have completed subcycle 4.
update_display(ANI_DISPLAY_SLOW) the display flag was ANI_DISPLAY_NONE
i Execute until the end of an instruction.
That is, execute subcycles until the MPC becomes 1 at the end of subcycle 4.
update_display(ANI_DISPLAY_SLOW the display flag was ANI_DISPLAY_NONE
i n Execute until the end of n instructions.
That is, execute subcycles until the MPC becomes 1 at the end of subcycle 4 n times.
update_display(ANI_DISPLAY_SLOW) the display flag was ANI_DISPLAY_NONE
d off Set the display flag to ANI_DISPLAY_NONE
d fast Set the display flag to ANI_DISPLAY_FAST
d slow Set the display flag to ANI_DISPLAY_SLOW
u Call update_display(ANI_DISPLAY_FAST)

Every time you complete an instruction, update the number of instructions completed. Every time you complete a cycle, update the number of cycles completed.

When you exit the program after receiving and end-of-file, output to standard error all of the memory locations which are valid. Also display the 16 registers, the total number of instructions completed, and the total number of cycles completed.

Every time you read from memory, set the valid flag for that memory location to true. Execute ani_move_from_memory_to_mbr when the mbr is updated. This should not be done before the third subcycle of the second cycle of the read. If this read was because of an instruction fetch, also execute ani_set_memory_as_instruction. Every time you write to memory, set the valid flag for that memory location to true and execute ani_move_from_mbr_to_memory. Do not call either ani_move_value_from_memory_to_mbr or ani_move_value_from_mbr_to_memory.

You should not call update_display after each subcycle or cycle except as indicated above. Make sure you do not display any values bigger than 16 bits as the ALU can only produce 16-bit values. Every time the PC changes, call ani_set_memory_pc. Every time the SP changes, call ani_set_memory_sp. Also call these in update_display. Make sure you call ani_set_programmer_name once during your initialization.