<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>> > > to smarten things up for calls to non-M3 stdcall procedures.<BR><BR>
Why is the smartening specific to non-M3 procedures?<BR>I should be able to write stdcall functions in M3 as well, that take and return structs, I am so inclined or "forced".<BR>
(Arguably, it should be the default. It is slightly more efficient.)<BR>
<BR>
- Jay<BR><BR><BR>
<HR id=stopSpelling>
<BR>
> CC: m3devel@elegosoft.com<BR>> From: hosking@cs.purdue.edu<BR>> Subject: Re: stdcall naming discrepancy?<BR>> Date: Mon, 4 Feb 2008 15:30:59 -0500<BR>> To: jayk123@hotmail.com<BR>> <BR>> I don't think I follow you.<BR>> <BR>> On Feb 4, 2008, at 2:46 PM, Jay wrote:<BR>> <BR>> > > value... whereas parse.c passes by ref. Blurgh! Looks like we need<BR>> > > to smarten things up for calls to non-M3 stdcall procedures.<BR>> ><BR>> > ps: m3 or not m3 I would think. stdcall is stdcall, independent of <BR>> > the implementing language.<BR>> > Though sure, the C declaration could declare the thing by const <BR>> > pointer.<BR>> ><BR>> > Given some existing unchanged C declarations for "callbacks" <BR>> > however, I should be able to implement them in M3.<BR>> ><BR>> > - Jay<BR>> ><BR>> ><BR>> ><BR>> > > CC: m3devel@elegosoft.com<BR>> > > From: hosking@cs.purdue.edu<BR>> > > Subject: Re: stdcall naming discrepancy?<BR>> > > Date: Mon, 4 Feb 2008 09:52:31 -0500<BR>> > > To: jayk123@hotmail.com<BR>> > ><BR>> > > Any chance that standard_structs in Target.i3 is causing the front-<BR>> > > end to pass structs by reference (standard structs=TRUE)? Also,<BR>> > > looking at pop_struct in parse.c it seems to want to pass them by<BR>> > > reference (standard_structs=FALSE)? In any case, what does the<BR>> > > integrated back-end do with pop_struct? I bet it is passing by<BR>> > > value... whereas parse.c passes by ref. Blurgh! Looks like we need<BR>> > > to smarten things up for calls to non-M3 stdcall procedures.<BR>> > ><BR>> > > On Feb 4, 2008, at 1:23 AM, Jay wrote:<BR>> > ><BR>> > > > (and codegen..)<BR>> > > ><BR>> > > > C:\dev2\j\m3\t>type t.c<BR>> > > ><BR>> > > > typedef struct {<BR>> > > > int a,b,c,d,e,f;<BR>> > > > } Foo_t;<BR>> > > ><BR>> > > > void __stdcall Sleep(Foo_t foo);<BR>> > > ><BR>> > > > extern Foo_t a;<BR>> > > ><BR>> > > > void F1()<BR>> > > > {<BR>> > > > Sleep(a);<BR>> > > > }<BR>> > > ><BR>> > > > C:\dev2\j\m3\t>gcc -c -S t.c<BR>> > > ><BR>> > > > C:\dev2\j\m3\t>type t.s<BR>> > > > .file "t.c"<BR>> > > > .text<BR>> > > > .globl _F1<BR>> > > > .def _F1; .scl 2; .type 32; .endef<BR>> > > > _F1:<BR>> > > > pushl %ebp<BR>> > > > movl %esp, %ebp<BR>> > > > subl $24, %esp<BR>> > > > movl _a, %eax<BR>> > > > movl %eax, (%esp)<BR>> > > > movl _a+4, %eax<BR>> > > > movl %eax, 4(%esp)<BR>> > > > movl _a+8, %eax<BR>> > > > movl %eax, 8(%esp)<BR>> > > > movl _a+12, %eax<BR>> > > > movl %eax, 12(%esp)<BR>> > > > movl _a+16, %eax<BR>> > > > movl %eax, 16(%esp)<BR>> > > > movl _a+20, %eax<BR>> > > > movl %eax, 20(%esp)<BR>> > > > call _Sleep@24<BR>> > > > subl $24, %esp<BR>> > > > leave<BR>> > > > ret<BR>> > > > C:\dev2\j\m3\t><BR>> > > ><BR>> > > > (NOTE: This is NOT the correct declaration of Sleep, but ok for<BR>> > > > testing purposes.)<BR>> > > ><BR>> > > > C:\dev2\j\m3\t>type t.i3<BR>> > > > INTERFACE T;<BR>> > > ><BR>> > > > TYPE Foo_t = RECORD<BR>> > > > a,b,c,d,e,f : INTEGER;<BR>> > > > END;<BR>> > > ><BR>> > > > <*EXTERNAL Sleep:WINAPI*><BR>> > > > PROCEDURE Sleep (dwMilliseconds1: Foo_t);<BR>> > > > END T.<BR>> > > ><BR>> > > > C:\dev2\j\m3\t>type t.m3<BR>> > > ><BR>> > > > MODULE T;<BR>> > > > VAR<BR>> > > > Foo: Foo_t;<BR>> > > ><BR>> > > > BEGIN<BR>> > > > Sleep(Foo);<BR>> > > > END T.<BR>> > > ><BR>> > > ><BR>> > > > LM1:<BR>> > > > movl 8(%ebp), %eax<BR>> > > > xorl $1, %eax<BR>> > > > testb %al, %al<BR>> > > > jne L2<BR>> > > > .stabn 68,0,6,LM2-_T_M3<BR>> > > > LM2:<BR>> > > > movl $_MM_T+52, %eax<BR>> > > > movl %eax, %edx<BR>> > > > subl $8, %esp<BR>> > > > subl $24, %esp<BR>> > > > movl %esp, %eax<BR>> > > > movl %eax, %edi<BR>> > > > movl %edx, %esi<BR>> > > > cld<BR>> > > > movl $6, %eax<BR>> > > > movl %eax, %ecx<BR>> > > > rep<BR>> > > > movsl<BR>> > > > call _Sleep@4<BR>> > > > addl $8, %esp<BR>> > > > L2:<BR>> > > > movl $_MM_T, %eax<BR>> > > > LBE2:<BR>> > > > leal -8(%ebp), %esp<BR>> > > > popl %esi<BR>> > > > popl %edi<BR>> > > > leave<BR>> > > > ret<BR>> > > ><BR>> > > > ?<BR>> > > ><BR>> > > > - Jay<BR>> > > ><BR>> > > > Connect and share in new ways with Windows Live. Get it now!<BR>> > ><BR>> ><BR>> ><BR>> > Helping your favorite cause is as easy as instant messaging. You <BR>> > IM, we give. Learn more.<BR>> <BR><BR><br /><hr />Need to know the score, the latest news, or you need your HotmailŪ-get your "fix". <a href='http://www.msnmobilefix.com/Default.aspx' target='_new'>Check it out.</a></body>
</html>