digitalmars.D.bugs - [Bug 13] New: Difficulty accessing byte and short inout parameters from inline asm
- d-bugmail puremagic.com (89/89) Mar 05 2006 http://d.puremagic.com/bugzilla/show_bug.cgi?id=13
- d-bugmail puremagic.com (9/9) Apr 28 2006 http://d.puremagic.com/bugzilla/show_bug.cgi?id=13
- Thomas Kuehne (11/16) Jun 29 2006 -----BEGIN PGP SIGNED MESSAGE-----
http://d.puremagic.com/bugzilla/show_bug.cgi?id=13
Summary: Difficulty accessing byte and short inout parameters
from inline asm
Product: D
Version: 0.148
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: braddr puremagic.com
ReportedBy: sean f4.ca
I'm having problems manipulating inout function parameters within asm blocks if
those parameters are not 32 bits in size. Since inout parameters are pointers,
I first tried the obvious method:
C:\code\d>type test.d
import std.c.stdio;
void fn( inout byte val )
{
asm
{
mov EAX, val;
inc [EAX];
}
}
void main()
{
byte b;
printf( "%i\n", b );
fn( b );
printf( "i%\n", b );
}
C:\code\d>dmd test
test.d(7): bad type/size of operands 'mov'
C:\code\d>
When that didn't work, I tried simply adding a "byte ptr" descriptor to the
variable, but got similar results:
C:\code\d>type test.d
import std.c.stdio;
void fn( inout byte val )
{
asm
{
mov EAX, byte ptr val;
inc [EAX];
}
}
void main()
{
byte b;
printf( "%i\n", b );
fn( b );
printf( "%i\n", b );
}
C:\code\d>dmd test
test.d(7): bad type/size of operands 'mov'
C:\code\d>
So finally I thought that perhaps the assembler was outsmarting me and treating
'val' like an actual value instead of a pointer:
C:\code\d>type test.d
import std.c.stdio;
void fn( inout byte val )
{
asm
{
lea EAX, val;
inc [EAX];
}
}
void main()
{
byte b;
printf( "%i\n", b );
fn( b );
printf( "%i\n", b );
}
C:\code\d>dmd test
C:\bin\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;
C:\code\d>test
0
0
C:\code\d>
But the above result makes it clear that it does not, as the second value
shoule be 1.
Is there any way to force the inline assembler to treat 'val' as a pointer
without declaring a temporary? And is this something that can be fixed? I
know I could write naked asm, but I don't consider that a viable option
--
Mar 05 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=13
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed 0.155
--
Apr 28 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail puremagic.com schrieb am 2006-03-05:http://d.puremagic.com/bugzilla/show_bug.cgi?id=13 Summary: Difficulty accessing byte and short inout parametersI'm having problems manipulating inout function parameters within asm blocks if those parameters are not 32 bits in size. Since inout parameters are pointers, I first tried the obvious method:Added to DStress as http://dstress.kuehne.cn/run/i/inout_02_A.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEn64l3w+/yD4P9tIRArxVAJ9WNPo7SJA9GgXor0KPpxtZmQzI8gCfdDdU p/Gj41C5cCEyNdYpGx5RvRs= =VtXx -----END PGP SIGNATURE-----
Jun 29 2006









d-bugmail puremagic.com 