From owner-freebsd-questions@FreeBSD.ORG Mon Apr 7 11:19:51 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C0231065673 for ; Mon, 7 Apr 2008 11:19:51 +0000 (UTC) (envelope-from freebsd-questions@m.gmane.org) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.freebsd.org (Postfix) with ESMTP id DBCC18FC15 for ; Mon, 7 Apr 2008 11:19:50 +0000 (UTC) (envelope-from freebsd-questions@m.gmane.org) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JipO4-0000W1-40 for freebsd-questions@freebsd.org; Mon, 07 Apr 2008 11:19:44 +0000 Received: from lara.cc.fer.hr ([161.53.72.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Apr 2008 11:19:44 +0000 Received: from ivoras by lara.cc.fer.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Apr 2008 11:19:44 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-questions@freebsd.org From: Ivan Voras Date: Mon, 07 Apr 2008 13:19:33 +0200 Lines: 55 Message-ID: References: <687872.53069.qm@web57011.mail.re3.yahoo.com> <20080407122423.S86337@wojtek.tensor.gdynia.pl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig321DE440BB766C9C7728A414" X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lara.cc.fer.hr User-Agent: Thunderbird 2.0.0.6 (X11/20071022) In-Reply-To: <20080407122423.S86337@wojtek.tensor.gdynia.pl> X-Enigmail-Version: 0.95.0 Sender: news Subject: Re: Inline assembly under FreeBSD X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Apr 2008 11:19:51 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig321DE440BB766C9C7728A414 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Wojciech Puchar wrote: >> asm("pushfl; stc; int $0x13; setc %%al; popfl" >> : "+a" (ax), "+b" (bx), "=3Dc" (cx), "+d" (dx) >> : : "esi", "edi"); >> >> if ((u8)ax) >> return -1; /* No extended information */ >> else >> return 1; /* Extended information available */ >> } >> >> When it is executing the int $0x13, it crashes with >> "Program received signal SIGBUS, Bus error." >> >> Could you guys give me a helping hand to identify >> what's the problem? >> >> Input and return values are at: >> http://en.wikipedia.org/wiki/INT_13 >=20 > you are in 32-bit mode To be a little bore verbose: FreeBSD and all other modern operating systems run in some variation of "protected mode", as opposed to DOS which ran in "real mode". When you run any program as a user in such an operating system, the program doesn't have direct access to hardware, and the many other low-level details of the program execution are very much different than in DOS. Specifically in this case, you cannot call DOS and BIOS interrupts from protected mode. If you need to do something with raw data on a disk drive, there are ways to do it (see g_open(3) on recent versions of FreeBSD) but the user executing the program needs sufficient privileges/rights for the operation to be successful. --------------enig321DE440BB766C9C7728A414 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH+gNFldnAQVacBcgRAnPkAJ95qltsXCkNbcQZ46L3sKcVTTUyggCgu+mf i8oEZUIuj5HI32FlOikUnnI= =Shh9 -----END PGP SIGNATURE----- --------------enig321DE440BB766C9C7728A414--