This page does not represent the most current semester of this course; it is present merely as an archive.
Question 1
nop
Question 2
nop
Questions 3–6
extraneous %, 0x, etc OK.
Correct answers:
Question 7
This code (a) changes %rsp
and (b) jumps to flub
. Hence,
Question 8
4
6
Question 9
16
, half for 12
Question 10
our
The following errors are in the code:
*array
not *ans
Question 11
22
Question 12
ans
Question 13
Question 14
An example correct solution:
int i = 0;
:
loopif (i >= n) goto end;
if (i % x == 0) y *= i;
if (i % x != 0) z += 1;
+= 1;
i goto loop;
: end
The if/else can be done as either of
if (i % x == 0) y *= i;
if (i % x != 0) z += 1;
or
if (i % x == 0) goto ifcase;
+= 1;
z goto endif
:
ifcase*= i;
y : endif
And the loop can be done as either of
int i = 0;
:
loopif (i >= n) goto end;
// if goes here
+= 1;
i goto loop;
: end
or
int i = 0;
goto guard;
:
loop// if goes here
+= 1;
i :
guardif (i < n) goto loop;
Question 15
a
, b
, and d
(half if one left, 0 if all);c
(all or nothing)Question 16
Question 17
Question 18