程序代写代做代考 assembly Monday, 24 April 2017

Monday, 24 April 2017

2.00 ppm – 4.00 pm

(Duration: 2 hours)

DEGREES OF MSc, MSci, MEng, BEng, BSc,MA and MA (Social Sciences)

System and Networks

Answer ALL Questions

This examination paper is worth a total of 60 marks

The use of a calculator is not permitted in this examination

INSTRUCTIONS TO INVIGILATORS
Please collect all exam question papers and exam answer scripts

and retain for school to collect. Candidates must not remove exam

question papers.

CONTINUED OVERLEAF Page 1

1. (a) In a 16-bit two’s complement code what are the codewords for:

i. 255
ii. -255

Express your answers in hexadecimal.
[3]

(b) What is meant by an overflow in a numeric code? Give an example of an addition that overflows
in the 16-bit two’s complement code but not in the 16-bit unsigned code.

[2]
(c) Suppose the Sigma16 instruction MUL R1, R2,R3 is executed with $FFFF in R2. Recalling that MUL works

exclusively with two’s complement numbers, what are the smallest (most negative) and largest (most
positive) values that R3 can contain which will NOT produce an overflow?

[2]
(d) A Sigma16 system has an array X of n 16-bit signed numbers in memory. Write an assembly language

program to add the absolute values of all elements in X storing the result in a variable ABSUM.
(Note that the absolute value of a number, x, is equal to x, if x ≥ 0, but equal to -x if x < 0.) [7] (e) Would your program work for all two’s complement array elements? [2] (f) What is the maximum value that ABSUM can have without overflow occurring? What is the maximum value that can be added to ABSUM at any one time? Given that Sigma16 does not detect unsigned or signed overflows, using these facts or otherwise, devise a test that a programmer could use to determine whether overflow has occurred or not? (Describe what you would test for, but do not write the code). [4] For reference, this is part of the instruction set of the Sigma16 CPU. lea Rd, x[Ra] Rd:= x +Ra load Rd, x[Ra] Rd:= mem[x +Ra] store Rd, x[Ra] mem[x +Ra]:=Rd add Rd,Ra,Rb Rd:= Ra+Rb sub Rd,Ra,Rb Rd:= Ra-Rb mul Rd,Ra,Rb Rd:= Ra*Rb div Rd,Ra,Rb Rd:= Ra/Rb cmplt Rd,Ra,Rb Rd:= RaRb
Rd:= NOT Ra

jumpf Rd, x[Ra] If Rd=0 then PC:=x+Ra
jumpt Rd, x[Ra] If Rd<>0 then PC:=x+Ra
jal Rd, x[Ra] Rd:= pc, pc: =x +Ra
trap Rd,Ra,Rb PC:= interrupt handler
jump x[Ra] PC:= x +Ra

END OF EXAMINATION PAPER Page 2

2 (a) Explain the difference between a memory cycle and an instruction cycle. Explain also how the two ideas

are related.
[4]

(b) The following Sigma16 instructions have the same effect:

LEA R1,0[R0];
ADD R1,R0,R0.

Using your knowledge of Sigma16, give two reasons why the second might be preferable to the first and
justify your answer.

[4]
(c) With the aid of a diagram, identify the main components of a von Neumann CPU, their function and how

they are connected.
[6]

(d) With reference to the components identified in (c) outline the sequence of events involved in the

execution of the instruction: LOAD R1,5[R2].

[6]

3. (a) What is meant by the term packet switching? Give two reasons why most packet protocols limit packet
size?

[4]

(b) What is the difference between a switched and a broadcast network? Give one advantage of each.
[4]

(c) How do IP packets inform routers of their intended destinations? Explain how the packets are then

forwarded and how the mechanism to achieve this adapts to changing conditions in the Internet.

[5]

(d) Give one reason why attempting to adapt the routing mechanism to changing Internet conditions, as
suggested in (c), might cause a problem.

[1]

(d) What difficulties might be encountered in using IP to carry streamed video and how might these be
overcome? Discuss additional difficulties that might apply to IP based telephone conversations and to IP
remote control of a robot vehicle? In each case suggest what might be done to tackle the difficulties you
identify.

[6]