324_Book

30 solution pg 191 codeasmasmprobs ansc b4 processor

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ne. Problem 2.8 Solution: [Pg. 38] These problems help you think about the relation between Boolean operations and typical masking operations. Here is the code: /* Bit Set */ int bis(int x, int m) { int result = x | m; return result; } /* Bit Clear */ int bic(int x, int m) { int result = x & ˜m; return result; } It is easy to see that bis is equivalent to Boolean O R—a bit is set in z if either this bit is set in x or it is set in m. The bic operation is a bit more subtle. We want to set a bit of z to 0 if the corresponding bit of m equals 1. If we complement the mask giving ˜m, then we want to set a bit of z to 0 if the corresponding bit of the complemented mask equals 0. We can do this with the A ND operation. Problem 2.9 Solution: [Pg. 39] This problem highlights the relation between bit-level Boolean operations and logic operations in C. 694 Expression x&y x|y ˜x | ˜y x & !y Problem 2.10 Solution: [Pg. 40] The expression is !(x ˆ y). APPENDIX B. SOLUTIONS TO PRACTICE PROBLEMS Value 0x02 0xF7 0xFD 0x00 Expression x && y x || y !x || !y x &am...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online