View mode: basic / threaded / horizontal-split · Log in · Help
January 17, 2008
inline asm bug
Hello

I've found something that seems to a bug working with the inline assembler, but I'm not sure if it is the expected behavoir.

The reference to struct/unions don't work if there is nested structs/unions defined separately. Example:

union test {
	ulong var1;
	struct var2 {
		ubyte zz;
	}
}

union test2 {
	ulong var1;
	pp var2;	
}

struct pp {
	ubyte zz;
}

..
..
asm{
	..
	movzx EAX, test.var2.zz[ESI];
	movzx EAX, test2.var2.zz[ESI];
	..
}

The first line succeed but the second fails:

Error: need 'this' for address of var2
Error: need 'this' for address of var2
bad type/size of operands '*(& var2)'    

When, by error, I change the second line to 

	movzx EAX, test2.var2->zz[ESI];

the compiler crash.


Regards 
Blas Rodriguez Somoza
January 17, 2008
Re: inline asm bug
在 Thu, 17 Jan 2008 12:21:21 +0800,Blas Rodriguez Somoza  
<blas@puertareal.com> 写道:

> Hello
>
> I've found something that seems to a bug working with the inline  
> assembler, but I'm not sure if it is the expected behavoir.
>
> The reference to struct/unions don't work if there is nested  
> structs/unions defined separately. Example:
>
> union test {
> 	ulong var1;
> 	struct var2 {
> 		ubyte zz;
> 	}
> }
>
> union test2 {
> 	ulong var1;
> 	pp var2;	
> }
>
> struct pp {
> 	ubyte zz;
> }
>
> ..
> ..
> asm{
> 	..
> 	movzx EAX, test.var2.zz[ESI];
> 	movzx EAX, test2.var2.zz[ESI];
> 	..
> }
>

I think this should compile

> The first line succeed but the second fails:
>
> Error: need 'this' for address of var2
> Error: need 'this' for address of var2
> bad type/size of operands '*(& var2)'
>
> When, by error, I change the second line to
>
> 	movzx EAX, test2.var2->zz[ESI];
>
> the compiler crash.
>
>
> Regards
> Blas Rodriguez Somoza
>
>

there's no -> operator in D, but compiler shouldn't crash.


-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
January 17, 2008
Re: inline asm bug
Blas Rodriguez Somoza <blas@puertareal.com> wrote:

> Hello
>
> I've found something that seems to a bug working with the inline  
> assembler, but I'm not sure if it is the expected behavoir.
>
> The reference to struct/unions don't work if there is nested  
> structs/unions defined separately. Example:
>
> union test {
> 	ulong var1;
> 	struct var2 {
> 		ubyte zz;
> 	}
> }
>
> union test2 {
> 	ulong var1;
> 	pp var2;	
> }
>
> struct pp {
> 	ubyte zz;
> }
>
> ..
> ..
> asm{
> 	..
> 	movzx EAX, test.var2.zz[ESI];
> 	movzx EAX, test2.var2.zz[ESI];
> 	..
> }
>
> The first line succeed but the second fails:
>
> Error: need 'this' for address of var2
> Error: need 'this' for address of var2
> bad type/size of operands '*(& var2)'
>
> When, by error, I change the second line to
>
> 	movzx EAX, test2.var2->zz[ESI];
>
> the compiler crash.
>
>
> Regards
> Blas Rodriguez Somoza

To me it seems you are referencing the struct definitions/prototypes, not  
a struct instance. Try something like this:


union test {
	ulong var1;
	struct var2 {
		ubyte zz;
	}
}

union test2 {
	ulong var1;
	pp var2;	
}

struct pp {
	ubyte zz;
}

test foo; // new lines here
test2 bar;

..
..

asm{
	..
	movzx EAX, foo.var2.zz[ESI];
	movzx EAX, bar.var2.zz[ESI];
	..
}

Simen Kjaeraas
January 18, 2008
Re: inline asm bug
Simen Kjaeraas Wrote:

> Blas Rodriguez Somoza <blas@puertareal.com> wrote:
> 
> > Hello
> >
> > I've found something that seems to a bug working with the inline  
> > assembler, but I'm not sure if it is the expected behavoir.
> >
> > The reference to struct/unions don't work if there is nested  
> > structs/unions defined separately. Example:
> >
> > union test {
> > 	ulong var1;
> > 	struct var2 {
> > 		ubyte zz;
> > 	}
> > }
> >
> > union test2 {
> > 	ulong var1;
> > 	pp var2;	
> > }
> >
> > struct pp {
> > 	ubyte zz;
> > }
> >
> > ..
> > ..
> > asm{
> > 	..
> > 	movzx EAX, test.var2.zz[ESI];
> > 	movzx EAX, test2.var2.zz[ESI];
> > 	..
> > }
> >
> > The first line succeed but the second fails:
> >
> > Error: need 'this' for address of var2
> > Error: need 'this' for address of var2
> > bad type/size of operands '*(& var2)'
> >
> > When, by error, I change the second line to
> >
> > 	movzx EAX, test2.var2->zz[ESI];
> >
> > the compiler crash.
> >
> >
> > Regards
> > Blas Rodriguez Somoza
> 
> To me it seems you are referencing the struct definitions/prototypes, not  
> a struct instance. Try something like this:
> 
> 
> union test {
> 	ulong var1;
> 	struct var2 {
> 		ubyte zz;
> 	}
> }
> 
> union test2 {
> 	ulong var1;
> 	pp var2;	
> }
> 
> struct pp {
> 	ubyte zz;
> }
> 
> test foo; // new lines here
> test2 bar;
> 
> ..
> ..
> 
> asm{
> 	..
> 	movzx EAX, foo.var2.zz[ESI];
> 	movzx EAX, bar.var2.zz[ESI];
> 	..
> }
> 
> Simen Kjaeraas

In inline assembler this kind of reference must be to a struct/union definition. It means an offset from the address contained in the register.
Top | Discussion index | About this forum | D home