The S&P 500 and the Nasdaq Composite ended higher Friday after a rebound in oil prices boosted energy shares and a chip maker's forecast-beating results revived semiconductor stocks.

But the Dow ended barely changed, dented by shares of International Business Machines Corp. (IBM), whose outlook fell short of some investors' forecasts, and General Electric Co. (GE), which reported poor performance by its plastics business.

Click here to visit FOXBusiness.com's Investing Center.

The Dow Jones industrial average dipped 2.40 points, or 0.02 percent, to end at 12,565.53. The Standard & Poor's 500 Index advanced 4.13 points, or 0.29 percent, to finish at 1,430.50. The Nasdaq Composite Index gained 8.10 points, or 0.33 percent, to close at 2,451.31.

Almost offsetting the drag of IBM and GE were advances by Exxon Mobil Corp. (XOM), with oil up more than $1, and Alcoa Inc. (AA) after the aluminum maker unveiled a share buyback at midday. Exxon Mobil and Alcoa were the Dow's top two gainers, which helped the blue-chip average claw most of its way back from a session low.

"We're finally getting some cold weather here in the Midwest and that's helping energy," said Kevin Kruszenski, head of listed trading at KeyBanc Capital Markets in Cleveland. "And things like Exxon and Alcoa are helping to erase IBM."

For the week, the Dow gained 0.08 percent, while the S&P 500 inched down 0.02 percent and the Nasdaq fell 2.06 percent.

The 3 percent gain in crude oil prices helped both energy producers and related shares. Crude for February delivery rose $1.51 to settle at $51.99 a barrel on the New York Mercantile Exchange, which rallied in sync with heating oil and natural gas futures amid much colder weather in key heating fuel markets.

Exxon Mobil's stock gained 2.2 percent, or $1.57, to $73.53, making it the top positive influence on both the S&P 500 and the Dow. Shares of oil services firm Schlumberger Ltd. shot up 5.4 percent, or $3.10, to $61 and were the second-biggest positive influence on the S&P 500.

IBM delivered better profits, but its earnings failed to beat some forecasts, sending its stock down 3.3 percent, or $3.28, to $96.17, its biggest daily drop in nearly two years.

Alcoa shares jumped 3.6 percent, or $1.10, to close at $31.40 on the New York Stock Exchange.

Xilinx, a programmable microchip maker, posted earnings that beat analysts' forecasts and helped the battered chip maker industry stage a comeback following an earnings warning from Advanced Micro Devices Inc. (AMD) and a flat gross margin outlook from Intel (INTC) Corp.

Xilinx shares rose 4 percent, or 91 cents, to $23.88 on Nasdaq. Shares of chip maker Broadcom Corp. rose 2.1 percent, or 63 cents, to $30.18, also in Nasdaq trading.

Motorola Inc. shares gained 3 percent, or 56 cents, to $19.27, reversing an earlier decline to a session low at $18.59. The world's second-largest mobile phone maker posted a drop in quarterly profits, but executives announced plans to cut jobs and vowed to return to double-digit operating margins in the year's second half.

Trading was moderate on the NYSE, with about 1.64 billion shares changing hands, below last year's estimated daily average of 1.84 billion, while on Nasdaq, about 2.08 billion shares traded, above last year's daily average of 2.02 billion.

Advancing stocks outnumbered declining ones by a ratio of nearly 7 to 3 on the NYSE and by more than 3 to 2 on Nasdaq.

Click here to visit FOXBusiness.com's Investing Center.