# E91 - Embedded Systems, Asn 1

## Some Dissassembly

Back to Embedded Systems Page

Please contact me if there is a problem with this web page (e.g., errors, or sections that are unclear).

Consider the code below:

```#include  <msp430x20x3.h>

int xg[10] = {0, 1, -1, 2, -2, 3, -3, 4, -4, 5};

void main(void) {
int x[10] = {0, 1, -1, 2, -2, 3, -3, 4, -4, 5};
int i;

for (i=1;i<10;i++) {
x[0] += x[i];
}

for (i=1;i<10;i++) {
xg[0] += xg[i];
}

}```

Pertinent parts of the dissassembled code are in the file "E91Asn1Dissasembly.txt" shown below:

Figure out how the array x[] is referenced in the assembly language.  Count the number of cycles to execute the line: x[0] += x[i];  Recall that shifting a number to the left is multiplication by 2.

Figure out how the array xg[] is referenced in the assembly language.  Count the number of cycles to execute the line: xg[0] += xg[i];

### Task 4: (optional)

Write an assembly language program to perform the same function (i.e., take an array of length 10, and sum all elements into x[0]).  Compare the speed of your routine with the "C" routines.

### To turn in:

• Task 1: (10 pts) A brief (one paragraph) description of how x[] is accessed (addressing modes...).  Also add comments to the C code that implements x[0] += x[i];
• Task 2: (10 pts) A brief (one paragraph) description of how xg[] is accessed.  Also add comments to the C code that implements xg[0] += xg[i];
• Task 3: (5 pts - optional) Your well commented code.
• Task 4: (5 pts - optional) Your well commented code and some discussion about how much

Back to Embedded Systems Page

Please contact me if there is a problem with this web page (e.g., errors, or sections that are unclear).