I think the stack will pile up from the larger memory address to the smaller memory address, but if it overflows, will the memory on the other side of the stack be rewritten?Or will the stack be rewritten in the direction in which the stack is growing, which is less than the stack limit?
memory-management stack
Stacking toward smaller memory addresses
Not necessarily. Is there a case where the stack does not stack toward a lower address?
Are addresses less than the stack limit rewrites?
Well, that's usually the case.Modern CPU/OS has a memory protection mechanism, so you may not be able to rewrite itself outside of the stack (=doesn't break or break anything).
Assuming the stack goes from the 0x2000
address to a smaller address on a 16-bit CPU,
0x1000
, the stack overflow would destroy around the 0x0FFE
address (=minimum address)0x0000
, it would destroy (=destroy large addresses) around the 0xFFE
address.Well, there are both.So if you don't assume a specific processing system, everything will be fine.
© 2024 OneMinuteCode. All rights reserved.