Bug 1829 – Inline assembler cannot get label addresses

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2008-02-12T09:00:00Z
Last change time
2015-06-09T05:11:36Z
Keywords
iasm, pull, rejects-valid
Assigned to
bugzilla
Creator
burton-radons

Comments

Comment #0 by burton-radons — 2008-02-12T09:00:36Z
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.
Comment #1 by thomas-dloop — 2008-02-25T05:08:04Z
Comment #2 by bugzilla — 2008-03-04T02:01:39Z
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. :-(
Comment #3 by burton-radons — 2008-03-10T14:45:09Z
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.
Comment #4 by aliloko — 2012-05-15T15:42:19Z
This missing feature pervents making manual jump-tables. It's not a biggie if final switch can generate branchless jump-tables.
Comment #5 by yebblies — 2012-12-26T23:27:53Z
*** Issue 2505 has been marked as a duplicate of this issue. ***
Comment #6 by yebblies — 2012-12-26T23:27:59Z
*** Issue 8448 has been marked as a duplicate of this issue. ***
Comment #7 by dmitry.olsh — 2012-12-27T01:52:43Z
Applies to D2 as well.
Comment #8 by hsteoh — 2014-06-26T20:38:42Z
Comment #9 by github-bugzilla — 2014-12-06T21:08:10Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c94f831379525d6bddc699bde5f474c5a602e2ba Merge pull request #3483 from Orvid/labeloperands Issue 1829 - Allow labels as inline asm operands
Comment #10 by blah38621 — 2014-12-07T19:22:17Z
It appears I failed to add the word fixes to the description of the commit, so this wasn't auto-marked as resolved when the PR was merged.
Comment #11 by bearophile_hugs — 2014-12-07T22:45:29Z
(In reply to Orvid King from comment #10) > It appears I failed to add the word fixes to the description of the commit, > so this wasn't auto-marked as resolved when the PR was merged. I'd like to see somewhere a working example of jump table in D.
Comment #12 by github-bugzilla — 2015-02-18T03:40:53Z