The Dow and S&P rose on Tuesday as stronger-than-expected earnings at BP Plc lifted energy shares, but weak U.S. consumer confidence data weighed on stocks.

The Nasdaq fell, pressured by disappointing results at Chinese Internet company Baidu.com .

BP said third-quarter earnings were helped by costs cuts. Its stock rose 5.5 percent to $58.54 on the New York Stock Exchange.

Among other energy companies, Dow components Exxon Mobil Corp was up 2.3 percent to $74.92 and Chevron Corp added 2 percent to $76.95.

There is definitely a gathering bullishness around energy at large, which is helping support things, said Matt Kaufler, portfolio manager and equity analyst at Clover Capital Management in Rochester, New York.

If you believe the worst of the contraction is behind us, you're going to see oil prices continuing to rise.

December crude futures were up 0.9 percent to $79.35 per barrel.

The Conference Board's index of consumer confidence fell to 47.7 in October, weaker than economists had forecast. The data showed consumers were increasingly concerned about job market conditions.

This number is clearly negative, said Kevin Caron, market strategist at Stifel Nicolaus in Florham Park, New Jersey. It suggests that at best, we're in an uneven recovery.

The Dow Jones industrial average <.DJI> added 56.98 points, or 0.59 percent, to 9,925.85. The Standard & Poor's 500 Index <.SPX> rose 2.04 points, or 0.19 percent, to 1,068.87. The Nasdaq Composite Index <.IXIC> lost 10.16 points, or 0.47 percent, to 2,131.68.

The S&P consumer discretionary sector <.GSPD> was the biggest percentage loser among S&P sectors, down 1.2 percent.

Baidu's U.S.-listed shares sank 11 percent to $384.74. The Chinese Internet search giant reported quarterly revenue that missed expectations and said fourth-quarter sales would miss expectations by more than 10 percent.

The steel sector retreated after several companies, gave gloomy outlooks for the industry and economy.

United States Steel Corp sank 6.8 percent to $37.82 while AK Steel Holdings shed 7.1 percent. The Dow Jones U.S. Steel index <.DJUSST> fell 3.6 percent.

Other data showed home prices rose for the fourth-straight month in August, sending the Dow Jones Home Construction index <.DJUSHB> up 1.1 percent.

The Standard & Poor's/Case-Shiller composite index of home prices in 20 metropolitan areas rose more than expected in August.

(Editing by Kenneth Barry)