US stocks end higher midweek on tech gains