The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RedXVII on March 22, 2006, 08:44:32 PM

Title: Quick Question: translate something from C
Post by: RedXVII on March 22, 2006, 08:44:32 PM
I know C pretty well. I cant get the C code im converting to compile  :'( so i thaught i'd just ask;
what does this C translate as in assembly,

functionname( (void**)&pData );

im more confused by the (void**) and what it represents.

Thanks  :U
Title: Re: Quick Question: translate something from C
Post by: asmfan on March 22, 2006, 09:17:46 PM
(void**) represents to pointer on pointer. For example you have a pointer on any data and abov means the addres of the pointer on data(&pData, as pData is (void*) type, then you get void**).
hope you understood me:),
Igor.
Title: Re: Quick Question: translate something from C
Post by: asmfan on March 22, 2006, 09:25:06 PM
in assembly it can be like this:
Code:
.data
var1  dd  ?
var2  dd  var1
.code
lea  eax, var2  ;eax is void** since it dereferenced twice points on var1
Title: Re: Quick Question: translate something from C
Post by: RedXVII on March 22, 2006, 11:27:31 PM
Errrr how many pointers is that

In your example, i presume var 2 points to var1.

Should i push pointer1 or pointer2?

Pointer1 -> pointer2 -> pData (-> Data)

So from your example - i should push pointer1, and make a new memory address for pointer2, right?

Thx  :U
Title: Re: Quick Question: translate something from C
Post by: asmfan on March 23, 2006, 07:46:58 AM
say var1 is Data, var2 is pointer on Data (void*) and eax is pointer on pointer (void**). Push the eax to get (void**) type.
Title: Re: Quick Question: translate something from C
Post by: RedXVII on March 23, 2006, 12:41:46 PM
Got it, its working.

Thx  :bg
Title: Re: Quick Question: translate something from C
Post by: asmfan on March 23, 2006, 12:49:21 PM
always welcome:)