Computer Organization Lab #1: Number Systems

  1. Create a new folder for this lab and copy Program Zero into it. The files binary.h and binary.c contain a C function named display_binary that display a 32 bit unsigned integer in binary. Modify the Makefile so binary.c is included in the build process. Modify the main program so that it prompts the user for an integer, prints that integer, and then uses display_binary to print that integer in binary.

  2. Using the program you created above, observe the binary representation of the values: 0, 1, -1, 65535, 2147483647, -2147483648, 4294967295. Do you get the results you expect?
  3. Modify library.asm to use an 'and' instruction to erase all bits except bits 8-23. Enter the same numbers as above and observe the results. Are they as you expect?

  4. Modify library.asm to use an 'or' instruction to set all bits 8-23. Enter the same numbers as before and observe the results. Are they as you expect?

  5. Modify library.asm to use an 'xor' instruction to invert bits 8-23. Enter the same numbers as before and observe the results. Are they as you expect?

  6. Display the bit pattern for -7.5e-10 as a 32 bit floating point value. To do this, use code such as:

            float value = -7.5e-10;
            ...
            display_binary(*(int*)&value);
          

    This strange looking code is necessary to force the floating point value to be treated as a 32 bit integer by display_binary. Be sure you can interpret the bits you are seeing.

Submit a file summarizing your observations. Include an explanation of any "surprising" results.


Last Revised: 2017-02-01
© Copyright 2017 by Peter C. Chapin <PChapin@vtc.vsc.edu>