subject

The exercise can be completed by following these steps:

1) Create a C program called ex6.c in C that compiles and runs.

2) Create a makefile to compile and link ex6.c to produce executable ex6

Create a C program that takes user input as separate lines.

As described in earlier discussion sessions, there are several bit operations available in C:

1) Bitwise OR (|)

2) Bitwise AND (&)

3) Bitwise XOR (^)

4) Bit SHIFT (>)

Using the operations, you can mask out certain bits (i. e., zero them), turn on specific bits (i. e., set them to 1), and select specific bits.

Your program will run on the shell command line and will provide a simple command line interface that accepts the following commands. By default, do not print a prompt. All output values are in hexadecimal format.

1) C x n: clear - read in x in hex format and n in decimal, output x with bit n (from LSB starting at 0) cleared

2) M x m: read in x and m in hex and output x masked by m

3) Q: quit

4) S x n: set - read in x in hex format and n in decimal, output x with bit n (from LSB starting at 0) set

5) V x n: read in x in hex and n in decimal, output bit n of x (from LSB starting at 0)

Clear means set a bit to 0. Masking x with mask m means that only all bits of x where the mask is 0 are cleared. Set means set a bit to 1. The maximum input hex value is 0x7 and the maximum decimal value is 31; there are no negative inputs, and you are not required to check for these.

Example Output:

storm:1% make

cc -o ex6 ex6.c

storm:2% ./ex6

V f0f0 0

0

S f0f0 8

f1f0

C f0f0 0

f0f0

M f0f0

f0f0

M 7 e

6

Q

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:20
Consider a byte-addressable computer with 16mb of main memory, a cache capable of storing a total of 64kb of data and block size of 32 bytes. (a) how many bits in the memory address? (b) how many blocks are in the cache? (c) specify the format of the memory address, including names and sizes, when the cache is: 1. direct-mapped 2. 4-way set associative 3. fully associative
Answers: 2
question
Computers and Technology, 22.06.2019 16:30
Technician a says that a dry sump system uses no oil storage sump under the engine. technician b says that a wet sump system uses no oil storage sump under the engine. who is correct?
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
How is the number 372 written when expanded out to place values in the base 8 (octal) number system? a. 2 x 4 + 3 x 2 + 4 x 1 b. 3 x 64 + 7 x 8 + 2 x 1 c. 3 x 8 + 7 x 7 + 2 x 6 d. 3 x 100 + 7 x 10 + 2 x 1
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
You know the right answer?
The exercise can be completed by following these steps:

1) Create a C program called ex6...
Questions
question
History, 02.08.2021 19:30
question
Physics, 02.08.2021 19:30
question
World Languages, 02.08.2021 19:30
Questions on the website: 13722366