The S&P 500 and Nasdaq rose slightly on Tuesday as deal news bolstered views that improved merger activity could signal economic strength. But the Dow edged lower after a downgrade of the tech sector.

Limiting gains was Morgan Stanley's downgrade of semiconductors, which weighed on the sector.

Trading was choppy, with indexes swinging between gains and losses.

The Dow Jones Transportation Average<.DJT> rose 5.3 percent as Warren Buffett's Berkshire Hathaway agreed to buy Burlington Northern Santa Fe Corp in a deal that values the railroad company at $34 billion. Burlington shares jumped 27.5 percent to $97.

Higher oil prices helped lift the S&P 500, with the S&P energy sector index <.GSPE> up 1.1 percent.

Technology stocks ranked among the major decliners after Morgan Stanley downgraded the sector to cautious from attractive, and cut its view on Dow component Intel Corp , saying inventories were beginning to creep up in the sector. The PHLX semiconductor index <.SOXX> lost 1.3 percent.

One of the themes we've been pointing toward is that the next catalyst after earnings is M&A activity, and we've had some big ones, said Tim Smalls, head of U.S. stock trading at brokerage firm Execution LLC in Greenwich, Connecticut. People consider companies to be cheap.

The Dow Jones industrial average <.DJI> slipped 17.53 points, or 0.18 percent, to end at 9,771.91. But the Standard & Poor's 500 Index <.SPX> added 2.53 points, or 0.24 percent, to finish at 1,045.41. The Nasdaq Composite Index <.IXIC> advanced 8.12 points, or 0.40 percent, to close at 2,057.32.

In other deal news, Black & Decker Corp shares jumped 31 percent to $62, a day after Stanley Works Inc said it struck a deal to buy the company. Stanley shares rose 10.1 percent to $49.69.

U.S. oil futures shot up $1.47, or 1.88 percent, to settle at $79.60 a barrel. ConocoPhillips' stock gained 1.5 percent to $50.75.

Shares of Intel slid 2.7 percent to $18.50 on Nasdaq.

Burlington shares surged 27.5percent to $97.

Shares of Black & Decker jumped 23.9 percent to $58.66, while shares of Stanley Works were up 4.8 percent at $47.30.

Data showed new orders received by U.S. factories rose more than expected in September but had little impact on the broader market.

(Reporting by Caroline Valetkevitch; Editing by Jan Paschal)