Writing register state to memfile when the snapshot(...) function is called.