CS30 Exam Winter 2001: Topics and Instructions - Prof. Richard Ord, Exams of Computer Science

The title, signature, and instructions for the cs30 final exam held in winter 2001. The exam covers various topics related to computer science, including number systems, binary addition, leaf subroutines, local variables, sparc subroutines, floating point, linkage, scope, lifetime, data, machine instructions, and alu and control unit. The document also includes instructions for filling in the blanks and performing sparc assembly instructions.

Typology: Exams

Pre 2010

Uploaded on 03/28/2010

koofers-user-d7j
koofers-user-d7j ๐Ÿ‡บ๐Ÿ‡ธ

5

(1)

9 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Name _________________________
Signature_______________________
cs30x_______
CSE 30
Winter 2001
Final Exam
1. Number Systems ___________________ (15 points)
2. Binary Addition/Condition Code Bits/Overflow Detection ___________________ (12 points)
3. Branching ___________________ (20 points)
4. Bit Operations ___________________ (10 points)
5. Leaf Subroutine ___________________ (20 points)
6. Local Variables, The Stack, and Return Values ___________________ (20 points)
7. SPARC Subroutines and Calling Convention ___________________ (15 points)
8. Floating Point ___________________ (12 points)
9. Linkage, Scope, Lifetime, Data ___________________ (31 points)
10. Machine Instructions ___________________ (20 points)
11. I/O & Instruction Speed ___________________ (8 points)
12. ALU & Control Unit ___________________ (8 points)
13. Miscellaneous ___________________ (12 points)
SubTotal ___________________ (203 points)
Extra Credit / C Tricks ___________________ (8 points)
Total ___________________
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download CS30 Exam Winter 2001: Topics and Instructions - Prof. Richard Ord and more Exams Computer Science in PDF only on Docsity!

Name _________________________

Signature_______________________

cs30x_______

CSE 30

Winter 2001

Final Exam

**1. Number Systems ___________________ (15 points)

  1. Binary Addition/Condition Code Bits/Overflow Detection ___________________ (12 points)
  2. Branching ___________________ (20 points)
  3. Bit Operations ___________________ (10 points)
  4. Leaf Subroutine ___________________ (20 points)
  5. Local Variables, The Stack, and Return Values ___________________ (20 points)
  6. SPARC Subroutines and Calling Convention ___________________ (15 points)
  7. Floating Point ___________________ (12 points)
  8. Linkage, Scope, Lifetime, Data ___________________ (31 points)
  9. Machine Instructions ___________________ (20 points)
  10. I/O & Instruction Speed ___________________ (8 points)
  11. ALU & Control Unit ___________________ (8 points)
  12. Miscellaneous ___________________ (12 points)**

SubTotal ___________________ (203 points)

Extra Credit / C Tricks ___________________ (8 points)

Total ___________________

1. Number Systems

Convert EFCA 16 (2โ€™s complement, 16-bit word) to the following. (6 points)

octal _______________________________________

binary _____________________________________

decimal ____________________________________

Convert +277 10 to the following (assume 16-bit word). Express answers in hexadecimal. (3 points)

sign-magnitude _______________________________________________

1โ€™s complement _______________________________________________

2โ€™s complement _______________________________________________

Convert -194 10 to the following (assume 16-bit word). Express answers in hexadecimal. (6 points)

sign-magnitude _______________________________________________

1โ€™s complement _______________________________________________

2โ€™s complement _______________________________________________

4. Bit Operations

What is the value of %l0 after each statement is executed? Express your answers in hexadecimal.

set 0x87EFAB34, %l set 0x43CDDC65, %l xor %l0, %l1, %l

Value in %l0 is _______________________________________ (2 points)

set 0x87EFAB34, %l sra %l0, 10, %l

Value in %l0 is _______________________________________ (2 points)

set 0x87EFAB34, %l sll %l0, 11, %l

Value in %l0 is _______________________________________ (2 points)

set 0x56EFAB34, %l set 0xF1213121, %l bclr %l1, %l

Value in %l0 is _______________________________________ (2 points)

set 0x56EFAB34, %l set 0x8A423121, %l btog %l1, %l

Value in %l0 is _______________________________________ (2 points)

5. Leaf Subroutine

Write a full unoptimized SPARC assembly leaf subroutine to implement the checkRange() function from PA1. Return 1 to indicate value is in the range of minRange - maxRange; return 0 to indicate value is not in the range of minRange - maxRange. The ranges are inclusive. (20 points)

Function prototype for this function: int checkRange( long value, long minRange, long maxRange );

7. SPARC Subroutines and Calling Convention (1 point each)

The ret instruction adds ________ to ________ and stores this result in ________.

The call instruction stores the current value of ________ into ________.

The C family of languages using the calling convention of call-by-___________.

Passing pointers is a way to simulate call-by-___________.

From a high-level language perspective, the two most important parts of a Stack/Call Frame are areas to store

____________________ and ____________________.

In the SPARC architecture, we pass the first _______ arguments to a function in %______ - %______.

Does a leaf subroutine have a Stack/Call Frame? ________

Does an open subroutine have a Stack/Call Frame? ________

Does a closed subroutine have a Stack/Call Frame? ________

8. Floating Point

Convert -54.375 10 (decimal fixed-point) to binary fixed-point ( binary ) and single-precision IEEE floating-point

( hexadecimal ) representations.

binary fixed-point __________________________________ (2 points)

IEEE floating-point __________________________________ (4 points)

Convert 0x42C64000 (single-precision IEEE floating-point representation) to fixed-point decimal.

fixed-point decimal __________________________________ (6 points)

9. Linkage, Scope, Lifetime, Data

For the following program fragment, specify what C runtime area/segment will be used for each variable defini- tion or statement: (31 points โ€” 1 point each)

int a; ______________

static int b = 4; ______________

int c = 20; ______________

static int d; ______________

static int fubar( int e ) { ______________ (fubar) ______________ (e)

float f = 420.420; ______________

int g; ______________

static int h = 20; ______________

static int *i; ______________

i = (int *) calloc( 3, sizeof(int) ); ______________ (where i is pointing)

... }

Fill in the letter corresponding to the correct Fill in the letter corresponding to the correct scoping/visibility for each of the variables: lifetime for each of the variables: A) Global across all modules/functions A) Exists from the time the program is loaded to linked with this source file. the point when the program terminates. B) Global just to this source file. B) Exists from the time function fubar() is called to C) Local to function fubar(). the point when fubar() returns.

a _______ a _______ b _______ b _______ c _______ c _______ d _______ d _______ e _______ e _______ f _______ f _______ g _______ g _______ h _______ h _______ i _______ i _______ fubar _______ fubar _______

12. ALU and Control Unit

Use the terms listed below to fill in the blanks. Terms may be used more than once. (1 point each)

The Control Unit gets its commands by ___________________ instructions from the ___________________.

The brains of the CPU is the ___________________ while the work is done by the ___________________

which gets its operands from and stores its results in ___________________.

___________________ are used by the Control Unit to tell the other part of the CPU what to do.

The ALU has direct access to the ___________________ to read/write the ___________________ with instruc- tions like bne and addcc.

Tri-State device(s) condition code bits Control Unit L1 cache Arithmetic Logic Unit (ALU) L2 cache CPU Register(s) Translation Lookaside Buffer (TLB) Program Counter (PC) Memory Management Unit (MMU) Instruction Register (IR) input enable Bus(es) output enable Control Signal(s)/Line(s) combinational logic circuit/gate(s) Process Status Register (PSR) sequential logic circuit/gate(s) pipeline/pipelining synchronous/synchronizing decode/decoding asynchronous/asynchronizing encode/encoding

13. Miscellaneous

List two advantages of Dynamic Linking over Static Linking. (4 points)

Put the following in the correct order/sequence using the numbers to the left of each word: (8 points)

  1. assembler 5. source code
  2. linker 6. loader
  3. compiler 7. preprocessor
  4. program execution 8. executable (.exe/a.out)

______ โ€”> ______ โ€”> ______ โ€”> ______ โ€”> ______ โ€”> ______ โ€”> ______ โ€”> ______

Extra Credit / C Tricks

Here is a stripped-down version of a program I wrote to print out the hex values of single precision floating point values and to print the single precision floating point value of hex values to double-check my floating point con- versions. For example, if I run the program on the command line as

a.out -5.5 0xC0B the output is -5.5 = 0xC0B 0xC0B00000 = -5.

The last argument to the two printf() statements is missing. Write the appropriate expressions for these parame- ters. No other code is allowed โ€” just expressions that would fit as a parameter expression. (8 points)

#include <stdio.h> #include <errno.h> #include <stdlib.h> #include <string.h>

int main( int argc, char *argv[] ) {

float f; unsigned long l; int i; char *endptr;

for ( i = 1; i < argc; ++i ) { if ( strchr( argv[i], โ€™.โ€™) != NULL ) { errno = 0; f = strtod( argv[i], &endptr ); if ( (errno == 0) && (endptr == โ€™\0โ€™) ) (void) printf( "%s = 0x%08X\n", argv[i], _______________________________ ); } else { errno = 0; l = strtoul( argv[i], &endptr, 16 ); if ( (errno == 0) && (endptr == โ€™\0โ€™) ) (void) printf( "%s = %g\n", argv[i], _______________________________ ); } } return 0; }

Scratch Paper

Scratch Paper