Notice: MP1, the first machine problem, is due on Oct. 1! Exam 1 is Oct 4! There will be no class Mon. Sept. 23 (Yom Kippur) and I will not check my E-mail between late Sunday afternoon and late Monday evening.
unsigned int t = 100;
while (t > 1) {
if (t & 1) {
t = (t * 3) + 1;
} else {
t = t / 2;
}
}
output('STOP');
(Aside: The above program fragment does terminate for every positive
integer initial value of t that anyone has ever tried, but nobody has ever
proven that it terminates for all positive integers.)
ADDS R1,R1,1
ADDSI R1,1
Modify the code form problem 1 to detect overflow and output 'ERR!' instead
of the 'STOP' the code outputs normally. Overflow, in this case, means that
the result of multiplication or addition was greater than or equal to 2 to
the 32, since we're only concerned with unsigned values.
You may turn in one program listing incorporating problem 2 into your solution for problem 1.
struct rec {
int x,y;
} z[8];
Part B:
In terms of the above and your answer to part A, translate the following
code fragment to SMAL Hawk assembly language:
for (i=0;i<7;i++) {
z[i].x = z[i+1].y;
}