Implementing State Machine for Mode 9