Simpler example: julia> for a::Uint8 in 0x0:0x1; println(a); end ERROR: syntax: invalid assignment location "(:: a Uint8)"
julia> for a::Uint8 in (0x0,0x1); println(a); end 0 1 julia> for a in 0x0:0x1; println(a); end 0 1 On Friday, 3 January 2014 08:04:12 UTC-3, andrew cooke wrote: > > Hi, > > What does --- ERROR: syntax: invalid assignment location "(:: i Uint)" --- > mean? I think it may be from the lisp/scheme layer which would explain the > strange position of "i", but I am having a hard time working out where the > mistake is in my ugly code (the location info is useless). > > The error is likely in: > > function precalc1() > function calc(state) > a = state & 0x01; state = state >> 1 > b = state & 0x01; state = state >> 1 > ac = state & 0x01; state = state >> 1 > bc = state & 0x01; state = state >> 1 > s1 = state & 0x01; state = state >> 1 > s2 = state & 0x01; state = state >> 1 > s3 = state & 0x01; state = state >> 1 > s4 = state & 0x01; state = state >> 1 > a = a $ b > a = a + s1 > b = b $ a > b = b + s2 > convert(Uint8, (a & 0x01) | (b & 0x01) << 1 | (a & 0x02) << 1 | (b > & 0x02) << 2) > end > cache = zeros(Uint8, 0x100) > for i::Uint in 0x0:0xff > cache[i+1] = calc(i) > end > cache > end > > > function precalc2(cache1) > cache = zeros(Uint8, 0x4000) > for in1::Uint in 0:0xff # ab2, r1c2, r1s4 > > out1 = cache1[in1+1] > for cs::Uint in 0x0:03f # r2c2, r2s4 > > in2 = (out1 & 0x03) | (cs << 2) > out2 = cache[in2+1] > # construct ab2, r1c2, r2c2, r1s4, r2s4 > > in = (in1 & 0x0f) | (cs & 0x03) << 4 | (in1 & 0xf0) << 2 | (cs > & 0x3c) << 8 > # construct final result + all carries > > out = convert(Uint8, (out2 & 0x03) | (out1 & 0x0c) | (out2 & > 0x0c) \ > << 2) > cache[in+1] = out > end > cache > end > > > function precalc3(cache1, cache2) > cache = zeros(Uint8, 0x100000) > for in1::Uint in 0x0:0xff # ab2, r1c2, r1s4 > > out1 = cache1[in1+1] # ab2, r1c2 > > for cs::Uint in 0x0:0xfff # r2c2, r3c2, r2s4, r3s4 > > in2 = (out1 & 0x03) | (cs << 2) > out2 = cache2[in2] # ab2, r2c2, r3c2 > > # construct ab2, r1c2, r2c2, r3c2, r1s4, r2s4, r3s4 > > in = (in1 & 0x0f) | (cs & 0x0f) << 4 | (in1 & 0xf0) << 4 | (cs > & 0xff0) << 8 > # construct ab2, r1c2, r2c2, r3c2 > > out = convert(Uint8, (out2 & 0x03) | (out1 & 0x0c) | (out2 & > 0x3c) \ > << 2) > cache[in+1] = out > end > end > end > > > function encrypt_bit() > const cache1 = precalc1() > const cache2 = precalc2() > const cache3 = precalc3() > end > > > and any suggestions on how to write that kind of bit-twiddling neater (but > no less efficiently) welcome. > > Thanks, > Andrew >
