In-depth understanding of computer system second edition Exercise answers CSAPP 2.13, csapp2.13
From the end of 1970s to the end of 1980s, Digital Equipment's VAX computer was a very popular model. It does not have Boolean operations and or commands, but only bis (bit setting) AND bic (bit clearing) commands. The input of the two commands is a data word x and a mask word m. They generate a result z, which is obtained by modifying the x bit based on the mask m bit. Using the bis command, this modification is to set the z bit to 1 at every position where m is 1. Using the bic command, this modification is to set the z bit to 0 at every position where m is 1.
Only these two functions are used to implement the bitwise | and ^ operations in the C language.
1 int bis (int x, int m); 2 int bic (int x, int m); 3 4 int bool_or (int x, int y) 5 {6 int result = bis (x, y); 7 return result; 8} 9 10 int bool_xor (int x, int y) 11 {12 int result = bis (bic (x, y), bic (y, x); 13 return result; 14}