TheFuzz
TheFuzz

Reputation: 2623

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 the 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

Upvotes: 0

Views: 372

Answers (2)

user922475
user922475

Reputation:

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].

Upvotes: 1

gordy
gordy

Reputation: 9786

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

Upvotes: 1

Related Questions