[M3devel] stdcall naming discrepancy?
Jay
jayk123 at hotmail.com
Mon Feb 4 20:46:00 CET 2008
> value... whereas parse.c passes by ref. Blurgh! Looks like we need > to smarten things up for calls to non-M3 stdcall procedures.
ps: m3 or not m3 I would think. stdcall is stdcall, independent of the implementing language.
Though sure, the C declaration could declare the thing by const pointer.
Given some existing unchanged C declarations for "callbacks" however, I should be able to implement them in M3.
- Jay
> CC: m3devel at elegosoft.com> From: hosking at cs.purdue.edu> Subject: Re: stdcall naming discrepancy?> Date: Mon, 4 Feb 2008 09:52:31 -0500> To: jayk123 at hotmail.com> > Any chance that standard_structs in Target.i3 is causing the front- > end to pass structs by reference (standard structs=TRUE)? Also, > looking at pop_struct in parse.c it seems to want to pass them by > reference (standard_structs=FALSE)? In any case, what does the > integrated back-end do with pop_struct? I bet it is passing by > value... whereas parse.c passes by ref. Blurgh! Looks like we need > to smarten things up for calls to non-M3 stdcall procedures.> > On Feb 4, 2008, at 1:23 AM, Jay wrote:> > > (and codegen..)> >> > C:\dev2\j\m3\t>type t.c> >> > typedef struct {> > int a,b,c,d,e,f;> > } Foo_t;> >> > void __stdcall Sleep(Foo_t foo);> >> > extern Foo_t a;> >> > void F1()> > {> > Sleep(a);> > }> >> > C:\dev2\j\m3\t>gcc -c -S t.c> >> > C:\dev2\j\m3\t>type t.s> > .file "t.c"> > .text> > .globl _F1> > .def _F1; .scl 2; .type 32; .endef> > _F1:> > pushl %ebp> > movl %esp, %ebp> > subl $24, %esp> > movl _a, %eax> > movl %eax, (%esp)> > movl _a+4, %eax> > movl %eax, 4(%esp)> > movl _a+8, %eax> > movl %eax, 8(%esp)> > movl _a+12, %eax> > movl %eax, 12(%esp)> > movl _a+16, %eax> > movl %eax, 16(%esp)> > movl _a+20, %eax> > movl %eax, 20(%esp)> > call _Sleep at 24> > subl $24, %esp> > leave> > ret> > C:\dev2\j\m3\t>> >> > (NOTE: This is NOT the correct declaration of Sleep, but ok for > > testing purposes.)> >> > C:\dev2\j\m3\t>type t.i3> > INTERFACE T;> >> > TYPE Foo_t = RECORD> > a,b,c,d,e,f : INTEGER;> > END;> >> > <*EXTERNAL Sleep:WINAPI*>> > PROCEDURE Sleep (dwMilliseconds1: Foo_t);> > END T.> >> > C:\dev2\j\m3\t>type t.m3> >> > MODULE T;> > VAR> > Foo: Foo_t;> >> > BEGIN> > Sleep(Foo);> > END T.> >> >> > LM1:> > movl 8(%ebp), %eax> > xorl $1, %eax> > testb %al, %al> > jne L2> > .stabn 68,0,6,LM2-_T_M3> > LM2:> > movl $_MM_T+52, %eax> > movl %eax, %edx> > subl $8, %esp> > subl $24, %esp> > movl %esp, %eax> > movl %eax, %edi> > movl %edx, %esi> > cld> > movl $6, %eax> > movl %eax, %ecx> > rep> > movsl> > call _Sleep at 4> > addl $8, %esp> > L2:> > movl $_MM_T, %eax> > LBE2:> > leal -8(%ebp), %esp> > popl %esi> > popl %edi> > leave> > ret> >> > ?> >> > - Jay> >> > Connect and share in new ways with Windows Live. Get it now!>
_________________________________________________________________
Helping your favorite cause is as easy as instant messaging. You IM, we give.
http://im.live.com/Messenger/IM/Home/?source=text_hotmail_join
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080204/f8c93eb8/attachment-0002.html>
More information about the M3devel
mailing list