Question: 1. To exercise the logical operations, write a program that works with three one-byte data variables labeled STATUS, CONTROL and PERIPH. The program is

1. To exercise the logical operations, write a program that works with three one-byte data variables labeled

1. To exercise the logical operations, write a program that works with three one-byte data variables labeled STATUS, CONTROL and PERIPH. The program is to perform the following operations. If bit 4 of STATUS is 0, set bit 3 of CONTROL to 0, otherwise set bit 2 of CONTROL to 1. If bit 2 of STATUS is O and bit 1 of STATUS is 0, set bit 6 of CONTROL to 1, otherwise set bit 5 of CONTROL to 0. Replace bits 6-3 of PERIPH with the hex digit 5, without changing the other four bits of PERIPH. Data are stored in "little endian" format (bits are numbered 7 down to O, from left to right, within each byte.) 2. Test the program using the following initial data values: STATUS = 0xC1, CONTROL = 0xA8, PERIPH = 0xD2. Display these values in the Expressions view and in a Memory view (rendered in hexadecimal, to facilitate examining bytes), and capture the Expressions view to show the final values of STATUS, CONTROL, and PERIPH. Then reset the program, change the data to STATUS=0x3E, CONTROL=0x3B, PERIPH=0x56, run the program, and again capture the Expressions view to show the final values of STATUS, CONTROL and PERIPH. Note that you can change the data, while the program is paused at label main, by either clicking on a value in the Memory view and enter a new value, or entering GDB "set" commands to change values. (Refer to section F of the Tutorial.) 3. Submit the source code and the Expressions views, circling or highlighting the values of the three variables in the Expressions view after each run.

Step by Step Solution

3.41 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

c include int main unsigned char STATUS 0xC1 unsigned char CONTROL 0xA8 unsigned char PERIPH 0xD2 if ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!