From: "H. Peter Anvin" <hpa@zytor.com>
To: Pawel Dziepak <hryssta@gmail.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
Andi Kleen <ak@suse.de>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
akpm@linux-foundation.org
Subject: Re: [x86 setup 13/33] Header file to produce 16-bit code with gcc
Date: Tue, 10 Jul 2007 14:20:09 -0700 [thread overview]
Message-ID: <4693F809.9030903@zytor.com> (raw)
In-Reply-To: <ec870ced0707101408p25b6115ao20aa5835072e7bad@mail.gmail.com>
Pawel Dziepak wrote:
>
> Unfortunately, .code16gcc is still experimental (at least binutils'
> website says that). What is worse, it says that it is possible that
> 16bit code produced on GCC won't work on pre-80386 processors (before
> switching to protected mode you have to think about cpu as a
> pre-80386).
>
.code16gcc has been in production use in real projects since at least 2001.
16-bit code produced by gcc is indeed, guaranteed to not work on pre-386
x86s, but so is the code we had there before. Saying "before switching
to protected mode you have to think about [the] cpu as a pre-80386" is
blatantly false; 32-bit registers and addressing are readily available
in real mode using size override prefixes (which is what ".code16gcc"
takes care of.)
> I don't think that -m16 flag will be introduced quickly. In fact, only
> OS developers _sometimes_ use 16 bit code...
>
> I did a fast test and now I know that assembler instructions are
> almost ignored by GCC and passed to gas. The situation is the same
> with .code16gcc, what mean that gas has to translate 32bit code from
> GCC to 16 bit code. The result binary was correct 16 bit program (at
> least its code looked good), but it is IMHO too many translations from
> C to 32bit assembler and then to 16bit assembler, that can cause
> unpredictable errors.
You're saying "I don't understand it, and it scares me." The
differences compared to standard .code16 are pretty minute, mostly in
the matter of a couple of different default sizes (e.g. "call" defaults
to "calll" not "callw".)
> Additionally, I prefer to write architecture depend procedures in
> assembler (but is only *my* opinion, and you probably disagree).
> Assembler is faster, you have bigger control over the code, and
> portability of C is in this circumstances not necessary.
... and the code is an utter, unmaintainable mess.
-hpa
next prev parent reply other threads:[~2007-07-10 21:23 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-10 2:51 x86 setup code rewrite in C H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 01/33] x86 setup: MAINTAINERS: formally take responsibility for the i386 boot code H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 02/33] hd.c: remove BIOS/CMOS queries H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 03/33] include/asm-i386/boot.h: This is <asm/boot.h>, not <linux/boot.h> H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 04/33] Unify the CPU features vectors between i386 and x86-64 H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 05/33] Change CONFIG_X86_MINIMUM_CPU_MODEL to CONFIG_X86_MINIMUM_CPU_FAMILY H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 06/33] Clean up struct screen_info (<linux/screen_info.h>) H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 07/33] Use a new CPU feature word to cover all Intel features that are spread around H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 08/33] Define zero-page offset 0x1e4 as a scratch field, and use it H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 09/33] Make definitions for struct e820entry and struct e820map consistent H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 11:48 ` Andi Kleen
2007-07-10 2:51 ` [x86 setup 10/33] Make struct boot_params a real structure, and remove obsolete fields H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 11/33] x86-64: add CONFIG_PHYSICAL_ALIGN for consistency with i386 H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 12/33] x86-64: add symbolic constants for the boot segment selectors H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 13/33] Header file to produce 16-bit code with gcc H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 14:16 ` Segher Boessenkool
2007-07-10 15:21 ` Andi Kleen
2007-07-10 15:48 ` H. Peter Anvin
2007-07-10 15:53 ` H. Peter Anvin
2007-07-10 20:08 ` Segher Boessenkool
2007-07-10 20:43 ` H. Peter Anvin
2007-07-10 21:08 ` Pawel Dziepak
2007-07-10 21:20 ` H. Peter Anvin [this message]
2007-07-11 0:26 ` Brian Gerst
2007-07-10 19:57 ` Segher Boessenkool
2007-07-10 20:42 ` H. Peter Anvin
2007-07-10 21:10 ` Segher Boessenkool
2007-07-10 21:40 ` H. Peter Anvin
2007-07-10 22:06 ` Segher Boessenkool
2007-07-10 21:43 ` Adrian Bunk
2007-07-10 21:46 ` H. Peter Anvin
2007-07-11 0:30 ` Brian Gerst
2007-07-10 2:51 ` [x86 setup 14/33] Top header file for new x86 setup code H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 15/33] Simple bitops for the " H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 16/33] String-handling functions " H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 18:25 ` Jan Engelhardt
2007-07-10 18:35 ` H. Peter Anvin
2007-07-10 20:10 ` Segher Boessenkool
2007-07-10 20:44 ` H. Peter Anvin
2007-07-10 21:14 ` Segher Boessenkool
2007-07-11 12:46 ` Andi Kleen
2007-07-10 2:51 ` [x86 setup 17/33] A20 handling code H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 18:27 ` Jan Engelhardt
2007-07-10 18:33 ` H. Peter Anvin
2007-07-10 18:36 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 18/33] APM probing code H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 19/33] Command-line parsing code for the new x86 setup code H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 2:51 ` [x86 setup 20/33] Console-writing " H. Peter Anvin
2007-07-10 2:51 ` H. Peter Anvin
2007-07-10 18:35 ` Jan Engelhardt
2007-07-10 18:48 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 21/33] Version string " H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 22/33] CPU features verification " H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 7:37 ` Sébastien Dugué
2007-07-10 7:37 ` Sébastien Dugué
2007-07-10 2:52 ` [x86 setup 23/33] EDD probing code " H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 24/33] MCA support for " H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 25/33] Memory probing support for the " H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 26/33] Voyager " H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 27/33] Video mode probing " H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 28/33] Code for actual protected-mode entry H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 29/33] Assembly header and main routine for new x86 setup code H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 30/33] Linker script for the " H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 31/33] Use the new x86 setup code for i386 H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 7:55 ` Tilman Schmidt
2007-07-10 2:52 ` [x86 setup 32/33] Use the new x86 setup code for x86-64; unify with i386 H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 2:52 ` [x86 setup 33/33] Remove old i386 setup code H. Peter Anvin
2007-07-10 2:52 ` H. Peter Anvin
2007-07-10 4:24 ` x86 setup code rewrite in C Yinghai Lu
2007-07-10 4:39 ` H. Peter Anvin
2007-07-10 5:25 ` Jeff Garzik
2007-07-10 16:24 ` Jeremy Fitzhardinge
-- strict thread matches above, loose matches on Subject: below --
2007-07-11 19:18 x86 setup code rewrite in C - revised H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 01/33] x86 setup: MAINTAINERS: formally take responsibility for the i386 boot code H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 02/33] hd.c: remove BIOS/CMOS queries H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 03/33] include/asm-i386/boot.h: This is <asm/boot.h>, not <linux/boot.h> H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 04/33] Unify the CPU features vectors between i386 and x86-64 H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 05/33] Change CONFIG_X86_MINIMUM_CPU_MODEL to CONFIG_X86_MINIMUM_CPU_FAMILY H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 06/33] Clean up struct screen_info (<linux/screen_info.h>) H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 07/33] Use a new CPU feature word to cover all Intel features that are spread around H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 08/33] Define zero-page offset 0x1e4 as a scratch field, and use it H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 09/33] Make definitions for struct e820entry and struct e820map consistent H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 10/33] Make struct boot_params a real structure, and remove obsolete fields H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 11/33] x86-64: add CONFIG_PHYSICAL_ALIGN for consistency with i386 H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 12/33] x86-64: add symbolic constants for the boot segment selectors H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 01/33] x86 setup: MAINTAINERS: formally take responsibility for the i386 boot code H. Peter Anvin
2007-07-11 19:18 ` [x86 setup 13/33] Header file to produce 16-bit code with gcc H. Peter Anvin
2007-07-11 19:18 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4693F809.9030903@zytor.com \
--to=hpa@zytor.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=hryssta@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=segher@kernel.crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.