23.08.2015 Views

EECS 370 – Introduction to Computer Organization – Exam 1 w

EECS 370 – Introduction to Computer Organization – Exam 1 w

EECS 370 – Introduction to Computer Organization – Exam 1 w

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1. LC-2K Assembly [4 pts]You are given the following segment of LC-2K assembly code:.fill 21626880 //=0x014A 0000haltCurious <strong>to</strong> determine what this program does, you run it on your recently completed Project1simula<strong>to</strong>r. How many instructions does the simula<strong>to</strong>r execute in <strong>to</strong>tal? (Note: all registers areinitialized <strong>to</strong> zero)A. 0B. 1C. 2 (partial credit of 2 pts is given if you choose this answer)D. Infinite (the instruction translates <strong>to</strong> jalr 1 2)2. Variables in Memory [6 pts]You find the program below by the printer in the CSE lab. Somebody deleted all the variablenames! Fortunately, we still have the information below from the last compilation. Reconstructthe original program by filling in the blanks based on the information provided.Variable information:• x is 4 bytes and resides on the stack.• y is 8 bytes and resides on the stack.• *r is 10 bytes and resides on the heap.• *x is 8 bytes and resides on the heap.• z is 2 bytes and resides in the static section.• p is 20 bytes and resides in the static section.• r is 4 bytes and resides in the static section.• w is 4 bytes and resides in the static section.char *_r_;char _p_ [20];int _w_;int mynamelessfunction(double _y_){static short _z_;int *_x_;. . .. . ._r__ = (char *)malloc(sizeof(char) * 10);. . ._x__ = (int *)malloc(sizeof(int) * 2);}. . .Page 2 of 12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!