这是我在一篇文章中看到的图片。
我百度查了下,内存中的栈,高位地址在上
,每次压栈(int这类),都会将地址减去1个字节,然后将值放入栈。
但是这张图,在对操作数栈
做压栈操作的时候,却从底下往上放了
。不知道是我理解错了,还是作者的一个失误。
谢谢指点
迷茫2017-04-18 10:52:18
I looked at other pictures in this article, and the pictures involving 操作数栈
are all from bottom to top
大家讲道理2017-04-18 10:52:18
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