NEW YORK, SEPT. 28 -- The stock market ran up a solid gain today in buying encouraged by hopes for a stable dollar in foreign exchange.

The Dow Jones average of 30 industrials, up more than 40 points at its midsession peak, closed with a 31.33 advance at 2601.50.

Volume on the New York Stock Exchange stepped up to 188.07 million shares from 137.95 million in the previous session.

A.C. Moore, analyst at Argus Research Corp., said investors were heartened by weekend news from a meeting of the Group of Seven industrialized countries in Washington.

There had been conjecture last week that the group might seek a lower level for the dollar in foreign exchange.

Instead, it reaffirmed its commitment to an agreement made last February to try to keep the dollar stable, apparently near its present levels.

On currency markets today, the dollar was mostly higher in Europe but little changed in U.S. markets. Gold prices also were little changed. Republic National Bank of New York quoted a bid of $460.05 for a troy ounce of gold, up from $460.00 on Friday.

In Tokyo, where trading ends as Europe's business day begins, the dollar rose for the fifth successive session to close up 0.42 at 144.22 yen. It was later quoted in London at 144.15 yen. In New York, the dollar rose to 144.38 yen from 143.55 yen late Friday.

The credit markets posted little change for the day. However, analysts said a steady showing by bonds was good enough to satisfy stock traders, given the pummeling the bond market has taken of late.

Salomon Inc. rose 2 3/4 to 34 3/4 in active trading. The firm bought out Minerals & Resources Corp. as its largest shareholder and announced plans to receive a new infusion of capital from Berkshire Hathaway Inc., whose chairman, Warren Buffett, is widely respected as a shrewd investor.

Among stocks of other investment banking firms, First Boston gained 1 3/8 to 42 3/8 and Morgan Stanley 1 to 77 3/4.

Bundy Corp., which agreed to a $40-a-share takeover by TI Group of Britain, picked up 9 5/8 to 41 1/8, posting one of the day's best percentage gains.

Entex Inc. rose 3 3/8 to 193. The company said it received a $20-a-share buyout proposal from its president.

Gainers among the blue chips included General Electric, up 1 at 62 1/4; Philip Morris, up 2 7/8 at 119 1/8; Du Pont, up 2 1/4 at 120, and Merck, up 4 7/8 at 204 3/4. International Business Machines was a notable laggard, down 3 1/4 to 152 3/4.

The Nasdaq composite index for the over-the-counter market gained 0.41 to 442.29. At the American Stock Exchange, the market value index closed at 356.91, up 2.41