U.S. stocks gained for a fourth day after Federal Reserve Chairman Ben Bernanke urged policy makers to react quickly to improve the growth of the economy and regulators allowed Fannie Mae and Freddie Mac to buy more mortgages.

Fannie Mae and Freddie Mac, the largest providers of financing for U.S. home loans, each rallied the most since November and have constrained their ability to support the housing market, which is in its worst state since the Great Depression.

Fannie Mae posted a $3.80 per share net loss for the fourth quarter, compared with a profit of $604 million in the year-earlier period. It stock tumbled in November when it report a $1.52 billion third-quarter loss.

The Dow average added 55.69 points, or 0.4 percent, to 12,740.61 at 11:27 a.m. in New York. The S&P 500 climbed4.72, or 0.3 percent, to 1,386.01, and the Nasdaq Composite Index rose 13.53, or 0.3 percent, to 2,358.52.

About three stocks gained for every two that fell on the New York Stock Exchange.