Computer Science 161.01

Homework 2

Due Wednesday, September 12th  at class time    

 

 

1. 44 points Do the following problems.  Show your work on each.

 

            Unsigned integer conversions:

 

            Convert 23 from a decimal integer to an 8-bit unsigned integer.

 

 

            Convert 160 from a decimal integer to an 8-bit unsigned integer.

 

 

            Convert the unsigned integer 10110100 from binary to decimal.

 

           

 

            Sign-and-magnitude conversions:

 

            Convert -23 from a decimal integer to an 8-bit sign-and-magnitude integer.

 

 

            Convert 32 from a decimal integer to an 8-bit sign-and-magnitude integer.

 

 

            Convert the sign-and-magnitude integer 10110100 from binary to decimal.

 

 

            Convert the sign-and-magnitude integer 01100000 from binary to decimal.

 

 

           

            Twos complement conversions:

 

            Convert -23 from a decimal integer to an 8-bit twos complement integer.

 

 

            Convert 84 from a decimal integer to an 8-bit twos complement integer.

 

 

            Convert the twos complement integer 10110100 from binary to decimal.

 

 

            Convert the twos complement integer 01100101 from binary to decimal.

 

             

 

 

 

2. 6 points The following is actually a hexadecimal representation of a program written for our favorite computer, the VSC-32. 

Though it looks cryptic, it is merely a program that adds the numbers 162 and 15 and displays the result. 

                       

25 A6 47 87 00 A2 0F

           

(a) Convert the hexadecimal to binary and list below what you obtained:

 

 

 

 

 

 

(b) Enter the program in binary using the VSC computer web site.  

Then “Load it and Go” to see what the program does. 

You’ll know you did well if you see that it reports 177 for its answer!

 

See if you can understand what the binary contents of Main Memory represent.

(You need not explicitly write anything for this part).