correcty updated the flags and register stacks