New York - US stocks ended with modest gains on Monday as investors digested recent market gains and looked ahead to new Federal Reserve Chair Janet Yellen's first testimony before lawmakers.

The Nasdaq was boosted by strength in large-cap tech and pharma names, but most market participants took a wait-and-see attitude ahead of the testimony, looking for confirmation that the Fed would not change its schedule for ending its support for the economy.

The US central bank's accommodative monetary policies have been credited with fuelling the market's steep gains in 2013, and are expected to keep a floor under equity prices for as long as they continue.

The Fed first announced a slowing in the bond-buying programme in December, followed by another one in January. If it changes the pace of tapering - and uncertainty in emerging markets and the weak January payrolls have raised the odds of that to some - it may raise concerns that the economy is still not strong enough to strengthen on its own.

“We're hoping to hear Yellen strike a balance where she recognises that the recovery is fragile, but not so much that the Fed changes its mind, which would be too premature of a signal to send,” said Leo Grohowski, chief investment officer at BNY Mellon Wealth Management in New York.

Yellen's prepared remarks will be available before the market opens on Tuesday. She will also participate in a question-and-answer session with US lawmakers after the open.

The Dow Jones industrial average was up 7.71 points, or 0.05 percent, at 15,801.79. The Standard & Poor's 500 Index was up 2.82 points, or 0.16 percent, at 1,799.84. The Nasdaq Composite Index was up 22.31 points, or 0.54 percent, at 4,148.17.

The S&P 500 is coming off its best two-day performance in four months, which capped the index's first weekly gain in the past four. Those gains were preceded by the index's sharpest pullback in months.

“Last week investors received a wake-up call that 2014 is unlikely to be like 2013 in terms of the return or the smoothness of the ride,” said Grohowski, who helps oversee $185 billion in client assets. “We're still digesting last week's volatility, but investor sentiment is now neutral or negative, which is a positive for markets.”

McDonald's reported a decline in US January same-store sales, though global sales were above expectations. Shares fell 1.1 percent to $94.86.

Alexion Pharmaceuticals was the top boost to the Nasdaq 100, jumping 4 percent to $170.11 after Deutsche Bank raised its price target to $205 from $125.

Hasbro was the S&P's top percentage gainer, rising 4.5 percent to $52.36. The toymaker reported quarterly results and gave an upbeat outlook.

With about 69 percent of the S&P 500 having reported, 67.8 percent have topped profit expectations, above the long-term average of 63 percent, according to Thomson Reuters data. Almost 66 percent have topped revenue forecasts, above the historical average of 61 percent.

After the market closed, voice technology company Nuance Communications fell 2.3 percent after reporting its first-quarter results.

CNA Financial said it would sell its life and group insurance business, while parent Loews reported a bigger quarterly loss, hurt by impairment charges. CNA gained 6.9 percent to $42.42 while Loews lost 4.2 percent to $43.26 as the worst performer on the S&P 500.

Yelp advanced 1.9 percent to $91.11. The Wall Street Journal reported on Saturday that Internet portal Yahoo was partnering with the consumer-reviews website to beef up local results in its search engine. Yahoo rose 1.4 percent to $37.76.

Apple Inc rose 1.8 percent to $528.99 after Carl Icahn said in a letter to shareholders he sees no reason to persist with his proposal that the iPhone maker buy back $50 billion of its shares.

AutoNavi Holdings Ltd surged 24.4 percent to $20.57 after Alibaba Group disclosed in a filing with the Securities and Exchange Commission that it had offered to buy all the shares of the Chinese digital mapping and navigation firm it does not already own.

About 56 percent of companies traded on both the New York Stock Exchange and Nasdaq closed higher on the day. About 5.83 billion shares traded on all US platforms, according to BATS exchange data. - Reuters