www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Inline assembler bugs

reply "Artem Rebrov" <ar_other mail.ru> writes:
Example:

void main()
{
   asm
   {
     mov EAX, offset q1; //#1
     lea EAX, [q1];      //#2
   q1: nop;
   }
}

line #1 generates "Error: .offset deprecated, use .offsetof".
line #2 generates "undefined identifier 'q1'"

DMC compiles the same example without errors, but #1 generates "mov EAX,0".

Probably documentation bugs (iasm.html):
1) Symbol $$ described as address instruction following the current  
instruction. Example from doc (jmp $$;) ouputs error "end of instruction",  
but "jmp $;" works (in dmc too).
2) Grammar fot the operands allows something like this "mov EAX%EBX+ECX,  
EDX-ESI+EDI". :)

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Feb 15 2006
parent "Walter Bright" <newshound digitalmars.com> writes:
"Artem Rebrov" <ar_other mail.ru> wrote in message 
news:op.s407k7zlncj208 comp...
 Example:

 void main()
 {
   asm
   {
     mov EAX, offset q1; //#1
     lea EAX, [q1];      //#2
   q1: nop;
   }
 }

 line #1 generates "Error: .offset deprecated, use .offsetof".
 line #2 generates "undefined identifier 'q1'"

Labels are in a separate symbol table from variables, hence they don't work in inline asm unless used as jmp or call operands.
 DMC compiles the same example without errors, but #1 generates "mov 
 EAX,0".

 Probably documentation bugs (iasm.html):
 1) Symbol $$ described as address instruction following the current 
 instruction. Example from doc (jmp $$;) ouputs error "end of instruction", 
 but "jmp $;" works (in dmc too).

Doc bug.
 2) Grammar fot the operands allows something like this "mov EAX%EBX+ECX, 
 EDX-ESI+EDI". :)

The grammar is a mess, unfortunately it resists conversion to something like bnf.
Feb 17 2006