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:

Task 1:

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.

Task 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 3: (optional)

Add comments to the rest of the dissassemble code.

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:

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).