www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1829] New: Inline assembler cannot get label addresses

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1829

           Summary: Inline assembler cannot get label addresses
           Product: D
           Version: 1.026
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: burton-radons shaw.ca


The inline assembler can't read label addresses. This makes it impossible to do
certain low-level tasks. For example, this code is rejected:

        asm
        {
        label:
                push label;
        }

With the error "undefined identifier 'label'". Given that it's blocking me,
I've given this major severity.


-- 
Feb 12 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1829





------- Comment #1 from thomas-dloop kuehne.cn  2008-02-25 05:08 -------
Added to DStress as
http://dstress.kuehne.cn/run/a/asm_lea_03_A.d
http://dstress.kuehne.cn/run/a/asm_lea_03_B.d


-- 
Feb 25 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1829


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |minor




------- Comment #2 from bugzilla digitalmars.com  2008-03-04 02:01 -------
Here's how to push a label on the stack:

    call L1 ;
 L1:

Because the workaround is straightforward, I'm going to lower the priority.
It's not likely to get fixed soon, as it's been a limitation of the inline
assembler for 15 years. :-(


-- 
Mar 04 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1829





------- Comment #3 from burton-radons shaw.ca  2008-03-10 14:45 -------
That's a bizarre workaround. If I needed to get the address of a block of code
(such as an exception handler) I'd have to do something like this:

  call grab_exception_handler_address; // Grab the exception handler and put it
in EAX.
  ...

grab_exception_handler_address:
  // Try to make it as thread-safe as possible to tell the exception handler
we're pulling an address.
  mov EAX, 0xDEADBEEF;
  mov ECX, 0xBEEFDEAD;
  mov EDX, 0x12345678;
  call exception_handler;
  mov EAX, [ESP];
  ret;

exception_handler:
  test EAX, 0xDEADBEEF;
  jne exception_handler_body;
  test ECX, 0xBEEFDEAD;
  jne exception_handler_body;
  test EDX, 0x12345678;
  jne exception_handler_body;
  // Pulling an address, do nothing.
  ret;
exception_handler_body:
  // Actually calling the exception.

I don't know that I'd call that "straightforward", but I understand you being
limited by your code.


-- 
Mar 10 2008