Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 1st, 2008, 11:53 AM   #1
headzoo
Newbie
 
Join Date: Oct 2006
Posts: 14
Rep Power: 0 headzoo is on a distinguished road
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]
headzoo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Heap vs. Stack memory Eric the Red C++ 11 Oct 24th, 2006 6:18 PM
stack question bl00dninja C++ 9 May 8th, 2006 7:54 PM
stack query aloksave C 12 Sep 30th, 2005 4:26 PM
Smashing a stack in MIPS assembly code tsgrimey Assembly 2 Feb 27th, 2005 1:06 PM
Help with stack implementation ridley C++ 0 Feb 26th, 2005 2:26 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:33 AM.

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