这些nasm堆栈推送之间有什么区别?

时间:2011-07-12 05:11:36

标签: assembly stack nasm 16-bit

这是16位,实模式,NASM。

 ; ---- variables ------
    cursorRow db 1
 .
 .
 .

 ; what are the differences between these two pushes?
 push cursorRow ; is this the address of?

 push [cursorRow] ; is this the value of?

我在函数中更改此变量时遇到问题,其中cursorRow是一个参数。 我发布的一个问题是相关的:Updating variable that lives in the data segment from the stack and its segment

2 个答案:

答案 0 :(得分:1)

cursorRow是值,[cursorRow]是位置cursorRow的值。如果你需要将cursorRow的地址放在堆栈上,那么你需要按bp + 1或者变量的实际地址

答案 1 :(得分:1)

如果在数据部分中启动了cursorRow(不是[cursorRow]),它就像一个C指针。使用[cursorRow]将取消引用它并返回存储在那里的值,你必须在[cursorRow]前加上mov al, byte [cursorRow]之类的值的大小。