From owner-freebsd-hackers@FreeBSD.ORG Thu Sep 30 17:35:38 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4E4F216A4CE for ; Thu, 30 Sep 2004 17:35:38 +0000 (GMT) Received: from mail3.speakeasy.net (mail3.speakeasy.net [216.254.0.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id DAECC43D2D for ; Thu, 30 Sep 2004 17:35:35 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: (qmail 18026 invoked from network); 30 Sep 2004 17:35:35 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 30 Sep 2004 17:35:35 -0000 Received: from [10.50.40.210] (gw1.twc.weather.com [216.133.140.1]) (authenticated bits=0) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id i8UHZREj019616; Thu, 30 Sep 2004 13:35:31 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: freebsd-hackers@FreeBSD.org Date: Thu, 30 Sep 2004 10:34:28 -0400 User-Agent: KMail/1.6.2 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409301034.28349.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: vijay singh Subject: Re: about freebsd boot1.S X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2004 17:35:38 -0000 On Wednesday 29 September 2004 03:32 pm, vijay singh wrote: > hello all, i am trying to understand the freebsd boot code. i saw that the > 1st stage boot loader relocates itself from 7c00 to 700. why is this done? > if the run time kernel were to switch to real-mode and transfer control to > this location (0700) would the 1st stage boot program run again? > > for the output below, i used the BIOS debugger and read the 1st sector into > 7c00, and unassebled the text. > > 0000:00007C1D cld > 0000:00007C1E xor cx, cx /* cx = 0 */ > 0000:00007C20 mov es, cx /* es = 0 */ > 0000:00007C22 mov ds, cx /* ds = 0 */ > 0000:00007C24 mov ss, cx /* ss = 0 */ > 0000:00007C26 mov sp, 7C00 /* set SP to current location */ > 0000:00007C29 mov si, sp > 0000:00007C2B mov di, 0700 /* DS:SI pair denotes the source string > and ES:DI pair the destination string 0:7C00 -> 0:700 */ > 0000:00007C2E inc ch /* ch = 1, cx = 100*/ > 0000:00007C30 repe /* repeat the movsw instruction cx number of times */ > 0000:00007C31 movsw /* moves 200h = 512 bytes from 7C00 to 700*/ > > please cc me in your reply. We copy ourselves down so that we can use 0x7c00 as a buffer to load sectors into off of the disk. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org