Question

Application Problem: Answer the following questions at the bottom of the worksheet: You are configuring a...

Application Problem:

Answer the following questions at the bottom of the worksheet:

You are configuring a microcontroller (uC) to sample a signal connected to an input pin. Part of the initial setup requires that you clear (turn off) bits #17 and #2 in a 32-bit register, while leaving all other bits unchanged. To work with specific bits, we typically use a second number, called a mask, which has the bit positions we need to alter set to 1, and all other bits are 0. What sequence of binary operators could you use on the register and mask to get the desired result (bits 9 and 1 cleared)?  

Control Register:              10000001 00000000 00000000 00001010

Mask:                                  00000000 00000001 00000000 00000010

                                              __________________________________

Result:                                10000001 00000000 00000000 00001000

Hints:   Try a simplified set on paper, such as 1-bit numbers, to help you come up with ideas to solve the problem. Use the program you created in Part 3 to test your ideas on 32-bit numbers.

The “32 bit register” is your first integer (iNum1), and its value could be anything. Make sure your solution works regardless what iNum1’s value is.

Your second integer (iNum2) is the “mask”. Its value is all 0’s with the two key bits (#17 and #2) set to 1. Use the Windows calculator in Programmer Mode to convert binary 1 0000 0000 0000 0010 to decimal for iNum2.  

               You will need to apply more than one bitwise operator to solve this correctly

Part A.) Using the following binary operators, explain how the code can be developed to solve the problem?

>>

shift all bits right

<<

shift all bits left

&

AND

|

OR (inclusive)

^

Exclusive OR (XOR)

               ~             One’s compliment (flip all bits)

Part B.) Write the lines of code necessary to comple the process in C?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

please do upvote.If you have any problem do comment and i shall be happy to help you.Thanks for using HomeworkLib.

-----------------------

Mask : Has the bit positions we want to alter set as 1

Bit positons that should remain unchanged as 0

We shall use Xor operation on register and mask to obtain desired result.

Xor operation is used to alter state of bit.

i.e If it is set(=1) it will clear(=0) it

and viceversa

(assume p shall be bit of register and q bit of mask)

Truth Table of xor

p q r

0 0 0

0 1 1

1 0 1

1 1 0

e.g

first 9 bits in a 32 bit register

register: 100111101

we want to alter 1st and 9th bit

so mask must be one(1) at bit position 1 and 9 will zero(0) otherwise

mask : 1 00000001

no when we perform xor bitwise on register and mask

register: 100111101

xor

mask : 1 00000001

---------------------------

result: 000111100 (obtained using xor table)

the bits at position 1 and 9 are cleared

Add a comment
Know the answer?
Add Answer to:
Application Problem: Answer the following questions at the bottom of the worksheet: You are configuring a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • lab3RGB.c file: #include <stdio.h> #define AlphaValue 100 int main() { int r, g,b; unsigned int rgb_pack...

    lab3RGB.c file: #include <stdio.h> #define AlphaValue 100 int main() { int r, g,b; unsigned int rgb_pack; int r_unpack, g_unpack,b_unpack; int alpha = AlphaValue; printf("enter R value (0~255): "); scanf("%d",&r); printf("enter G value (0~255): "); scanf("%d",&g); printf("enter B value (0~255): "); scanf("%d",&b); while(! (r<0 || g<0 || b <0) ) { printf("A: %d\t", alpha); printBinary(alpha); printf("\n"); printf("R: %d\t", r); printBinary(r); printf("\n"); printf("G: %d\t", g); printBinary(g); printf("\n"); printf("B: %d\t", b); printBinary(b); printf("\n"); /* do the packing */ //printf("\nPacked: value %d\t", rgb_pack); printBinary(rgb_pack);printf("\n");...

  • 1 to 15 blanks thank you! (1 point) For registers, Integers are encoded in one of...

    1 to 15 blanks thank you! (1 point) For registers, Integers are encoded in one of two basic types 1. and 2. (1 point) The number 201 as a one byte unsigned integer is represented as in binary and in hexadecimal. (1 point) The 2 methods for representing signed integers are 3. and (5 points) What is the 16 bit representation of -125 in 2's complement notation? 4. (5 points) What is the decimal representation of the signed integer 10000001?...

  • You are given a homework processor (HPro) capable of addressing 32 8-bit (1 byte) wide registers....

    You are given a homework processor (HPro) capable of addressing 32 8-bit (1 byte) wide registers. However, it has only 29 physical registers. Register RO, R1 and R31 are not physically implemented. Instead, every read from RO, R1 and R31 will return a constant zero (00000000), constant one (00000001) and all ones (11111111), respectively. Every write to RO, R1 and R31 will go to null (dummy write). Assume that all other registers have initially unknown (X) state (This in fact...

  • For this assignment you will explore subnet addresses, host addresses and direct broadcast addresses. You will...

    For this assignment you will explore subnet addresses, host addresses and direct broadcast addresses. You will be provided an IP addresses and then asked to answer questions related to the IP. In this assignment, first we explain how to find the subnet address for each subnet, the range of host addresses, and the direct broadcast address. Then you will be asked to do a similar exercise by yourself. Assume that you have been assigned the 192.168.1.0/24 network. You need to...

  • Write code to implement the following function: /* * Generate mask indicating leftmost 1 in x....

    Write code to implement the following function: /* * Generate mask indicating leftmost 1 in x. Assume w=32. * For example 0xFF00 -> 0x8000, and 0x6600 --> 0x4000. * If x = 0,then return 0. */ int leftmost_one(unsigned x); Your function should follow the above bit-level integer coding rules, except that you may assume that data type int has w=32 bits. Your code should contain a total of at most 15 arithmetic, bit-wise, and logical operations. In C++ and has...

  • Problem 1: Implement an algorithm to generate prime numbers. You will need to implement the following...

    Problem 1: Implement an algorithm to generate prime numbers. You will need to implement the following ingredients (some of them you developed for earlier assignments): 1. A method to generate random binary numbers with n-digits (hint: for the most significant digit, you have no choice, it will be 1; similarly, for the least significant digit there is no choice, it will have to be 1; for all other position, generate 0 or 1 at random) 2. A method to compute...

  • Solve problem 2 using the priblem 1 . Question is taken from Ring theory dealing with ideals and ...

    Solve problem 2 using the priblem 1 . Question is taken from Ring theory dealing with ideals and generating sets for ideals. Problem 1. Suppose that R (R,+ Jis a commutative ring with unity, and suppose F- (a,,. , a } is a finite nonempty subset of R. Modify your proof for Problem 5 above to show that 7n j-1 Problem 2. Consider the set Zo of integer sequences introduced in Homework Problem 6 of Investigation 16. You showed that...

  • the w 2. This problem explores the use of a one-time pad version of t In...

    the w 2. This problem explores the use of a one-time pad version of t In this scheme, the key is a stream of random numbers between 0 and example, if the key is 3 19 5..., then the first letter of plaintext is encrypted with a shift of 3 letters, the second with a shift of 19 letters, the third with a shift of 5 letters, and so on. a. Encrypt the plaintext sendmoremoney with the key stream 9...

  • Implement the following statements using MS430 assembly instructions. You may use more than one, ...

    Implement the following statements using MS430 assembly instructions. You may use more than one, but you should minimize the number of instructions required. You can use both native and emulated instructions. Use hex notation for all numbers 1. (a) Move the word located in register R14 to R15 (b) Increment the word in R6 by 2. (c) Perform a bitwise ANDing of the word located at address 0x0240 with the datum in R15, placing the results in R15. (d) Rotate...

  • thank you in advance Sample Problem: MIPS is a 32-bit ISA. The I instructions in MIPS have the following format: [...

    thank you in advance Sample Problem: MIPS is a 32-bit ISA. The I instructions in MIPS have the following format: [opcode (6bits)ー!RS (5 bits) (l6 bits) |1mm (16bits) Rt(5 bits) (1) Assume that we want to implement a single-cycle datapath for I MIPS instructions, write down the "in" ports part of the VHDL entity declaration for the single-cycle datapath controller. (Hint: what information does the single-cycle controller use?) entity singlecyclecontroller is port (???: in STD LOGIC); end foo; (2) Now...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT