SCC150

Example exam questions

Term(3) - Week: 24 or 25 – 2020/2021


QUESTION(1) : Architecture Topic

1.a This question involves your knowledge of binary, hexadecimal and decimal systems. Please, show the details of your working.

i- Give the 8-bit 2’s complement binary and hexadecimal representations of the decimal number +76.

ii- Give the binary and decimal values of the 8-bit 2’s complement hexadecimal number 0xE8.

iii- Calculate the 8-bit two’s complement representation of the following decimal numbers: a = 114, b = 17, c = −73 , then calculate using signed 8-bit two’s complement the following sums: b + c , a + c


1.b

i- Show using a circuit diagram how W can be implemented in 2-level sum of products form using AND gates followed by OR gates. Remember to include any NOT gates required since only uncomplemented input variables are available:

W = B’.C’ + A’.B.C + A.C.D’


ii- Using only NAND gates, draw the simplest circuit that generates the function:

F = (A.B + A’.B’).C.D + (A.C’+A’C).B.D + A’.C.D + A.B’.C.D


iii- Using Boolean algebra rules, simplify the following logic expression:

F = A.B + A.C’ + C + A.D + A.B’.C + A.B.C


1.c

i- In the circuit shown below, which basic logic function does this circuit generate? Please, show how you arrived at your answer.


ii- Design the circuit that implements the expression:

F = A’.B + A.B’.C’.(B + C)

and verify that it is equivalent to the following network:


iii- Minimize the logical functions in the maps below as sums of products.






QUESTION (2) : Assembly Topic

3.a What does the syscall instruction do? Discuss an example in which this instruction is useful.

    3.b The MIPS architecture provides a $zero register. What is the purpose of this register?


3.c Without using pseudo-instruction, write a MIPS program that loads the value 0xaaaabbbb into register $t1;

3.d Write a MIPS assembler program which carries out the following calculation:

x = 2*a - 4*b

The result x should be available in register $s0 at program completion. Please explain your register mapping. You can assume that a, b and c are present in registers (no loading from memory is required).


QUESTION (3) : Debugging – C Topic

3.a

i- Consider the following definition of a function:

void f(int *x)

{

*x = *x + 1;

}

Show how to correctly call this function, using exactly two lines of code. The first line declares a variable and the second line calls f.

ii. Define a new type SF for function pointers to be used to point to function which takes a char pointer as argument and returns a pointer to void.


3.b State whether these two declarations are the same or different.

int *n[7]

int (*n)[7]


3.c A function strcpy is required which copies the char content of a null terminated string into a char array. The strcpy function takes two c char arrays, dst and src, and copies all character up to and including the null character from the src array into the dst array. The function should return the number of character copied from the source array into the destination array, including the null character. Your implementation can assume that the dst array always has sufficient space to store the content of the src array. 

int strcpy(char* dst, const char *src) {

<< YOUR CODE >>>

}


QUESTION(4)

4.a

i- Give the 32-bit IEEE 754 representation of the following floating point numbers as 8 hexadecimal digits: −1.125, 385

(Reminder: The 32 bits are used as follows: Bit 1: sign of mantissa, bits 2-9: 8-bits of exponent in excess 127, bits 10-32: 23 bits for magnitude of mantissa.)

ii- Express IEEE 754 single precision number 1001 0101 1110 1101 0001 0000 0010 0111 in decimal scientific notation (e.g., 6.02 x 1023).

iii- How does the technique of pipelining increase performance? Explain the increased instruction throughput, compared with a multicycle non-pipelined processor. Does pipelining reduce the execution time for individual instructions? Why?


4.b    Please write a MIPS assembler program which has equivalent functionality to the following c code. At program termination the result should be available in $s0.

int a=0,i;

for (i=0;i<10;i++){

a=a+10;

}

4.c Consider the following sequence of operations on a stack:

stack_t* s = stack_create();

push(s,1);

push(s,2);

push(s,3);

printf("%d", pop(s));

push(s,4);

push(s,5);

push(s,6);

printf("%d", pop(s));

printf("%d", pop(s));

push(s,7);


What will be the state of the stack in the end?. Show the intermediate steps of the computation.