I was wondering if there was an efficient way to perform a right shift on an 8-bit binary value using only ALU operators (NOT, OR, AND, XOR, ADD, SUB)
Example: input: 00110101 output: 10011010
I managed to implement a left shift by simply adding an 8-bit binary value with me, since a left shift is equivalent to multiplying by 2. However, I cannot think of a way to do this to switch correctly.
The only method I came across is to simply perform 7 left trunk shifts. Is this the only way?
, {AND, OR, XOR, NOT}. outbit [N] inbit1 [N] inbit2 [N] . inbit1 [N].. inbit1 [0] inbit2 [N].. inbit2 [0]. inbit [N + 1]. , , - , SUB.
{AND, OR, XOR, NOT}
A - B A + (-B), A + ((B XOR 11111111) +1). , SUB, ADD XOR. , . , {ADD, OR, XOR, NOT, ADD, SUB} .
A - B
A + (-B)
A + ((B XOR 11111111) +1)
{ADD, OR, XOR, NOT, ADD, SUB}
Source: https://habr.com/ru/post/1719857/More articles:Edit multiple states at once in Flash Builder 4 - flexWhat are some physical distribution services with an API? (pdf for letter delivery) - automationMVC ... how and why, and what other good options are (PHP)? - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1719855/splitting-a-git-repository&usg=ALkJrhhUfhSDXe-PmCXmhI4oidtEEZKbGwtableView: viewForHeaderInSection: default value? - iosThe initial heap size allocated for a C ++ program on UNIX - c ++HTML / CSS color names - htmlsaving and restoring the state of the tab bar controller - objective-cWhat is the best way to build / design a long complex web form for collecting user input - designПроблема с синхронизированными наборами Java при выполнении equals() в обратном порядке из нескольких потоков - javaAll Articles