  We study the low-energy limit of a compactification of N=4 U(n) super
Yang-Mills theory on $S^1$ with boundary conditions modified by an S-duality
and R-symmetry twist. This theory has N=6 supersymmetry in 2+1D. We analyze the
$T^2$ compactification of this 2+1D theory by identifying a dual weakly coupled
type-IIA background. The Hilbert space of normalizable ground states is
finite-dimensional and appears to exhibit a rich structure of sectors. We
identify most of them with Hilbert spaces of Chern-Simons theory (with
appropriate gauge groups and levels). We also discuss a realization of a
related twisted compactification in terms of the (2,0)-theory, where the recent
solution by Gaiotto and Witten of the boundary conditions describing D3-branes
ending on a (p,q) 5-brane plays a crucial role.
