From owner-freebsd-hackers Fri Nov 13 13:16:18 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA01378 for freebsd-hackers-outgoing; Fri, 13 Nov 1998 13:16:18 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from ceia.nordier.com (m2-34-dbn.dial-up.net [196.34.155.98]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA01358 for ; Fri, 13 Nov 1998 13:16:11 -0800 (PST) (envelope-from rnordier@nordier.com) Received: (from rnordier@localhost) by ceia.nordier.com (8.8.7/8.6.12) id XAA13342; Fri, 13 Nov 1998 23:09:58 +0200 (SAT) From: Robert Nordier Message-Id: <199811132109.XAA13342@ceia.nordier.com> Subject: Re: FreeBSD on i386 memory model In-Reply-To: from "David E. Cross" at "Nov 13, 98 02:49:42 pm" To: crossd@cs.rpi.edu (David E. Cross) Date: Fri, 13 Nov 1998 23:09:55 +0200 (SAT) Cc: rnordier@nordier.com, ru@ucb.crimea.ua, hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG David E. Cross wrote: > > That is great. Could you sprinkle a comment or 2 as to what it is doing? > > ie, I am not sure what the 'call .+0x5' and 'lcall $0x7,0x0' do. The "call .+0x5" just calls the location corresponding to the start of the next instruction (the '.' is the current location and a call is encoded as 5 bytes). The "lcall 0x7,0x0" does a system call. # Get offset of main in %ebp main: call .+0x5 popl %ebp subl $0x5,%ebp # write(STDOUT_FILENO, msg, sizeof(msg)); pushl $msg.1-msg leal msg-main(%ebp),%eax pushl %eax pushl $0x1 movl $0x4,%eax # SYS_write call .+0x5 lcall $0x7,$0x0 # exit(0); pushl $0x0 movl $0x1,%eax # SYS_exit call .+0x5 lcall $0x7,$0x0 msg: .ascii "hello, world!\n" msg.1: It is really just intended as a curiosity, and is neither very idiomatic nor very correct. :-) -- Robert Nordier To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message