home | |||
links |
|
||
developer's mag main page article part 1 part 2 part 3 part 4 part 5 part 6 part 7 part 8 part 9 |
6 - Digging DeeperA function can safely make use of registers r0-r7 and r15, but should leave all others alone (unless you are prepared to save and restore values). However, it isn't quite that simple, since some of the registers are used for parameters, starting from r0. In the case of our function, r0 contains the array pointer, while r1 contains the limit. This leaves us r2-r7 to use without cleanup worries, which is more than enough for our purposes. Here we've used r7 for our i counter, and initialized it to 3.Once in the outer loop, we next prepare for the inner loop: mov r7,t ; k=3*r7 rptr r7 add rp add rp mov t,r6The first step in the i loop is initializing k (which is register r6) in preparation for the inner loop. From our optimized C code, we know we can set it to 3*i, which is a simple matter of copying and then repeatedly adding r7 to t, placing the result into r6 Previous Section Next Section |
||
Copyright © 2001-2006 ebmDevMag.com - Legal Notice |