Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Computing Science 1S

1.      (a)     Convert 1010 0010 to a decimal number, assuming binary representation.

[2]

 

(b)     Convert 1010 0010 to a decimal number, assuming two’s complement

representation.

[3]

(c)     Translate the statement  a := b - c*d into Sigma16 assembly language,     assuming that a, b, c, d are signed integer variables.  You do not need to write a   complete program, and you don’t need to write data statements for the variables. Just translate this one statement.

[5]

 

 

(d)     Translate the following high level language program fragment into low level         language.   The variables sum, i and n are signed integers, and x is an array of       signed integers containing n elements.  You do not need to define the variables or array, just translate the program code.   (The low level language contains               assignment statements, goto statements, and statements ofthe form if b then goto label, where b is a Boolean expression.)

 

sum := 0

i := 0

while i < n && x[i] > 0 do

sum := sum + x[i]

i := i + 1

 

[5]

 

(e)     Translate the program in part (d) into a complete program in Sigma16 assembly

language.  Use data statements to define the following initial values:  n = 4, x[0] = 7, x[1] = 2, x[2] = 0, x[3] = 5.  What is the value of sum when the program      terminates?

[10]

 


2.      (a)     Give the truth tables for the following logic gates: and2, or2, xor2.

[3]

 

(b)     Design a circuit that takes two inputs a and b, and produces one output x, which

is 1 ifthe two inputs have the same value, as shown in the truth table.  Implement

the circuit using any of the standard logic gates (inv, and2, or2, xor2).  You may   specify the circuit using any of the following notations (just use one): a schematic diagram, Boolean algebra, or Hydra notation.


a

b

x

0

0

1

0

1

0

1

0

0

1

1

1

 

[3]


 

(c)     Explain the purpose ofthe clock in a synchronous circuit.  Describe how a suitable clock speed for the circuit is determined.

[4]

 

(d)     The following program determines the sum ofthe elements and the number of     elements in a linked list, given a pointer p to the head ofthe list.  Each node is a   record consisting oftwo words: the first word “value” is an integer, and the          second word “next” is a pointer to the rest ofthe list.  The last node in the list has nil in the next field (nil is represented by 0).   Translate the program to Sigma16   assembly language.  You don’t need to write out the low level language version,   and you don’t need to define the variables or the linked list.

; given p = pointer to list

length := 0

sum := 0

while p /= nil do

length := length + 1

sum := sum + (*p).value

p := (*p).next

[10]


 

(e)     State what the processor does when an interrupt occurs.    Give two advantages of

using interrupts to catch errors (such as overflow or division by zero) rather than using instructions to test explicitly for the error.

[5]