Stocks fell on Tuesday, as a disappointing outlook from Hewlett-Packard Co and another batch of soft U.S. data added to growing trepidation about the strength of the economy.

The declines caused both the benchmark S&P and Nasdaq at times to fall below their 50-day moving averages, a technical symbol that could indicate further weakness is possible.

Tech stocks fell as investors sold recent winners due to unease about pockets of weakness in the U.S. economy. The PHLX semiconductor index <.SOX>, composed partly of suppliers of desktop computer chips, dropped 1.7 percent.

HP, the world's largest technology company, tumbled 8.1 percent to $36.56 after cutting its forecast due to problems stemming from Japan's earthquake and soft PC sales.

Hewlett-Packard is kind of taking the whole tech sector down, that's true. Don't forget also the macro data that has been coming out has been anything but stellar -- as a matter of fact it has been more to the bleak side, said Ken Polcari, managing director at ICAP Equities in New York.

The Dow Jones industrial average <.DJI> dropped 136.38 points, or 1.09 percent, to 12,411.99. The Standard & Poor's 500 Index <.SPX> fell 7.09 points, or 0.53 percent, to 1,322.38. The Nasdaq Composite Index <.IXIC> lost 14.32 points, or 0.51 percent, to 2,767.99.

Data showed U.S. housing starts and permits for future home construction fell in April, pointing to prolonged weakness in the housing sector while the Federal Reserve reported factory output slumped in April as an automobile part shortage hurt production.

The PHLX housing sector index <.HGX> declined 1.4 percent. Forest product maker and homebuilder Weyerhaeuser Co lost 2.4 percent to $21.59.

Commodity-related stocks also lagged as the dollar rose on concerns about a Greek debt restructuring. The S&P materials index <.GSPM> fell 1.3 percent and the S&P energy index <.GSPE> shed 0.9 percent.

A rise in the greenback reduces the appeal of dollar-priced commodities, which become relatively more expensive. Worry over European sovereign debt is sending investors in a flight to safety to the U.S. dollar, Polcari said.

If the euro really starts to have some difficulty, people are going to flock to the dollar, he said.

Shares of defensive companies, however, outperformed. The S&P utilities sector <.GSPU> rose 0.3 percent, boosted by a 2.1 percent gain in and American Electric Power to $38.50.

Wal-Mart Stores Inc's stock dipped 1.2 percent to $55.38 after news the retailer's same-store sales have now fallen for two years.

Through Tuesday, of the 464 companies in the S&P 500 that have reported earnings, 69 percent have topped analyst estimates, according to Thomson Reuters data.

(Editing by Kenneth Barry)