CS273

Quiz 4 Solution

 

Put your social security number in the right hand corner of the page.  Please do not put your name anywhere on this quiz.  Failure to follow these instructions will cost you 1 point on the quiz.  Note: Be sure to show all your work and no calculators. You will have until the end of class to complete the quiz.  Description: `2C’ means two’s complement format.

 

1.      (2 points) Add the following two 2C binary numbers:

       Note: Your answer should be in 2C binary (radix 2).
        
                  11111110

               + 10000001
                --------------

   1- CO      011111112C

 

 

       Is a 2C overflow produced?  Justify your answer.

        Yes, the numbers that are being added are negative (MSB – 1); the answer is a positive

                (MSB – 0) number.

 

 

2.      (2 points)

a)      What port are the motors on for the HC11 board? Port B
What is the address for that port (0.5 extra credit)?   $1004

b)     What port are the digital input sensors on for the HC11 board? Port C
What is the address for that port (0.5 extra credit)?  $1003

c)      The following two lines of code are from the sample program given in class:

 

        org    RESET

        fdb     start

 

 

 

What do these two lines of code do?   They set the start address for the reset

                                                             vector.

 

What is the value of the variable constant `RESET’? $fffe



3.      (3 points) Use the multiplication algorithm (with table) to convert 111101102 (this binary number is in 2C form) to radix base number 10 (decimal):

 

 

First: do the two complement algorithm:            a)  11110110 -> 00001001

                                                                             b) + 00000001 -> 000010102

 

Second:  Table

 

                Old       Digit         New        Radix

                   0            0              0               2
                   0            0              0               2
                   0            0              0               2
                   0            0              0               2
                   0            1              1               2

                   2            0              2               2

                   4            1              5               2

                 10            0             10

 

Third:  Remember that MSB of 2C binary number was 1 so final answer is:    -1010

 

 

4.       (3 points) Use the division algorithm (with table) to convert –5310 to 2C binary form:
Note: You can go through hexadecimal or just directly to binary.

 

I. Going through hexadecimal

 

First: Division Table

 

          Old     Radix         New        Digit

            53          16             3              5

              3          16             0              3

 

Second: Two’s complement algorithm

 

            3516                         f – 3            f – 5

                                       c                 a

                              +       0                 1

                               ----------------------

                                        c                 b

 

Third:  convert to binary

                                        c                 b

1100            1011  ->       110010112C

 

 

II. Going directly to binary

 

First: Division Table

 

          Old     Radix         New        Digit

            53            2            26             1

            26            2            13             0

            13            2             6              1

             6             2             3              0

             3             2             1              1

             1             2             0              1

 

Second: Two’s complement algorithm

 

a)      00110101 ->  11001010

b)      + 00000001 -> 11001011 ->       110010112C