Vous êtes sur la page 1sur 2

ELEC2142

1
The University of New South Wales
ELEC2142: Embedded Systems Design
Tutorial 2 ARM Architecture & Data Processing

1. Consider the ARM Processor architecture. Answer the following questions.


a) How many registers are visible to the programmer?
b) What is the size of these registers?
c) If the content of register R2 is 134, draw a picture to show the placement of the
number 134 in the register bits.
2.
a) List and explain the different instruction categories for the ARM architecture.
b) Explain what is meant by a load-store architecture.
c) Briefly explain the steps involved in the fetch-decode-execute cycle.
3. Consider the assembly code below. Provide a comment for each line of assembly
instruction.
If register R2 contains 23, what are the contents of registers R1-R4 after execution of
all the assembly instructions?
mov r1, r2
add r3, r1, r2
and r4, r3, r2
orr r4, r3, r4
4. Consider the C code below.
a) What is the output of the printf statements?
b) What is the output of the printf statements if a = 0x7722?
#include <stdio.h>
int main(void) {
short a = 0xDEE5;
char b;
b = a;
printf(short = %d\n, a >> 1);
printf(char = %d\n, b >> 1);
return 0;
}

ELEC2142

5. Consider the ARM Assembly code:


mov a1, v1, ror #8
a) Write a suitable comment for this instruction to explain what is does.
b) If v1 = 0xEEBAE213, what would register a1 contain after execution of this
instruction?
c) Write equivalent C code for this instruction. In your answer, consider whether the
variable representing the register v1 is a signed or unsigned int.
6. Using addition, subtraction, and shift operations, write down ARM Assembly code to
implement the following multiplications. You can assume that the registers v1 and
v2 represent the variables a and b respectively.
a = 35*b
a = 100*b
a = 1000*b
7. Consider implementing the discrete-time equation,
y(n) = 3y(n - 1) + 12y(n - 2)
for n = 0, 1,. This equation states that the new value of y, called y(n), is
equal to 3 times the first old value of y, called y(n-1), plus 12 times the second
old value of y, called y(n-2). The index n acts as a discrete time index. For
example, if we set y(0) = 0, and y(1) = 1, then the signal y would evolve
according to:
y(2) = 3y(1) + 12y(0) = 3 1 + 12 0 = 3
y(3) = 3y(2) + 12y(1) = 3 3 + 12 1 = 21
y(4) = 3y(3) + 12y(2) = 3 21 + 12 3 = 99
...
Write down ARM Assembly code that implements just one (1) iteration of this
equation, that is, for just one value of n. Assume that the registers v1, v2, and v3,
are associated with the variables y(n), y(n-1), and y(n-2). For this question, as
you are only implementing one iteration, the value of n is irrelevant, and is not
needed in the Assembly code. Similarly, your code need not involve any memory, just
the three registers. Keep in mind that a complete iteration will need to include
updating the old values.