首页 新闻 赞助 找找看

C#中的堆栈指针

0
悬赏园豆:30 [已关闭问题]

记得堆栈空间是从高地址向低地址伸展的,可为何我在.Net下编译后的程序地址确是由低向高增长的呢?  
   
  测试代码如下:  
          public   static   class   Test  
          {  
                  public   unsafe   static   void   Main()  
                  {  
                          int   x,   y;  
                          x   =   10;  
                          y   =   50;  
                          int*   pX,   pY,pZ;  
                          pX   =   &(x);  
                          pY   =   &(y);  
                          pZ   =   pX   -   1; //pZ想指向y  
   
                          Console.WriteLine("Address   of   x:   {0:X}",(uint)pX);  
                          Console.WriteLine("Address   of   y:   {0:X}",(uint)pY);  
                          Console.WriteLine(*pZ);  
   
                          Console.ReadKey();  
                  }  
   
          }  
   
  调试时的输出:(可以证明堆栈由高地址向低地址伸展)  
  Address   of   x:   3C4ECC4  
  Address   of   y:   3C4ECC0  
  50  
   
  可运行时的输出却变成了:(由低地址向高地址伸展了?!)  
  Address   of   x:   12F45C  
  Address   of   y:   12F460  
  14090491   <-变成了无效值了-_-!

 

 

请问是什么原因?

meade的主页 meade | 初学一级 | 园豆:150
提问于:2009-03-20 21:51
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册