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

Tuesday 30 April 2019

Computing Science 1S

1. (a) Convert 1100 0011 to a decimal number, assuming binary representation.

(b) Convert 1100 0011 to a decimal number, assuming two’s complement

(c) Translate the statement  a := b*c d/b into Sigma16 assembly language, assuming that a, b, c, and d are 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.

(d) In the following program, variables k, i and n are integers, and x is an array of signed integers containing n elements.  Suppose the program is executed with these initial values:

n = 7

x = [9, -2, 13, 0, 45, -8, 7]

After the program executes, what are the values of k and x?

k := 0;

for i := 0 to n-1 do

{ if x[i] < 0

then { x[i] := -x[i]; }

else { k := k+1; } }

(e) Translate the program in part (d) into low level language.   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 of the form if b then goto label, where b is a Boolean expression.)

(f) Translate the low level program in part (e) into a complete program in Sigma16

assembly language.  Use data statements to define the initial values specified in part (d).

2. (a) Describe the behavior of the 1-bit register circuit (reg1) with data input x, control input load, and output r.

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

defined by the truth table below.  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

1

1

0

0

1

1

1

(c) Explain what could happen in a synchronous circuit if the clock speed is too fast.

(d) The following program takes two inputs: an integer x and a pointer header to a

list header.  The list is represented by nodes.   Each node is a record consisting of two words: the first word value is an integer, and the second word next is a           pointer to the rest of the list.  The last node in the list has nil in the next field (nil is represented by 0).  The value field of the list header is unused, and its next field points to the first node with a value (if any).

p := header;

q := p;

p := (*p).next;

done := false;

while not done do

if p=nil || x<(*p).value

then { new := avail;

avail := (*avail).next;

(*new).value := x;

(*new).next := p;

(*q).next := new;

done := true; }

else { q := p;

p := (*p).next; }

Suppose the program is given x=5 and header points to a header for a list       containing the initial values [3, 8, 9].  After the program executes, what is the value of the list that the header points to?

(e) Translate the program in part (d) 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.  Just write the instructions that implement the     algorithm, but not the data statements.

(f) Define the term concurrent processes.  Explain how concurrent processes are implemented, and how the system ensures that all process continue to run even if