Ex2Winter97

advertisement
Computer Science 101
Survey of Computer Science
Exam 3 - Fall 2009
Name:
Pledged:
1. (35 points) Complete the following:
a. If we are using 5-bit unsigned numbers, then the largest possible number we can
represent is
. If we are using 5-bit sign-magnitude numbers,
then the largest possible number we can represent is
. If we are
using 5-bit two’s complement numbers, then the largest possible number we can
represent is
.
b. One major advantage of the two’s complement system over the sign-magnitude
system for signed numbers is
c. A logic circuit that has three inputs and two outputs with one output being a sum bit
and the other output being a carry bit is called a/an
d. If a multiplexor has 5 control lines, then it has
output line(s) and
input lines.
e. A major unit of the computer architecture in which we made use of a decoder circuit
was the
unit.
f. In order to store a new value in a memory cell, the address of the cell is placed in the
register, and the new value is placed in the
register.
2
g. If the MAR of a memory unit holds 32 bits, then the maximum number of cells for
the memory unit would be
. This would be
megabytes.
h. Using the assembly language for the hypothetical lab machine, assume that we have
memory locations with labels X, Y, Z. Starting over for each part, give a statement
or series of statements that would
i) Put a 0 in the memory location with label X.
ii) Replace the value stored at location X with the value stored at location Y.
iii) Display the value that is currently in the register R.
iv) Swap the values stored at the locations with labels X and Y.
v) Definitely put 100 into the CCR
i. Circle the statement types whose execution could possibly change the value in some
memory cell:
SUBTRACT, JUMPLT, COMPARE, STORE, LOAD, INCREMENT, IN,
OUT, CLEAR, JUMP
j. For each of the following relationships between people and charities (Heart Fund,
Salvation Army, Whaley Empty Pocket Fund, etc.) indicate whether it would most
likely be considered 1:1, N:1(or 1:N), or N:M
IsFavoriteOf indicating the charity is the favorite charity of the person
DonatesTo indicating the person donates to the charity
GaveMostTo indicating the person was the one who gave the largest
donation to that charity
DidNotGiveTo indicating the person did not give to that charity
3
2. (15 points) Convert the binary number 1011001 to decimal
a. Assuming that the number is an unsigned (positive) number.
b. Assuming that the number is a 7-bit sign magnitude number.
c. Assuming that the number is a 7-bit 2's complement number.
3. (10 points) Convert the decimal number 185 to
a. binary
b. hexadecimal
4
Assembly Language Table for use on following problems:
Numeric
Assembly Language
Op Code
Mnemonic
Op Code
0000
0001
0010
0011
0100
0101
0110
0111
LOAD X
STORE X
CLEAR X
ADD X
INCREMENT X
SUBTRACT X
DECREMENT X
COMPARE X
1000
1001
1010
1011
1100
1101
1110
1111
Mnemonic
JUMP X
JUMPGT X
JUMPEQ
JUMPLT
JUMPNEQ X
IN X
OUT X
HALT
4. (20 points) Using the assembly language for the hypothetical machine:
a. Write a complete assembly language program for a program that allows the user
to enter 2 numbers, say X and Y, and then outputs the value of 3X – Y + 5.
5
b. For this problem, you are to use the techniques covered in class to convert the
following pseudocode program to an assembly language program.
Pseudocode
Set Sum to 0
Set Count to 0
While Count < 100 do
Get Num
If Num>0 then
Set Sum to Sum + Num
End-of-loop
Print Sum
Stop
6
5. (20 points) The following are the tables together with their columns from our class
database:
Students(StudentId,LastName,FirstName,ClassYear,City,State,Birthdate,
AdvisorId,Term)
Faculty(FacultyId, LastName, FirstName, Phone, Email)
Interests(InterestId, InterestName, Category, URL)
Majors(MajorId, MajorName, Department, ChairId)
StudentInterest(StudentId, InterestId)
StudentMajor(StudentId, MajorId)
Give SQL query statements for each of the following
a. Give an alphabetical list with two columns for the state and city of students who
are taking the course this term. The list should be alphabetical by state, and by city
within state.
b. Give the names of the students who are advised by the faculty member with name
“Holt Merchant”.
7
c. Give a list of the names of students who listed “Guitar” as an instrument
(Category is Instrument) that they played.
Download