🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.msdos.programmer
2 messages
2 total messages Started by Bruce Atherton Thu, 02 Aug 1990 16:03
Re: Virtual Memory for the Heap
#1781
Author: Bruce Atherton
Date: Thu, 02 Aug 1990 16:03
30 lines
1764 bytes
bright@Data-IO.COM (Walter Bright) writes:
> 
> I've used _handles quite a bit in my code. The reason they were implemented
> is that the code looked so *ugly* when explicit function calls had to be
> done to dereference a handle. Thus, making a handle a special pointer type,
> and having the compiler call the function for you, cleaned up the code
> a lot. I'd say that the _handles are certainly the easiest to convert your
> code into using.
> 
> The thing to watch out for is inadvertently converting a handle to a far
> pointer, as in stuff like:
>         char _handle *h;
>         h = (char *) handle_malloc(10);         /* error!       */
>         h = (char _handle *) handle_malloc(10); /* correct way  */

I agree that explicit calls for dereferencing is no way to implement
virtual memory.  Zortech seems to use the most elegant solution I've
heard about so far.

Can you use a _handle anywhere you would use a pointer?  Can you declare
a _handle to a _handle to a function that returns a _handle? Does this
have to be a part of the compiler, or could I write an object in any C++
that would do the same thing?

Finally, can you create a pointer into the ROM BIOS area?

Thanks for your help.

Bruce_Atherton@mindlink.UUCP or| Wham bam bam bam bam bam thank you Hymie.
uunet!van-bc!rsoft!mindlink!a35| We drive chicks MAAADD! - The Frantics.
Re: Virtual Memory for the Heap
#1804
Author: Walter Bright
Date: Mon, 06 Aug 1990 18:50
38 lines
1913 bytes
In article <2699@mindlink.UUCP> a35@mindlink.UUCP (Bruce Atherton) writes:
<I agree that explicit calls for dereferencing is no way to implement
<virtual memory.  Zortech seems to use the most elegant solution I've
<heard about so far.
<Can you use a _handle anywhere you would use a pointer?

Anywhere you would use a far pointer, except if you want a far pointer
that points into the BIOS.

<Can you declare a _handle to a _handle to a function that returns a _handle?

You cannot have _handle pointers to functions (there is no point to that!).
But you can do things like:

	char _handle *(_handle **)(void);

which is a _handle to a pointer to a function returning a _handle.

<Does this have to be a part of the compiler, or could I write an object
<in any C++ that would do the same thing?

You can do it in standard C++ on a class-by-class basis by overloading the
* [] and -> operators. The disadvantage is that the optimizer cannot tell
when the dereferencing function calls are redundant and cannot eliminate
them. For instance:
	struct A __handle *h;
	h->a = 1;
	h->b = 2;
On the second assignment, the function call to dereference h can be
eliminated if handles are built in to the compiler, but cannot be if
it's a user-defined function in C++.

You cannot do it with pointers to something-besides-a-class in standard C++.

<Finally, can you create a pointer into the ROM BIOS area?

Yes. Simply use a far pointer:
	char far *p = MK_FP(0xFFFF,0);
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads