[Issue 2076] New: offset doesn't work in asm
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed May 7 07:05:08 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2076
Summary: offset doesn't work in asm
Product: D
Version: 1.028
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: clugdbug at yahoo.com.au
I wanted to get the address of a label into a register. This seems to be
impossible at present. I tried various things, including the code below, which
prints:
-----
Error: offset deprecated, use offsetof
which (a) gives no line number; and (b) in the spec, 'offset' is permitted in
asm (and offsetof is not mentioned).
-----
void main()
{
asm {
mov EAX, offset L1;
L1:
;
}
}
Finally,
bug(c):
mov EAX, $; doesn't work either. It seems that $ only works in jmp
instructions?
This is either a compiler bug, or should be mentioned in the spec.
So it seems that there is no way to get the current address into a register.
This limitation means that there's no way to (efficiently) implement duff's
device in asm. But it's probably a side-effect of there being no way to take
the address of a label in normal D code.
--
More information about the Digitalmars-d-bugs
mailing list