Updated

Stronger earnings reports from Mattel, Coca-Cola and other big companies pushed the stock market higher in midday trading Tuesday.

The Dow Jones industrial average rose 45 points to 12,772 shortly after noon Eastern.

Stocks wavered between gains and losses during morning trading. If the Dow finishes higher, it would mark the third day of gains for the average this month. The market has been taking a beating in July because of worries that Spain's banking system would fail and that U.S. corporate earnings would shrink.

Mattel jumped 10 percent, more than any other company in the S&P 500. The country's biggest toy maker said net income rose on better sales of Barbie dolls and lower advertising costs. Its stock jumped $3.10 to $34.14.

Coca-Cola posted higher income and revenue than Wall Street had expected, thanks in part to booming business overseas. Coke rose $1.19 to $77.65.

A grim assessment on the U.S. economy from Federal Reserve Chairman Ben Bernanke kept the gains in check. In his semiannual report before Congress, Bernanke said weaker economic growth likely means the unemployment rate will be slow to drop. But he offered no signs that the Fed was ready to take action to bolster growth soon.

"The big question here isn't whether the Fed will act," said Randy Frederick, managing director of active trading and derivatives at Charles Schwab. "We know they will. The question is how bad do things have to deteriorate before they act."

Goldman Sachs also reported earnings and revenue that beat Wall Street's forecasts. The bank said it bundled more mortgages into bonds, leading to a 37 percent increase in sales from mortgage and commodity trading. Its stock gained 21 cents to $97.89.

The gains were broad but slight. Nine of the 10 industries in the S&P 500 rose, led by material companies. Bank stocks fell.

In other trading, the Standard & Poor's 500 index edged up four points to 1,358 and the Nasdaq rose eight points to 2,905.

Among other stocks making big moves:

— Mosaic jumped 4 percent. The fertilizer maker's net income beat Wall Street's forecasts, with the help of stronger phosphate sales and higher prices for potash. Mosaic also doubled its quarterly dividend to 25 cents. The stock gained $2.24 to $57.63.

— Reports that HSBC allowed Mexican drug cartels to launder billions through its U.S. banks helped push the bank's stock down 1 percent. A Senate investigation also said some HSBC bank affiliates ignored U.S. government bans against financial transactions with Iran and other countries. HSBC fell 54 cents to $42.94.

— Walt Disney led the Dow, gaining $1.78 to $49.64 after getting an upgrade by analysts at Bank of America.