Enhanced Embedded Systems Midterm Exam 2
Enhanced Embedded Systems Midterm Exam 2
Instructions: Answer all questions. The questions test your ability to write efficient, correct ARM assembly code and
Question 1:
Write an ARM assembly code that divides a number in R0 by 4 using only bitwise shift operations. Store the result in R1.
Question 2:
Convert the following C code snippet into ARM assembly, ensuring minimal instructions:
int x = 5;
int y = x * 3;
Question 3:
Using only three instructions, implement a subtraction of 7 from a value in R0 and store the result in R1. Avoid using the
SUB instruction.
Question 4:
Analyze the following ARM assembly code and describe its purpose. Can you simplify it further?
MOV R2, #8
Question 5:
Write an ARM assembly loop to decrement R4 from 50 to 0 by 5 on each iteration and stop when it reaches zero.
Answer 2:
MOV R0, #5 ; x = 5
Answer 3:
Answer 4:
Answer 5: