A stable algorithm for computing subresultants