Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

There's a whole WORLD in a mud puddle! -- Doug Clifford


devel / comp.lang.asm.x86 / 32-bit on 64-bit

SubjectAuthor
* 32-bit on 64-bitPaul Edwards
+* 32-bit on 64-bitPaul Edwards
|`* 32-bit on 64-bitPaul Edwards
| `- 32-bit on 64-bitPaul Edwards
`- 32-bit on 64-bitPaul Edwards

1
32-bit on 64-bit

<9c7d578e-882f-41a9-8d50-19e7d8ebe085n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=474&group=comp.lang.asm.x86#474

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: 32-bit on 64-bit
Date: Wed, 16 Aug 2023 07:35:27 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 37
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <9c7d578e-882f-41a9-8d50-19e7d8ebe085n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Wed, 16 Aug 2023 14:35:29 +0000
Injection-Info: dont-email.me; posting-host="3e6bfbaae3b52945c72f5c40334d4ea2";
logging-data="3509420"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KdnYbTwj9NOycihPwE7mKYuIAF2tNYzQ="
User-Agent: G2/1.0
Cancel-Lock: sha1:YNms/FjO98N5Gk0nODg/LfMOQOY=
 by: Paul Edwards - Wed, 16 Aug 2023 14:35 UTC

I have had success in getting Win64 executables to
run under UEFI with a relatively small amount of
"glue" to switch formats.

And I decided to see if I could get Win32 executables
to run instead of Win64, using different - more
complicated - "glue".

Here is a simple call to puts, but written in assembler
(so I need a C compiler to generate assembler that
looks like this - a separate exercise):

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/pdpclib/msdemo32.asm

So this is dependent on msvcrt.dll, and then this loader code:

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/bios/exeload.c

(search for w32puts) will put in the stubs for the win32
executable, and the puts stub can be found here:

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/generic/w32hack.asm

So anyway, with this in place, it means I can write a 32-bit
windows executable that works on anything from win 95
to win 11, and it also runs on an appropriate 64-bit UEFI-based
system (basically just UCX64 from http://pdos.org). Note that
this is running 32-bit code in long mode.

There will be issues for something like printf, where I don't
know how many parameters there are, so I will just assume
a maximum of 4 or something like that.

Any thoughts/improvements?

Thanks. Paul.

Re: 32-bit on 64-bit

<7824c81c-8d68-4a81-8667-196081051d97n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=475&group=comp.lang.asm.x86#475

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: 32-bit on 64-bit
Date: Wed, 16 Aug 2023 09:03:26 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 8
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <7824c81c-8d68-4a81-8667-196081051d97n@googlegroups.com>
References: <9c7d578e-882f-41a9-8d50-19e7d8ebe085n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Wed, 16 Aug 2023 16:03:27 +0000
Injection-Info: dont-email.me; posting-host="3e6bfbaae3b52945c72f5c40334d4ea2";
logging-data="3540793"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/CvyDfxWxVIYePyUnmKli/Vn7rlcCmARo="
User-Agent: G2/1.0
Cancel-Lock: sha1:d1bXCHAhxerHZEScVJ6xMmI4+p8=
 by: Paul Edwards - Wed, 16 Aug 2023 16:03 UTC

Note that I tested the win64 on real hardware previously,
but I only just tested the win32 on real hardware now
and it failed. I'll need to find out why tomorrow.

Note that it worked on qemu.

BFN. Paul.

Re: 32-bit on 64-bit

<3c4d774f-9cf4-49bb-b0df-8099f6c27c1bn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=476&group=comp.lang.asm.x86#476

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: 32-bit on 64-bit
Date: Wed, 16 Aug 2023 10:24:32 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 12
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <3c4d774f-9cf4-49bb-b0df-8099f6c27c1bn@googlegroups.com>
References: <9c7d578e-882f-41a9-8d50-19e7d8ebe085n@googlegroups.com> <7824c81c-8d68-4a81-8667-196081051d97n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Wed, 16 Aug 2023 17:24:33 +0000
Injection-Info: dont-email.me; posting-host="3e6bfbaae3b52945c72f5c40334d4ea2";
logging-data="3565565"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ExzwRPBl3ipNZUYyLrhc4vXVI0nf+o5w="
User-Agent: G2/1.0
Cancel-Lock: sha1:Z3jazp6m8Lb9ZKT9j2i8xokXMJI=
 by: Paul Edwards - Wed, 16 Aug 2023 17:24 UTC

Ok, so my bootx64.efi contains a 1 in the upper 32 bits
of addresses, ie it has been loaded above the 4 GiB
mark (on real hardware).

I'm not sure how to get around that issue.

I could arrange for the high 32 bits of the return address
to be copied onto the stack and then do a ret instead of
a jmp, but that wouldn't work on a 32-bit system.

BFN. Paul.

Re: 32-bit on 64-bit

<315a424a-14c0-4cc9-a3ab-f2c51c5cedc7n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=477&group=comp.lang.asm.x86#477

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: 32-bit on 64-bit
Date: Wed, 16 Aug 2023 11:39:51 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 22
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <315a424a-14c0-4cc9-a3ab-f2c51c5cedc7n@googlegroups.com>
References: <9c7d578e-882f-41a9-8d50-19e7d8ebe085n@googlegroups.com>
<7824c81c-8d68-4a81-8667-196081051d97n@googlegroups.com> <3c4d774f-9cf4-49bb-b0df-8099f6c27c1bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Date: Wed, 16 Aug 2023 18:39:52 +0000
Injection-Info: dont-email.me; posting-host="3e6bfbaae3b52945c72f5c40334d4ea2";
logging-data="3588935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ufLQmjv3wezEnWTPjTw5o1r5L8B5c1W4="
User-Agent: G2/1.0
Cancel-Lock: sha1:CiKQI9T6owB4cOvkuOQTVNoMWgc=
 by: Paul Edwards - Wed, 16 Aug 2023 18:39 UTC

On Thursday, August 17, 2023 at 1:27:20 AM UTC+8, Paul Edwards wrote:

> Ok, so my bootx64.efi contains a 1 in the upper 32 bits
> of addresses, ie it has been loaded above the 4 GiB
> mark (on real hardware).
>
> I'm not sure how to get around that issue.

Switching linker to pdld has a low base address, and that
was sufficient for real hardware to work (plus another bug
fix was needed).

All code has been committed, and there is a w32hack.zip
available in the UCX64 section of http://pdos.org if you
want an image to burn to USB stick.

So we're back to working code, just after code review
or whatever.

BFN. Paul.

Re: 32-bit on 64-bit

<56c00e7d-3377-457f-87ae-52fea9ca6ca7n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=478&group=comp.lang.asm.x86#478

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: 32-bit on 64-bit
Date: Wed, 16 Aug 2023 11:59:55 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 23
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <56c00e7d-3377-457f-87ae-52fea9ca6ca7n@googlegroups.com>
References: <9c7d578e-882f-41a9-8d50-19e7d8ebe085n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Date: Wed, 16 Aug 2023 18:59:56 +0000
Injection-Info: dont-email.me; posting-host="3e6bfbaae3b52945c72f5c40334d4ea2";
logging-data="3595689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dERVdtN8J79arvyo1VaeT3bM1/n9wRAo="
User-Agent: G2/1.0
Cancel-Lock: sha1:4+d3G83Wd5nbvRVWjU4FjVS61Nw=
 by: Paul Edwards - Wed, 16 Aug 2023 18:59 UTC

On Wednesday, August 16, 2023 at 10:40:29 PM UTC+8, Paul Edwards wrote:

> There will be issues for something like printf, where I don't
> know how many parameters there are, so I will just assume
> a maximum of 4 or something like that.

I thought of a possible solution for this.

I can make it mandatory to call getmainargs, and have a
fudged argc - if argc is greater than x'80000000' then it
means that it is running under a 64-bit environment, and
argv is also fudged, and is a struct, and has a pointer to
a global variable that contains the number of parameters
to any variable-argument function.

So, when the global exists, the value gets populated.

Otherwise, it's a standard win32 environment that works
without assistance.

BFN. Paul.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor