Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 23:30, bri2008
Which of the following is not a symptom of chronic fatigue syndrome
Answers: 2
image
Computers and Technology, 23.06.2019 06:40, sardarp1irc5
What are the three uses of a screw?
Answers: 2
image
Computers and Technology, 24.06.2019 14:30, SmartScholar4094
Two students are discussing electricity that has a frequency of 60 hz. student a says that this type of electricity is referred to as ac. student b says that in this type of electricity, the electrons flow in only one direction. which of the following statements is correct? a. only student a is correct b. only student b is correct c. both of the two students are correct d. neither of the two students is correct
Answers: 1
image
Computers and Technology, 24.06.2019 17:00, harlon852
The length of time that a slide appears before automatically advancing to the next slide can be set in the timing group under the transitions tab. transition to this slide group under the transitions tab. timing group in the master slide view. transition to this slide group in the master slide view.
Answers: 1
Do you know the correct answer?
The exercise can be completed by following these steps:

1) Create a C program called ex6...

Questions in other subjects:

Konu
Mathematics, 10.01.2020 13:31
Konu
History, 10.01.2020 13:31