From owner-freebsd-hackers Fri Aug 24 11: 8:15 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from dragon.nuxi.com (dsl092-013-169.sfo1.dsl.speakeasy.net [66.92.13.169]) by hub.freebsd.org (Postfix) with ESMTP id 07CC137B401 for ; Fri, 24 Aug 2001 11:08:07 -0700 (PDT) (envelope-from obrien@NUXI.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.11.5/8.11.1) id f7OI85t89545; Fri, 24 Aug 2001 11:08:05 -0700 (PDT) (envelope-from obrien) Date: Fri, 24 Aug 2001 11:08:05 -0700 From: "David O'Brien" To: Steve Roome Cc: freebsd-hackers@freebsd.org Subject: Re: function calls/rets in assembly Message-ID: <20010824110805.C88259@dragon.nuxi.com> Reply-To: obrien@freebsd.org References: <20010824010139.E365@dylan.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010824010139.E365@dylan.home>; from stephen_roome@yahoo.com on Fri, Aug 24, 2001 at 01:01:39AM +0100 X-Operating-System: FreeBSD 5.0-CURRENT Organization: The NUXI BSD group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Aug 24, 2001 at 01:01:39AM +0100, Steve Roome wrote: > How exactly should functions work in assembly, afaict, the > following C : > > void printasint(int p) { printf ("print this %d\n", (int)p);} Why not just ask the compiler?? $ cc -S -O0 printasint.c $ cat printasint.s .file "foo.c" .version "01.01" gcc2_compiled.: .section .rodata .LC0: .byte 0x70,0x72,0x69,0x6e,0x74,0x20,0x74,0x68,0x69,0x73 .byte 0x20,0x25,0x64,0xa,0x0 .text .p2align 2,0x90 .globl printasint .type printasint,@function printasint: pushl %ebp movl %esp,%ebp subl $8,%esp addl $-8,%esp movl 8(%ebp),%eax pushl %eax pushl $.LC0 call printf addl $16,%esp .L2: leave ret .Lfe1: .size printasint,.Lfe1-printasint .ident "GCC: (c) 2.95.3 20010315 (release)" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message