Re:Open AirPlay 2 Receiver
by adolph on Monday August 08, 2022 @10:43PM
(#32393737)
There are two lists buffer1 and buffer4. So these two lines assign a value to the 16th item in buffer1 and prints it with its hex value. The value is determined by arithmetic and bitwise operations.
For example, if buffer1[72]=107343, buffer1[190] = 25, and buffer[4]=18
(buffer1[72] >> (buffer4[buffer1[190] % 21] & 7))
(buffer1[72] >> (buffer4[25 % 21] & 7))
(buffer1[72] >> (buffer4[4] & 7))
(buffer1[72] >> (18 & 7))
(107343 >> 10)
104
>> and << operators accept integers as arguments. They shift the first argument to the left or right by the number of bits given by the second argument
i = 14; // Bit pattern 00001110
j = i >> 1; // here we have the bit pattern shifted by 1 thus we get 00000111 = 7 which is 14/2
& operator yields the bitwise AND of its arguments (*If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. so 1100 & 1010 is 1000*)
^ operator yields the bitwise XOR (exclusive OR) of its arguments (*so 0101 ^ 1111 is 1010*)
To use formatted string literals, begin a string with f or F before the opening quotation mark or triple quotation mark. Inside this string, you can write a Python expression between { and } characters that can refer to variables or literal values.
For example, if buffer1[72]=107343, buffer1[190] = 25, and buffer[4]=18 (buffer1[72] >> (buffer4[buffer1[190] % 21] & 7)) (buffer1[72] >> (buffer4[25 % 21] & 7)) (buffer1[72] >> (buffer4[4] & 7)) (buffer1[72] >> (18 & 7)) (107343 >> 10) 104
https://docs.python.org/3/reference/expressions.html#shiftin...
https://docs.python.org/3/reference/expressions.html#binary-... https://docs.python.org/3/tutorial/inputoutput.html#fancier-... Bitwise examples from:https://en.wikipedia.org/wiki/Bitwise_operations_in_C
https://docs.microsoft.com/en-us/cpp/cpp/bitwise-exclusive-o...