java - jvm中操作数栈的高位地址在上面还是下面
高洛峰
高洛峰 2017-04-18 10:50:18
0
2
675
  • 这是我在一篇文章中看到的图片。

  • 我百度查了下,内存中的栈,高位地址在上,每次压栈(int这类),都会将地址减去1个字节,然后将值放入栈。

  • 但是这张图,在对操作数栈做压栈操作的时候,却从底下往上放了。不知道是我理解错了,还是作者的一个失误。

  • 谢谢指点

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
迷茫

I looked at other pictures in this article, and the pictures involving 操作数栈 are all from bottom to top

大家讲道理

First of all, if int a and int b are continuously stored in the stack, then the memory address of b must be 4 bytes larger than the address of a, not 1 byte!

As for big endian mode or little endian mode, let’s start with binary. The minimum storage unit of data in the stack is bytes, and the storage in bytes is fixed in little endian mode!

The same hexadecimal data 0x3F00 is stored in the order 00 3F in the little endian mode, and in the big endian mode the storage order is 3F 00. To put it bluntly, it means whether the low-order bytes are stored first or the high-order bytes are stored first.

The storage mode of Java is related to the computer's CPU, but regardless of big-endian or little-endian, the storage mode and analysis are also opposite. That is to say, the calculation result of the same int is the same regardless of big-endian or little-endian storage.

Please correct me if there are any errors or omissions in your answer

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!