# HG changeset patch # User lindquist # Date 1212778303 -7200 # Node ID 68687d8c3e9aa75612671d502bc6a8c01947a812 # Parent ccc2e6898a7837bb151c25ad35e72ce0176f6b63 [svn r237] some inline asm output now seems to work, see tangotests/asm2.d diff -r ccc2e6898a78 -r 68687d8c3e9a gen/asmstmt.cpp --- a/gen/asmstmt.cpp Fri Jun 06 20:14:51 2008 +0200 +++ b/gen/asmstmt.cpp Fri Jun 06 20:51:43 2008 +0200 @@ -257,7 +257,7 @@ static std::string i_cns = "i"; static std::string p_cns = "p"; static std::string m_cns = "m"; - static std::string mw_cns = "=m"; + static std::string mw_cns = "=*m"; static std::string mrw_cns = "+m"; static std::string memory_name = "memory"; @@ -457,7 +457,7 @@ size_t cn = output_values.size(); for (size_t i=0; igetLVal(); + LLValue* val = output_values[i]->getRVal(); callargs.push_back(val); } diff -r ccc2e6898a78 -r 68687d8c3e9a gen/d-asm-i386.h --- a/gen/d-asm-i386.h Fri Jun 06 20:14:51 2008 +0200 +++ b/gen/d-asm-i386.h Fri Jun 06 20:51:43 2008 +0200 @@ -1855,8 +1855,12 @@ ((operand->baseReg == Reg_EBP && ! sc->func->naked ) || (operand->baseReg == Reg_ESP && sc->func->naked)) ) { - e = new AddrExp(0, e); - e->type = decl->type->pointerTo(); + if (mode == Mode_Output) + { + e = new AddrExp(0, e); + e->type = decl->type->pointerTo(); + } + #if !IN_LLVM /* DMD uses the same frame offsets for naked functions. */ if (sc->func->naked) @@ -1909,6 +1913,12 @@ insnTemplate->writebyte('*'); use_star = false; } + if (mode == Mode_Output) + { + e = new AddrExp(0, e); + assert(decl); + e->type = decl->type->pointerTo(); + } addOperand(fmt, Arg_Memory, e, asmcode, mode); } } diff -r ccc2e6898a78 -r 68687d8c3e9a tangotests/asm2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tangotests/asm2.d Fri Jun 06 20:51:43 2008 +0200 @@ -0,0 +1,17 @@ +module tangotests.asm2; + +extern(C) int printf(char*, ...); + +int main() +{ + int i = 40; + asm + { + mov EAX, i; + add EAX, 2; + mov i, EAX; + } + printf("42 = %d\n", i); + assert(i == 42); + return 0; +}