The Dow Jones industrial average rose 58.73 points, or 0.50 percent, to 12,676.05. Helping the Dow were big gains from two components, Boeing Co. and Caterpillar Inc. They contributed 24 points to the index, nearly half of its gain.
Boeing rose $2, nearly 3 percent, to $74.03 after reporting surprisingly strong earnings. The aircraft maker also raised its profit forecast for all of 2012.
Caterpillar, which makes mining and construction equipment, rose $1.17, or 1.4 percent, to $82.60. The company blew away analysts' estimates with a 67 percent surge in profits for the second quarter. Caterpillar credited strong sales of mining equipment overseas and a strengthening housing market.
Shortly after Caterpillar announced its results, the optimism about housing took a hit. The Commerce Department said sales of new homes fell 8 percent last month, the steepest drop since February last year. Sales in the Northeast plummeted 60 percent. The decline suggests a weaker job market is dampening any pickup in the industry.
Homebuilders were hit hard. Beazer Homes fell 13 cents, or 5 percent, to $2.35. KB Home lost 32 cents, or 3 percent, to $9.31.
The biggest loser in the S&P was Netflix Inc., the video subscription company. It fell $20.11 to $60.28, a loss of 25 percent. The company reported late Tuesday that its net income plunged 91 percent in the latest quarter. Investors are worried about rising licensing fees and slowing subscriber growth.
Late Tuesday, Apple had reported net income rose 21 percent in the second quarter instead of the 33 percent that analysts were expecting. Apple said consumers appear to be holding off on buying iPhones before a new model comes out, even though it isn't expected until October.
Apple makes up 12.7 percent of the Nasdaq composite, making it by far the biggest component of the technology-focused index. The Nasdaq lagged the broader market, closing down 0.3 percent, or 8.75 points, at 2,854.24.
The bad news from tech stocks didn't end there. After the closing bell, Zynga Inc., the maker of online video games such as Farmville, slashed its forecast for full-year earnings, blaming delays in launching new games, dwindling revenue from Web games, and a "more challenging environment" on the Facebook platform. The stock plunged $2.04, or 40 percent, to $3.05 in after-hours trading.
In other corporate news, computer security provider Symantec soared $1.79 to $14.96. The company announced the departure of its CEO, Enrique Salem, and reported earnings per share and revenue came in well ahead of Wall Street's estimates.
WellPoint, the nation's second largest insurer, lowered its earnings forecast. Its stock fell $7.41, or 12 percent, to $54.01, the biggest one-day drop for the stock in more than three years. The insurer said enrollment has been slipping as companies cut jobs.