The ESP has a series of pitch and yaw gyroscopes that determine, based on those inputs and inputs from the steering angle sensor and the wheel speed sensors, whether the car is going into a spin. In order to break out of the spin, it selectively brakes the necessary wheel to make the car pivot out of the spin.
ASR comes into play with ESP, but what ASR does primarily is prevent wheelspin by braking the spinning wheel and backing off the electronic throttle.
All ESP cars have ASR, but not all ASR cars ave ESP. If you have a button on the console marked ESP, you have ESP. If you have a button marked ASR, you have ASR and no ESP.