程序集x86执行堆栈

1 x86 assembly

我需要在x86程序集中实现一个堆栈,所以我写了这个:

section .bss

my_stack: 
       resb 5
Run Code Online (Sandbox Code Playgroud)

但继续我的程序后,这个地址内的数据消失了

有一种更好的方法可以实现堆栈?????

sch*_*der 6

我不确定你想要什么,但是由于x86汇编语言提供了它自己的堆栈,为什么不使用它呢?

push reg ; push register reg to the stack
pop reg  ; pop register reg from the stack
         ; actual stack pointer = sp
Run Code Online (Sandbox Code Playgroud)

顺便说一下,你的代码只为变量保留了5个字节的空间,看看为什么你的数据会消失,程序的其余部分会很有趣.对堆栈只使用5个字节也很奇怪.