what are the differences between these nasm stack pushes?
this is in 16 bit, real mode, NASM.
; ---- variables ------
cursorRow db 1
.
.
.
; what are the differences between these two pushes?
push cursorRow ; is this th开发者_运维技巧e address of?
push [cursorRow] ; is this the value of?
I'm having trouble altering this variable in function where cursorRow is a parameter. A question I posted that is relevant: Updating variable that lives in the data segment from the stack and its segment
cursorRow is the value and [cursorRow] is the value at location cursorRow. If you need to put the address of cursorRow on the stack then you need to push bp+1 or whatever the actual address of the variable is
If cursorRow (not [cursorRow] ) is initiated in the data section, it is like a C pointer. Using [cursorRow] would dereference it and return the value stored there and you'll have to prefix [cursorRow] with the size of value like mov al, byte [cursorRow]
.
精彩评论