Before this lab, we need read README carefully.
In this lab, our goal is to modify bits.c so that it passes all the tests in btest. And we can't violating any of the coding guidelines.
We can use dlc compiler to automatically check our version fo bits.c for compliance with the coding guidelines.
If there are no problems with code, ./dlc bits.c
returns silently. Otherwise it prints messages that flag any problem.
And we can run ./dlc -e bits.c
to print counts of the number of operators used by each functions.
Then, Testing with btest, which will test our code for correctness by running millions of test case on each function.
make btest
./btest
And we will need to recompile btest each time we change our bits.c program.
If we want to get rid of the old version of btest and generate a new one, we could use the commands: make clean
.
But btest does not check code for compliance with the coding guidelines. Use dlc to do that.
I write a shell script auto_test.sh
so that you can test quickly by run this script.
And I limited the time is 20 seconds, because the last function may exceed time in some environment if limits is 10.
Also, I suggest you change the var TIMEOUT_LIMIT
of btest.c
from 10 to 20.
ishow
and fshow
programs to help we decipher integer and floating point representations respectively.
ONLY can use following:
- Integer constants 0 through 0xFF, inclusive. Not allowed to use big constants such as 0xFFFFFFFF.
- Function arguments and local variables.
- Unary integer operations ! ~
- Binary integer operations & ^ | + << >>
And FORDID to:
- Use any control constructs such as: if, do, while, for, switch, etc.
- Define or use any macros.
- Define any additional functions in this file.
- Call any function.
- Use any other operations, such as ||, &&, -, ?:
- Use any form of casting.
- Use any data type other than int.
And ASSUME that machine:
- Uses 2s complement, 32-bit representations of integers.
- Performs right shifts arithmetically.
- Has unpredictable behavior when shifting if the shift amount is less than 0 or greater than 31.
- Allowed to use looping and conditional control.
- Allowed to use both ints and unsigneds.
- Allowed to use any arithmetic, logical, or comparison operations.
- Forbidden to define or use any macros.
- Forbidden to define any additional functions.
- Forbidden to call any functions.
- Forbidden to use any form of casting.
- Forbidden to use any data type other than int or unsigned.
- Forbidden to use any floating point data types, operations, or constant.