>Dr. Plank, > >I had a student ask me to clarify your answer for midterm question 1, but >I was a little baffled myself, so I couldn't. What I am not clear on is >why the first byte of s is located at fp-16 in your example. > >I would think that the chars would be organized from low to high >addresses, with fp-19 being the first and fp-4 being the last. However, I >could believe the compiler uses some other ordering such that fp-16 is the >first element, folled by 17, 18, 19, and then 12, 13 etc. I could also >believe that I am just confused. Could you clear this up for me a bit? So, suppose the program was: main(int argc, char **argv) { char s[4]; char *x; x = strcpy(s, argv[1]); puts(x); } Then it's pretty clear that you would start with ``push #8'', and if x is at fp, then s must start at fp-4: | | | | | | <----- sp fp-4 |s[0] |s[1] |s[2] |s[3] | fp | x | <----- fp Ok -- now suppose it were s[8]. We'd start with ``push #12'' and now we have s starting with fp-8: | | | | | | <----- sp fp-8 |s[0] |s[1] |s[2] |s[3] | fp-4 |s[4] |s[5] |s[6] |s[7] | fp | x | <----- fp So, with s[16] -- We start with ``push #20'' and get: | | | | | | <----- sp fp-16 |s[0] |s[1] |s[2] |s[3] | fp-12 |s[4] |s[5] |s[6] |s[7] | fp-8 |s[8] |s[9] |s[10]|s[11]| fp-4 |s[12]|s[13]|s[14]|s[15]| fp | x | <----- fp Jim Plank