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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 01:00, joedawg50
What is added to the < meta > tag to describe the encoding type?
Answers: 1
image
Computers and Technology, 22.06.2019 12:20, crodriguez87
Usually, when we sniff packets, we are only interested certain types of packets. we can do that by setting filters in sniffing. scapy’s filter use the bpf (berkeley packet filter) syntax; you can find the bpf manual from the internet. set the following filters and demonstrate your sniffer program again (each filter should be set separately): (a) capture only the icmp packet. (b) capture any tcp packet that comes from a particular ip and with a destination port number 23. (c) capture packets comes from or to go to a particular subnet. you can pick any subnet, such as 128.230.0.0/16; you should not pick the subnet that your vm is attached to.
Answers: 3
image
Computers and Technology, 22.06.2019 23:30, lexirandall19
Define a function printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. ex: printfeetinchshort(5, 8) prints: 5' 8"
Answers: 1
image
Computers and Technology, 22.06.2019 23:30, Molly666
What does 21 pilots middle aged name as a band 15 years prior to them naming their band 21 pilots?
Answers: 1
You know the right answer?
The exercise can be completed by following these steps:

1) Create a C program called ex6...

Questions in other subjects: