Ok, so I'm a (posting) noob on this site, but aren't loops discouraged in these forums?
If you have a zero-based Tally table, you can replace your initializer and loop with something like:
INSERT INTO @PROCMASKSTABLE
SELECT CAST(c.value AS INT) & Bits.BitMask AS Mask
FROM sys.configurations AS c CROSS JOIN
(SELECT Number AS BitNo, CAST(POWER(2.0, Number) AS BIGINT) AS BitMask
FROM Tally WHERE (Number <= @NUMPROCS and Number <= 31)) AS Bits
WHERE (c.name = 'affinity mask')
not saying it's any faster, but the anti-loop people will like it much better
Also, I think your code will fail on processor 32 (bit 31), because you'll get an integer overflow - try this and see what I mean:
select 1073741824 * 2 -- 1073741824 == 2^30
you need to use a BIGINT.
Also, although I also can't test it, because I don't have more than 32 processors, I think the Affinity64 mask is also a 32-bit number,
for processors 32 through 63, and that you need to use the same logic as for the first 32, and add 32 to resulting numbers...