CS代考 CS 213 Spring 2009 – cscodehelp代写

Exam 1 Solutions
CS 213 Spring 2009

Description Decimal Binary
Bias 3 ——
Smallest Positive positive 1/16 000001
Lowest finite -14 111011
Smallest positive normalized 1/4 000100
—— -7/16 100111
—— 5/4 001101
—— -5/8 101001
—— 13(12) 011010

a) 32 bytes

b) 6 bytes

0xbfb2ffdc
0x0000000c

0x000000f3
0x000000d5

int switchfn(inta, longb) {

switch(A*b) {

return 24;

a= x + b*4;

return a+b;

return a/b;

return x==y;

void mystery_sort (long* array, long len)
long a, b, tmp;

while(len>0)

for(b=len-1; b>0; b–)
if(array[b]>array[a])

tmp = array[len];
array[len] = array[a];
array[a] = tmp;

Update 10/6/11 by Taerim Kim:
Although C was accepted as the solution in Spring 2009, none of the choices
for Problem 5 Question 11 are correct.

Enter new stack frame by saving old base pointer and
allocating space by subtracting from stack pointer

b)Fill into dissasembly of foo

0x8, 0xc, 0x10, 0x14
8, 12, 16, 20

The new foo is not saving the old ebp. This makes
the stack frame 4 bytes shorter

old new
—— ——
| args | | args |
| ret | | ret |
| ebp | ebp | |
| | | |
| | | |
| … | | … |
| | | |
|______| esp |______| esp

0x44, 0x48, 0x4c, 0x50
68, 72, 74, 80