public inbox for linux-8086@vger.kernel.org
 help / color / mirror / Atom feed
From: David Given <dg@cowlark.com>
To: linux-8086@vger.kernel.org
Subject: Re: EDE - Personal Suggestions and Ideas
Date: Fri, 28 May 2004 11:11:50 +0100	[thread overview]
Message-ID: <200405281111.50735.dg@cowlark.com> (raw)
In-Reply-To: <20040528081028.GX15905@vega.vega.lgb.hu>

On Friday 28 May 2004 09:10, Gábor Lénárt wrote:
[...]
> Wrong, because there is no such thing like 'C program' from the view point
> of the CPU. It runs machine code. It's ANOTHER thing that this machine
> code was produced by a C compiler/linker/etc, or it's 'hand coded' in
> assembly and was assembled by the assembler and/or linked/etc into CPU
> runnable machine code. My only point is that we should generally speaking
> that we have or have not this feature, and probably we should not use
> rules 'only C is allowed'.

One interesting consequence of dealing with C is that C insists that you can 
take pointers to things on the stack. This means that the stack has to live 
in the data segment.

However, the 8086 doesn't have to do this! You can put the stack in a 
completely different segment, if you like. If you do, the only way of 
accessing it is via stack-relative addressing modes, but the 8086 was 
designed to make this easy. (If you've ever programmed on the Z80, which 
*wasn't* designed to make this easy, you'll realise just how nice 
stack-relative addressing modes are.)

Unfortunately, if you put the stack in another segment, you can't take 
pointers to it from C. Imagine this code:

void settozero(char* pointer)
{
	*pointer = 0;
}

char global;
void main()
{
	char local;

	settozero(&local);
	settozero(&global);
}

As far as the settozero() function is concerned, it doesn't know whether the 
pointer argument should be accessed with DS or SS.

But if you're not programming in C, you don't have this limitation. Unix 
traditionally is programmed in C, so people don't think about this much, but 
it would be really nice if the kernel would manage all the segment registers 
and not just CS and DS. So that, if you like, you could load a binary that 
allocated all four segments. This would allow nice features such as a Basic 
interpreter that stored its byte-code in ES, its working stack in SS, and 
used DS for workspace.

I haven't looked at the source, so I don't know how much extra work it would 
be, but I suspect it wouldn't be hard to extend the kernel to do this. This 
way the multi-segment people can be happy, plus we keep the clean design of 
the kernel (and avoid the hideousness of far pointers).

-- 
+- David Given --McQ-+ "...you could wire up a *dead rat* to a DIMM
|  dg@cowlark.com    | socket, and the PC BIOS memory test would pass it
| (dg@tao-group.com) | just fine." --- Ethan Benson
+- www.cowlark.com --+ 
-
To unsubscribe from this list: send the line "unsubscribe linux-8086" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2004-05-28 10:11 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-25 14:23 [Fwd: Re: EDE - Personal Suggestions and Ideas] Miguel Bolanos
2004-05-25 17:10 ` David Given
2004-05-26  6:20   ` AW: " Mario Premke
2004-05-26 10:09     ` David Given
2004-05-26 10:30       ` Gábor Lénárt
2004-05-26 11:43         ` AW: " Mario Premke
2004-05-26 11:57           ` Gábor Lénárt
2004-05-26 12:39             ` AW: " Mario Premke
2004-05-26 13:06               ` Gábor Lénárt
2004-05-26 14:17                 ` David Given
2004-05-26 15:10                   ` Gábor Lénárt
2004-05-26 16:00                     ` Andrey Romanenko
2004-05-26 16:49                     ` David Given
2004-05-26 17:19                       ` Eduardo Pereira Habkost
2004-05-27  9:09                         ` Gábor Lénárt
2004-05-26 17:42                       ` Andrey Romanenko
2004-05-26 23:19                         ` David Given
2004-05-27  6:07                           ` EDE - Personal Suggestions and Ideas sandeep
2004-05-27 15:51                             ` Eduardo Pereira Habkost
2004-05-28  8:09                               ` sandeep
2004-05-28  8:10                                 ` Gábor Lénárt
2004-05-28 10:11                                   ` David Given [this message]
2004-05-28 11:23                                     ` Andrey Romanenko
2004-05-28 12:14                                       ` David Given
2004-05-29  5:28                                         ` Dan Olson
2004-05-28 10:30                                   ` sandeep
2004-05-26 22:34                       ` AW: [Fwd: Re: EDE - Personal Suggestions and Ideas] Harry Kalogirou
2004-05-27  9:00                       ` Gábor Lénárt
2004-05-27  6:04         ` Dan Olson
2004-05-27  7:14           ` Andrey Romanenko
2004-05-27  9:32             ` David Given
2004-05-27 10:19               ` Gábor Lénárt
2004-05-27 21:07               ` Tommy McCabe
2004-05-28  7:39                 ` Gábor Lénárt
2004-06-01 13:46                 ` Gabucino
2004-06-02  9:03                   ` AW: [Fwd: Re: EDE - Personal Suggestions and Ideas][OT] Javier Sedano
2004-05-26 11:34       ` AW: AW: [Fwd: Re: EDE - Personal Suggestions and Ideas] Mario Premke
2004-05-26 12:09         ` Gábor Lénárt
2004-05-27  5:56     ` Dan Olson
2004-05-26 22:42   ` Harry Kalogirou
  -- strict thread matches above, loose matches on Subject: below --
2004-05-25 13:33 EDE - Personal Suggestions and Ideas Miguel Bolanos
2004-05-26 10:06 ` Gábor Lénárt

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=200405281111.50735.dg@cowlark.com \
    --to=dg@cowlark.com \
    --cc=linux-8086@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox