Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Many Thanks and Thumps up in advance Objective Investigate the usage of bitwise and shift operators using the C language Procedure 1. Create a new
Many Thanks and Thumps up in advance
Objective Investigate the usage of bitwise and shift operators using the C language Procedure 1. Create a new C project in Code Composer. Initialize the contents of three local variables of type int as follows volatile int i = 0x25A3; volatile int j = 0x8B94; volatile int k 0x006C; Perform the following operations using the appropriate C operators. Create a new variable r to store the result. Use the watch window in CCS to observe the results (change the Number Format to Binary). For each operation, record the result in binary Description C Language Predicted Result MSP430 Result Bitwise AND r-i &j Bitwise OR Bitwise XOR Bitwise NOT on i 2. Masking. Perform a "bit test" operation to test if the bit5 of the variable i is a one. Hint: create a new variable with a mask. Remember the LSB = bit. If the result of the test is stored in an int, can you use the result of the test in a conditional loop (which requires a Boolean value in the condition)? Explain. In this exercise, you used the data type int. This variable can represent both negative and positive integer values. If you change the data type to unsigned int 3. a. Does t change the decimal value of the result? Explain. b. Does t change the bit values of the result? Explain. Hint: experiment with the Number Format...Default, Decimal, and Hex 4. What does the following expression do? Hint: rewrite it as separate expressions. Objective Investigate the usage of bitwise and shift operators using the C language Procedure 1. Create a new C project in Code Composer. Initialize the contents of three local variables of type int as follows volatile int i = 0x25A3; volatile int j = 0x8B94; volatile int k 0x006C; Perform the following operations using the appropriate C operators. Create a new variable r to store the result. Use the watch window in CCS to observe the results (change the Number Format to Binary). For each operation, record the result in binary Description C Language Predicted Result MSP430 Result Bitwise AND r-i &j Bitwise OR Bitwise XOR Bitwise NOT on i 2. Masking. Perform a "bit test" operation to test if the bit5 of the variable i is a one. Hint: create a new variable with a mask. Remember the LSB = bit. If the result of the test is stored in an int, can you use the result of the test in a conditional loop (which requires a Boolean value in the condition)? Explain. In this exercise, you used the data type int. This variable can represent both negative and positive integer values. If you change the data type to unsigned int 3. a. Does t change the decimal value of the result? Explain. b. Does t change the bit values of the result? Explain. Hint: experiment with the Number Format...Default, Decimal, and Hex 4. What does the following expression do? Hint: rewrite it as separate expressionsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started