Bug 13 – Difficulty accessing byte and short inout parameters from inline asm

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-03-05T13:01:00Z
Last change time
2014-02-14T20:33:30Z
Assigned to
bugzilla
Creator
sean

Comments

Comment #0 by sean — 2006-03-05T13:01:15Z
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
Comment #1 by bugzilla — 2006-04-28T02:54:18Z
Fixed 0.155
Comment #2 by thomas-dloop — 2006-06-29T08:40:32Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-03-05: > http://d.puremagic.com/bugzilla/show_bug.cgi?id=13 > > Summary: Difficulty accessing byte and short inout parameters > 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: 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-----