From: Jay Reeve <jktr@...>

Date: Fri, 22 Oct 99 09:58:09 -0500

Date: Fri, 22 Oct 99 09:58:09 -0500

>Now, there should be a way to find the reverses without recourse to a >lookup-table... > But why? Your table only needs 16 entries--just 16 bytes if you use a BYTE array. If you don't want the minimal overhead of an array, just use a 16-byte var and do this: DIM swapList;16 'set values then swappedNybble% = PEEK (@swapList + nybbleVal) Doing anything else will use more mem than that for code, and be slower. BTW, I think bitshifts would be faster for the calcs you showed: > a = &1A > b1 = a / 16 'b1 = &1 > b2 = a MOD 16 'b2 = &A > c = 16 * f(b2) + f(b1) ' c = 16 * 5 + 8 = &58 a = &1A b1 = a >> 4 'b1 = &1 b2 = a AND 15 'b2 = &A c = f(b2) << 4 + f(b1) ' c = 16 * 5 + 8 = &58 >Now, there should be a way to find the reverses without recourse to a >lookup-table... try this: LOCAL FN swapNybble%(nybble%) select nybble% case 0,6,9,15 '= no change case 1,8: nybble% = nybble% XOR 9 case 2,4: nybble% = nybble% XOR 6 case else:nybble% = nybble% XOR 15 end select END FN = nybble% AND 15 a = &1A swappedVal% = FN swapNybble%(a>>4) OR FN swapNybble%(a AND 15) << 4 At least it's a different approach. 0"0 =J= a y "