Question: There is an 8-bit register named CTRL at memory location 0x8000102C. It has the following bit values: Bit 7 6 5 4 3 2 1

  1. There is an 8-bit register named CTRL at memory location 0x8000102C. It has the following bit values:

Bit 7

6

5

4

3

2

1

0

EN

NEN

OPT

GX

FLG

WERR

  1. Write one line of code to read the value of CTRL into inval. Assume that the IDE works in such a way that you can simply do something like inval = CTRL.
  2. Write one line of code to mask inval so that only the FLG bit is reflected. That is, after masking, inval should be non-zero if FLG is 1 and zero if FLG is 0. Hint: The value of the control register is already in the variable named "inval". Apply a masking operation to "inval" so that all bits besides the FLG bit are forced to zero. (This results in a situation in which inval is non-zero if FLG=1 and inval is zero if FLG=0.)

  1. Write one line of code to set (force to 1) the NEN bit without affecting any other bits. One way to do this is to read CTRL into inval (do it again CTRL might have changed since the last time you did it), manipulate inval, and then write it back to CTRL.
  2. Write one line of code to clear (force to 0) the EN bit without affecting any other bits.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!