muta...@gmail.com
2022-12-10 15:20:41 UTC
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.
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.