Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

16-bit absolute addresses

36 views
Skip to first unread message

muta...@gmail.com

unread,
Dec 10, 2022, 10:20:43 AM12/10/22
to
If you want to point to video memory, you
can hardcode an address by going:

char *x = (char *)0xb8000000;

even though you only want 0xb8000.

And you can encapsulate that in a macro

char *x = MK_FP(0xb800, 0x0).

But with huge memory model you should instead
be able to code:

char *x = NULL;

x += 0xb8000UL;

ie you have a nice address, finally.

I'm wondering whether syntax like that should
always be used, so even in PM32, instead of
doing:

char *x = (char *)0xb8000;

you instead go:

char *x = NULL;
x += 0xb8000UL;

and have code that is portable regardless of which x86
processor you are using.

Or put the above into a macro.

I'm not sure you can even doing arithmetic on a NULL
pointer officially.

Any suggestions?

I guess addresses should be obtained from a syscall
in the first place instead of hardcode though.

But the case I really want to do it in is the bootloader,
and I need a start address of 0x10600. I'm planning
on switching my bootloader to huge memory model
(currently it is tiny).

I'm also thinking of writing an exe2flat that takes an
arbitrary executable and "loads" it to a particular
address instead of being dependent on the linker to
support such a facility.

And I'll also initialize BSS in that process, as I think
the location of BSS can be determined by getting
the "minsize" from the executable header and subtracting
the stack length.

Any thoughts on that too?

Thanks. Paul.

Alexei A. Frounze

unread,
Dec 10, 2022, 12:25:27 PM12/10/22
to
On Saturday, December 10, 2022 at 7:20:43 AM UTC-8, muta...@gmail.com wrote:
> If you want to point to video memory, you
> can hardcode an address by going:
...
> char *x = MK_FP(0xb800, 0x0).

This just works in a test program I'm compiling with:
- Borland/Turbo C/C++, large model
- Open Watcom, large model
- Smaller C, huge, unreal and DPMI models

The definition for Smaller C is:
#define MK_FP(s,o) ((void*)(((unsigned long)(s) << 4) + (unsigned)(o)))

Alex

Joe Monk

unread,
Dec 11, 2022, 6:25:32 PM12/11/22
to


You forgot the volatile keyword.

Since the video memory can be altered by events outside your code, you have to use the volatile keyword, otherwise you will get unpredictable results when C compilers apply optimizations.

Joe

Joe Monk

unread,
Dec 11, 2022, 7:42:25 PM12/11/22
to

> char *x = NULL;

> char *x = NULL;

> I'm not sure you can even doing arithmetic on a NULL
> pointer officially.

You shouldnt be using NULL at all.

"Hoare’s friend, Edsger Dijkstra, pointed out that a null pointer reference could be a bad idea. Comparing a null pointer reference to a promiscuous adulterer he noted that the null assignment for every bachelor represented in an object structure “will seem to be married polyamorously to the same person Null”.

https://www.bbc.com/news/health-63859184

Joe

muta...@gmail.com

unread,
Dec 11, 2022, 9:12:20 PM12/11/22
to
I thought that was a very amusing thing for the BBC
to say, so was smiling before I even clicked the (fake)
link. :-)

BFN. Paul.

Joe Monk

unread,
Dec 11, 2022, 9:38:48 PM12/11/22
to

> I thought that was a very amusing thing for the BBC
> to say, so was smiling before I even clicked the (fake)
> link. :-)
>
Oh sorry. Honest Mistake. That was a link for my daughter, who works in the DNA lab at the hospital doing that kind of work. She has two degrees in genetics and molecular genetics. If you read the article, it was about base amino acid editing used to make a custom therapy for a girl suffering from leukemia.

This was the link I meant to post:

https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/

https://www.theregister.com/2022/12/09/google_dart_null_safety/

Joe

muta...@gmail.com

unread,
Dec 12, 2022, 6:23:46 AM12/12/22
to
On Monday, December 12, 2022 at 10:38:48 AM UTC+8, Joe Monk wrote:

> > I thought that was a very amusing thing for the BBC
> > to say, so was smiling before I even clicked the (fake)
> > link. :-)
> >
> Oh sorry. Honest Mistake. That was a link for my daughter, who
> works in the DNA lab at the hospital doing that kind of work. She
> has two degrees in genetics and molecular genetics. If you read
> the article, it was about base amino acid editing used to make a
> custom therapy for a girl suffering from leukemia.

Reminds me of when someone accidentally cross-linked
the C programming echo with some sex one, so we
suddenly started receiving some pretty unusual messages.

Someone remarked "if there's any justice in the world, they
will have been hit with a whole lot of C programming messages"
and someone from the sex group confirmed that it was really
bad getting C programming messages.

Man, I love humanity sometimes.
Ok, I read the articles.

BFN. Paul.
0 new messages