Review


Know the Concepts

  • Convert the decimal number 5,294 to binary.

  • What number does 0x0234aeff represent? Specify in binary, octal, and decimal.

  • Add the binary numbers 10111001 and 101011.

  • Multiply the binary numbers 1100 1010110.

  • Convert the results of the previous two problems into decimal.

  • Describe how AND, OR, NOT, and XOR work.

  • What is masking for?

  • What number would you use for the flags of the open system call if you wanted to open the file for writing, and create the file if it doesn't exist?

  • How would you represent -55 in a thirty-two bit register?

  • Sign-extend the previous quantity into a 64-bit register.

  • Describe the difference between little-endian and big-endian storage of words in memory.

Use the Concepts

  • Go back to previous programs that returned numeric results through the exit status code, and rewrite them to print out the results instead using our integer to string conversion function.

  • Modify the integer2string code to return results in octal rather than decimal.

  • Modify the integer2string code so that the conversion base is a parameter rather than hardcoded.

  • Write a function called is_negative that takes a single integer as a parameter and returns 1 if the parameter is negative, and 0 if the parameter is positive.

Going Further

  • Modify the integer2string code so that the conversion base can be greater than 10 (this requires you to use letters for numbers past 9).

  • Create a function that does the reverse of integer2string called number2integer which takes a character string and converts it to a register-sized integer. Test it by running that integer back through the integer2string function and displaying the results.

  • Write a program that stores likes and dislikes into a single machine word, and then compares two sets of likes and dislikes for commonalities.

  • Write a program that reads a string of characters from STDIN and converts them to a number.




Programming from the Ground Up
Programming from the Ground Up
ISBN: 0975283847
EAN: 2147483647
Year: 2006
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net