Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 07 Apr 2008 13:19:33 +0200
From:      Ivan Voras <ivoras@freebsd.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: Inline assembly under FreeBSD
Message-ID:  <ftd005$f7r$1@ger.gmane.org>
In-Reply-To: <20080407122423.S86337@wojtek.tensor.gdynia.pl>
References:  <687872.53069.qm@web57011.mail.re3.yahoo.com> <20080407122423.S86337@wojtek.tensor.gdynia.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
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--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ftd005$f7r$1>