asm
{
jmp label1;
mov EBX,EAX;
label1:
}
when i have label in the last line of my asm block would make the compiler fail to compiler it
and i wonder how can this kind of hack being done
asm
{
mov label1, EAX; //modify the code to get it run differently
label1: dw 00;
}
and also if i have a array item i want i can get the address directly
asm
{
mov ax, myarray[1];
}
Comment #1 by lio+bugzilla — 2006-11-02T08:20:20Z
[email protected] wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=474
>
> Summary: in ASM block last line can't be a label
> Product: D
> Version: 0.173
> Platform: PC
> OS/Version: Windows
> Status: NEW
> Severity: normal
> Priority: P2
> Component: DMD
> AssignedTo: [email protected]
> ReportedBy: [email protected]
>
>
> asm
> {
> jmp label1;
> mov EBX,EAX;
> label1:
> }
>
> when i have label in the last line of my asm block would make the compiler fail
> to compiler it
>
>
> and i wonder how can this kind of hack being done
> asm
> {
> mov label1, EAX; //modify the code to get it run differently
> label1: dw 00;
> }
Or,
label: nop;
> and also if i have a array item i want i can get the address directly
> asm
> {
> mov ax, myarray[1];
> }
I think you'd want "lea eax, myarray[1]".
L.
Comment #2 by davidl — 2006-11-03T01:18:05Z
consider this
class
{
int dynamicarray[];
void method()
{
asm
{
mov EAX,this; //failed;
}
asm
{
lea EAX, dynamicarray[0]; //without this this ain't gonna work properly
}
}
}
and consider this in a func bar
void bar()
{
int dynamicarray[];
asm
{
lea EAX,dynamicarray[1]; //this won't tell the address IMHO
}
}
and how to deal with dynamic array in ASM is a pain in ass in D
Comment #3 by bugzilla — 2006-11-09T03:38:31Z
This is the way it's supposed to work; a label is not a statement. To make it compile, add an empty statement:
asm
{
jmp label1;
mov EBX,EAX;
label1:
; // <== add this
}
Labels outside of asm blocks work the same way.
Also, if there are separate issues, please list them as separate items in bugzilla.
Comment #4 by bugzilla — 2006-11-09T03:42:10Z
int dynamicarray[];
asm
{
mov EAX,dynamicarray; // gets the length
mov EAX,dynamicarray+4; // gets pointer to the data
}