Question: Write a C++ program to simulate a binary register that supports shift right and shift left operations. The original value stored in the register, its

Write a C++ program to simulate a binary register that supports shift right and shift left operations. The original value stored in the register, its size and what operation(s) to perform and how many times are all given via the command line arguments. Your program must use a class to simulate that register and it should use the stl vector to hold the value of the bits in the register. You must do this work, as any other assignment in this class in Linux and using g++ compiler. You must turn in ONLY ONE UNCOMPRESSED TEXT FILE (NO INCLUDES, NO BINARIES): the c++ file named shiftregister.cpp ARGUMENTS MUST BE SUPPORTED IN ANY ORDER. by default your register must inject 0 values unless told otherwise via command line arguments. Here are some of the parameters to support as your command line arguments: -i 010101: Initial values stored in your register. -s 6: Specifies the number of bits in your shift register. -r 2: shift the register right by two positions. -l 3: shift left register by 3 positions. -v 1: value to inject in vacated bits if other than default. -p: prints the value of bits in your register after performing all the operations. Bits must be printed as a non-spaced string of 0 or 1s and terminated by a new line. Multiple operations may be specified and they must be performed in the order specified in the command line argument list. Any violation of the specs is likely to result on a zero grade especially if they prevent your program from compiling or running without core dumps. VERY IMPORTANT: your program must return 0 on success and -1 on failure, not following this direction will result in zero credit in the full assignment.

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!