CS1021 Tutorial 3
Q1 Translate each of the following pseudo-code statements into a sequence of ARM assembly language instructions. Assume that x and y are signed integers and that x is in R1 and y in R2.
(i) if (x== 0)
x = x + 5;
(ii) if (x >= 5) x = 0;
(iii) x = 10; y = 5;
while (x > 0) { y = y*x;
x = x – 1;
}
(iv) if(x<9){
x = x + 1;
} else { x = 0;
}
(v) if (x > 9) { x = 0;
if (y > 9) { y= 0
} else {
y = y + 1;
}
} else {
x = x + 1; }
Q2 Write an ARM assembly language program to compute xy. Assume x and y are unsigned integers and that x is in R1, y in R2 and the result is stored in R0.
CS1021 Tutorial 2 2018 jones@scss.tcd.ie
1