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

Tuesday 17 May 2022

CS1S Computer Systems

COMPSCI1018

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

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

(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.

(d)     Consider the following program:

 

load load add  store lea  lea

R1,mod[R0]  R2,instr[R1] R2,R2,R1

R2,instr[R0] R4,4[R0]    R5,2[R0]

instr

add  store trap

R3,R0,R0  R3,out[R0] R0,R0,R0

mod

data

0

out

data

0

Hand-execute the above program and report the final value of the out variable for the following values of mod (remember the following RRR operation codes: add 0; sub 1; mul 2; div 3):

- mod = 0

- mod = $0045

- mod = $1045

- mod = $2045

Explain what behaviour the code of this program is displaying, and in particular with the instruction with the instr label? Explain what kind of major problems this type of program can lead to when executed. Explain why this type of program is not recommended in terms of software engineering.

(e)     Consider two arrays named x and y that both contain n integers, where n is an

integer variable in memory. Write a Sigma16 assembly language program that  calculates the dot product of the two array and stores this sum in the variable     dotprod (i.e. dotprod := x0.y0 + x1.y1 + x2.y2 + …. + xn-1.yn-1). The program must work correctly for any nonnegative n and initial array elements. Don’t       forget to appropriately document your code with comments. You may assume   that the variables have been declared but not initialised. Your program should   exit cleanly.

2.      (a)     Define the behaviour of a 1-bit multiplexer circuit (the mux1 circuit): detail how many inputs are used by the circuit and how many outputs the circuit provides,  Write the truth table of the mux1 circuit. Explain how the multiplexer circuit      enables the creation of complex programs.

(b)    Design a circuit that produces the following truth table for inputs x, y, z and

output o. Draw the corresponding schema for the circuit.

 

(c)     Consider a synchronous circuit with a gate delay of 1ms and a critical path of 20 logic gates. What is the maximum value of the clock speed? What could happen if we use a higher clock speed?

(d)     Consider a personal banking system used to record series of expenses on             customers’ bank accounts. To store the transactions, a linked list data structure is used for each customer. Each node in that list contains three fields: value, an   unsigned integer containing the amount being debited from the account,              account_id, an unsigned integer used to identify the other party of the           transaction (e.g. a store charging the customer for a purchase) and next, a         pointer to the next node in the list.

i) Discuss the pros and cons of using a linked list to store these transactions instead of using an array.

ii) Write a high-level program that traverses the linked list and calculates the total amount of money spent at one store, given a pointer p pointing to the linked list containing transactions of the individual, and a binary number store representing the identification number of that store and corresponding to one of the numbers present in the account_id field of transactions.

iii) Translate this high-level language program to a low-level language. (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.)

iv) Translate this low-level program to a Sigma16 program.