Several questions (about inline assembly, ddoc for templates, and foreach)
Thomas Kuehne
thomas-dloop at kuehne.cn
Sat Aug 19 15:19:42 PDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Marcio schrieb am 2006-08-19:
> Thomas Kuehne wrote:
>> It's implemntation dependent. Phobos, GPhobos and Ares currently use
>>
>> # struct Array{
>> # size_t len;
>> # void* ptr;
>> # }
>>
>> Thus you could write(32-bit systems only):
>>
>> # asm {
>> # mov EAX, [array + 4]
>> # }
>
> Just tested the following code, using DMD v0.164 (in Linux), and it didn't work:
>
> //----------------------------------------------------
> void main() {
> static uint[3] array = [0xC0DE, 0xBEEF, 0xF00D];
> uint* a = null;
>
> asm {
> mov EAX, [array + 4];
> mov a, EAX;
> }
>
> writefln(a); // Prints: BEEF
> }
> //----------------------------------------------------
>
> Any ideas?
Static arrays are special :X
Try
# uint[] array = new uint[3];
# array[0] = 0xC0DE;
# array[1] = 0xBEEF;
# array[2] = 0xF00D;
And replace
#
# writefln(a);
#
with something like
#
# writefln("%X", *a);
#
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFE55u3LK5blCcjpWoRAvqHAJ4jCwdfq4eiMY3Q9nRZShIbhR7q5wCgk/rL
PmehAwIRT8emFAesQwWU2Vs=
=0uiF
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-learn
mailing list