Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Why is MSP430's Stack Poniter(SP) always alligned to even address?

$
0
0

While I was reading through the MSP430's User's guide, I came to know that its stack pointer is alligned to even address. (Read Pg.189 of http://www.ti.com/lit/ug/slau208m/slau208m.pdf)

 

Question 1: Why is it so ? Why is the stack pointer alligned to even address?

 

 

 

Using msp430-gcc, I wrote a C program which contained a global 'char'(8 bits) array and which will print on UART the address location of each array element. What I found was that each array element was at '+1' from the previous address i.e

Address of a[0] is 2400

Address of a[1] is 2401

Address of a[2] is 2402

Address of a[3] is 2403

 

Question 2: Here I can see that all array element's are not alligned to even address i.e a[1], a[3] are at odd address. Arrays are stored in RAM and are accessed via stack pointer. How did the stack pointer store an odd address ?

 

 

 

As per my understanding, each address location in RAM can store 16bits of data(since MSP430) irrespective of even or odd address location. If I write the same above program with 'int'(16 bits) instead of 'char'(8 bits), then I get the array address '+2' i.e

Address of a[0] is 3400

Address of a[1] is 3402

Address of a[2] is 3404

Address of a[3] is 3406

 

Question 3: But my above experimentes showed that each address can store only 8 bits instead of 16. Why ?


Viewing all articles
Browse latest Browse all 2077

Trending Articles