2011-07-12 102 views
0

這是16位,實模式下,NASM。這些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

+0

我認爲這些都將取決於你的彙編推cursorRow的*值*(你可以隨時拆卸文件肯定知道)。 'mov ax,offset cursorRow;推斧頭應至少推送地址。 'lds si,[cursorRow];推動ds;推si'應該推遠指針,但是我做了多段的16位程序已經有一段時間了。 – user786653

+0

我使用NASM,它沒有關鍵字作爲據我所知偏移。昨晚我得到了我的程序通過下面的指令推cursorRow的地址工作:'推cursorRow' – TheFuzz

+0

你看過nasmdoc?我記得有一段專門描述這部分與其他彙編器如MASM和TASM不同。 –

回答

1

cursorRow是值,[cursorRow]是位置cursorRow處的值。如果你需要把cursorRow的地址在棧上,那麼你需要推BP + 1或任何變量的實際地址

1

如果cursorRow(不[cursorRow])在數據部分被啓動,它是就像一個C指針。使用[cursorRow]將取消對它的引用和返回值存儲在那裏,你就會有前綴[cursorRow]與像mov al, byte [cursorRow]值的大小。

相關問題