Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Assembly (http://www.programmingforums.org/forum20.html)
-   -   Dereference Value on the Stack (http://www.programmingforums.org/showthread.php?t=14844)

headzoo Jan 1st, 2008 11:53 AM

Dereference Value on the Stack
 
Howdy all,
I'm kind of new to assembly, and I'm using NASM 2.00. I've learned that you can dereference a value from an address stored in a register, or in memory, by enclosing the memory address in brackets, like this:

mov eax, [memory_location]

As far as I can tell, this is similar to using * to dereference a pointer in C.

I can't figure out how to do the same for an address pushed on the stack, from inside a procedure.

Example:
:

        push memory_location
        call my_procedure
       
my_procedure:
        push ebp
        mov ebp, esp
       
        mov eax, [ebp + 8]


The last instruction will move the address stored at [ebp + 8] into the eax register. What I'd like to do is dereference the value stored at [ebp + 8], and store that in eax.

Can that be done in one instruction? Or do I have to do something like this:

:

        mov eax, [ebp + 8]
        mov edx, [eax]



All times are GMT -5. The time now is 2:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC