Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Is knowledge knowable? If not, how do we know that?


devel / comp.lang.c / cc64 register preservation

SubjectAuthor
* cc64 register preservationPaul Edwards
+* Re: cc64 register preservationPaul Edwards
|`* Re: cc64 register preservationPaul Edwards
| `- Re: cc64 register preservationPaul Edwards
`* Re: cc64 register preservationBart
 +* Re: cc64 register preservationPaul Edwards
 |`* Re: cc64 register preservationPaul Edwards
 | `* Re: cc64 register preservationPaul Edwards
 |  `- Re: cc64 register preservationDan Cross
 `* Re: cc64 register preservationPaul Edwards
  `- Re: cc64 register preservationPaul Edwards

1
cc64 register preservation

<a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28651&group=comp.lang.c#28651

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:1888:b0:403:aa87:d220 with SMTP id v8-20020a05622a188800b00403aa87d220mr166448qtc.0.1693710430292;
Sat, 02 Sep 2023 20:07:10 -0700 (PDT)
X-Received: by 2002:a17:903:234c:b0:1c3:2fc8:12fe with SMTP id
c12-20020a170903234c00b001c32fc812femr511392plh.9.1693710429938; Sat, 02 Sep
2023 20:07:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 2 Sep 2023 20:07:09 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
Subject: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 03:07:10 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Paul Edwards - Sun, 3 Sep 2023 03:07 UTC

Can anyone spot where this compiler:

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

is preserving registers?

I am getting code generated that clobbers A3 (edi), but
the same happens with different code where D3 (rdi)
is clobbered.

The at&t syntax of a modified version is:

C:\devel\pdos\pdcc\cpplib>type symtab3.asm
..text
..globl symtab_destroy_symtab
symtab_destroy_symtab:
push %rbp
mov %rsp,%rbp
push %rdi
mov %rcx,0x10(%rbp)
mov %rdx,0x18(%rbp)
jmp fred
fred:
mov 0x10(%rbp),%rbx
# These used to have rex
mov 0x8(%rbx),%edi
mov %edi,%eax
dec %edi
mov %edi,0x8(%rbx)
# end of rex
cmp $0x0,%eax
jne fred
pop %rdi
pop %rbp
ret

(I added the push and pop of rdi manually to make it work)

Now I need that push and pop to happen automatically.

I don't mind if there are two push rdi to keep the stack
16-byte aligned.

Hell - I don't even particularly care if all registers that are
meant to be preserved are pushed and popped
unconditionally (ie even if not used).

I just need it to work.

I've looked (and am still looking) in the source code to
try to find where this could be done.

Thanks. Paul.

`symtab_destroy_symtab::
push Dframe
mov Dframe, Dstack
sub Dstack, 16
mov [Dframe+16], D10
mov [Dframe+24], D11
! -------------------------------------------------
jmp L11
L12:
sub Dstack, 32
mov D0, [Dframe+16]
mov A13, [D0+8]
push D13
mov D10, KK1
pop D11
call `printf*
add Dstack, 32
mov D0, [Dframe+16]
mov A0, [D0+8]
cmp A0, 7
jnz L13
jmp L10
L13:
mov D13, 0
mov [Dframe-16], D13
mov D0, [Dframe+16]
mov D0, [D0+0]
mov D1, [Dframe+16]
movsx D1, word32 [D1+8]
mov D0, [D0+D1*8]
mov [Dframe-8], D0
sub Dstack, 32
mov D10, KK2
mov D11, [Dframe-8]
call `printf*
add Dstack, 32
jmp L16
L17:
mov D0, [Dframe-8]
mov D0, [D0+16]
mov [Dframe-16], D0
sub Dstack, 32
mov D10, KK3
mov D11, [Dframe-8]
call `printf*
add Dstack, 32
sub Dstack, 32
mov D10, [Dframe-8]
mov D0, [Dframe+24]
call D0
add Dstack, 32
L14:
mov D0, [Dframe-16]
mov [Dframe-8], D0
L16:
mov D0, [Dframe-8]
cmp D0, 0
jnz L17
L15:
L9:
L11:
mov D1, [Dframe+16]
mov A3, [D1+8]
mov A0, A3
dec A3
mov [D1+8], A3
cmp A0, 0
jnz L12
L10:
sub Dstack, 32
mov D10, [Dframe+16]
mov D10, [D10+0]
call `free*
add Dstack, 32
sub Dstack, 32
mov D10, [Dframe+16]
call `free*
add Dstack, 32
L8:
! -------------------------------------------------
add Dstack, 16
pop Dframe
ret

align 16

Re: cc64 register preservation

<a834cc69-5450-484f-8208-1128cc07f041n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28653&group=comp.lang.c#28653

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:492:b0:76f:2631:caa3 with SMTP id 18-20020a05620a049200b0076f2631caa3mr142966qkr.2.1693712664248;
Sat, 02 Sep 2023 20:44:24 -0700 (PDT)
X-Received: by 2002:a17:902:d044:b0:1bc:73a6:8be7 with SMTP id
l4-20020a170902d04400b001bc73a68be7mr1323405pll.3.1693712663742; Sat, 02 Sep
2023 20:44:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 2 Sep 2023 20:44:23 -0700 (PDT)
In-Reply-To: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a834cc69-5450-484f-8208-1128cc07f041n@googlegroups.com>
Subject: Re: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 03:44:24 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2749
 by: Paul Edwards - Sun, 3 Sep 2023 03:44 UTC

I stumbled across something promising, and I think I have the push now.

C:\devel\pdos\cc64>git diff .
diff --git a/cc64/cc64.c b/cc64/cc64.c
index 525e5f2b..eebf3477 100644
--- a/cc64/cc64.c
+++ b/cc64/cc64.c
@@ -22166,6 +22166,9 @@ static void cc_genmcl_genprocentry(i64 fbytes,i64 pbytes) {
if (!!(fbytes)) {
cc_libmcl_pushstack(cc_libmcl_roundto(fbytes,(i64)16));
};
+ /* 1 is rax, 5 is r10, 3 is rsi, 4 is rdi */
+ cc_libmcl_genmc((i64)6,cc_libmcl_genreg((i64)4,(i64)8),(struct cc_libmcl_opndrec *)(0));
+ cc_libmcl_genmc((i64)6,cc_libmcl_genreg((i64)4,(i64)8),(struct cc_libmcl_opndrec *)(0));
} else {
cc_libmcl_pushstack((i64)8);
};

C:\devel\pdos\cc64>

0000000000000000 <symtab_destroy_symtab>:
0: 55 push %rbp
1: 48 8b ec mov %rsp,%rbp
4: 57 push %rdi
5: 57 push %rdi
6: 48 89 4d 10 mov %rcx,0x10(%rbp)
a: 48 89 55 18 mov %rdx,0x18(%rbp)
e: e9 00 00 00 00 jmp 13 <symtab_destroy_symtab+0x13>
13: 48 8b 5d 10 mov 0x10(%rbp),%rbx
17: 48 8b 7b 08 mov 0x8(%rbx),%rdi
1b: 48 8b c7 mov %rdi,%rax
1e: 48 ff cf dec %rdi
21: 48 89 7b 08 mov %rdi,0x8(%rbx)
25: 48 83 f8 00 cmp $0x0,%rax
29: 75 e8 jne 13 <symtab_destroy_symtab+0x13>
2b: 5d pop %rbp
2c: c3 ret

Re: cc64 register preservation

<771ddf5c-8ce3-4cbb-b5e3-d8affb276cden@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28654&group=comp.lang.c#28654

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:8e0a:b0:76f:39c:d0a9 with SMTP id re10-20020a05620a8e0a00b0076f039cd0a9mr134107qkn.5.1693713788845;
Sat, 02 Sep 2023 21:03:08 -0700 (PDT)
X-Received: by 2002:a17:90a:bc98:b0:269:78f:3816 with SMTP id
x24-20020a17090abc9800b00269078f3816mr1540537pjr.1.1693713788368; Sat, 02 Sep
2023 21:03:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 2 Sep 2023 21:03:07 -0700 (PDT)
In-Reply-To: <a834cc69-5450-484f-8208-1128cc07f041n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com> <a834cc69-5450-484f-8208-1128cc07f041n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <771ddf5c-8ce3-4cbb-b5e3-d8affb276cden@googlegroups.com>
Subject: Re: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 04:03:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4047
 by: Paul Edwards - Sun, 3 Sep 2023 04:03 UTC

With this:

C:\devel\pdos\cc64>git diff .
diff --git a/cc64/cc64.c b/cc64/cc64.c
index 525e5f2b..7e3216bd 100644
--- a/cc64/cc64.c
+++ b/cc64/cc64.c
@@ -22166,6 +22166,9 @@ static void cc_genmcl_genprocentry(i64 fbytes,i64 pbytes) {
if (!!(fbytes)) {
cc_libmcl_pushstack(cc_libmcl_roundto(fbytes,(i64)16));
};
+ /* 1 is rax, 5 is r10, 3 is rsi, 4 is rdi */
+ cc_libmcl_genmc((i64)6,cc_libmcl_genreg((i64)4,(i64)8),(struct cc_libmcl_opndrec *)(0));
+ cc_libmcl_genmc((i64)6,cc_libmcl_genreg((i64)4,(i64)8),(struct cc_libmcl_opndrec *)(0));
} else {
cc_libmcl_pushstack((i64)8);
};
@@ -22970,6 +22973,10 @@ void cc_libmcl_genreturn(i64 fbytes,i64 pbytes) {
iscallback = cc_libmcl_iscallbackfn(cc_decls_currproc);
cc_libmcl_retbeforeblock = (i64)1;
if ((!!(fbytes) || !!(pbytes))) {
+ /* first parameter: 6 is push, 7 is pop */
+ /* second parameter: 4 is rdi */
+ cc_libmcl_genmc((i64)7,cc_libmcl_genreg((i64)4,(i64)8),(struct cc_libmcl_opndrec *)(0));
+ cc_libmcl_genmc((i64)7,cc_libmcl_genreg((i64)4,(i64)8),(struct cc_libmcl_opndrec *)(0));
if (!!(fbytes)) {
cc_libmcl_popstack(cc_libmcl_roundto(fbytes,(i64)16));
};

C:\devel\pdos\cc64>

I get the desired generated code:

C:\devel\pdos\pdcc>cc64-fudge -c -out:cpplib/symtab2.obj cpplib/symtab2.i
Compiling cpplib/symtab2.i to cpplib/symtab2.obj

C:\devel\pdos\pdcc>objdump -d cpplib/symtab2.obj

cpplib/symtab2.obj: file format pe-x86-64

Disassembly of section .text:

0000000000000000 <symtab_destroy_symtab>:
0: 55 push %rbp
1: 48 8b ec mov %rsp,%rbp
4: 57 push %rdi
5: 57 push %rdi
6: 48 89 4d 10 mov %rcx,0x10(%rbp)
a: 48 89 55 18 mov %rdx,0x18(%rbp)
e: e9 00 00 00 00 jmp 13 <symtab_destroy_symtab+0x13>
13: 48 8b 5d 10 mov 0x10(%rbp),%rbx
17: 48 8b 7b 08 mov 0x8(%rbx),%rdi
1b: 48 8b c7 mov %rdi,%rax
1e: 48 ff cf dec %rdi
21: 48 89 7b 08 mov %rdi,0x8(%rbx)
25: 48 83 f8 00 cmp $0x0,%rax
29: 75 e8 jne 13 <symtab_destroy_symtab+0x13>
2b: 5f pop %rdi
2c: 5f pop %rdi
2d: 5d pop %rbp
2e: c3 ret

C:\devel\pdos\pdcc>

and cc64 even rebuilds itself, with byte exact, and my original
application now appears to work if I only compile the one
source file with the issue.

However, when I compile everything, the new compiler hangs.

Any ideas about that?

Thanks. Paul.

Re: cc64 register preservation

<fe935c09-2810-42c6-8398-5332793de0b0n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28657&group=comp.lang.c#28657

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:18c7:b0:651:62a3:6480 with SMTP id cy7-20020a05621418c700b0065162a36480mr259485qvb.4.1693724843908;
Sun, 03 Sep 2023 00:07:23 -0700 (PDT)
X-Received: by 2002:a17:90a:8f03:b0:271:df39:2332 with SMTP id
g3-20020a17090a8f0300b00271df392332mr1590960pjo.9.1693724843428; Sun, 03 Sep
2023 00:07:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 3 Sep 2023 00:07:22 -0700 (PDT)
In-Reply-To: <771ddf5c-8ce3-4cbb-b5e3-d8affb276cden@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
<a834cc69-5450-484f-8208-1128cc07f041n@googlegroups.com> <771ddf5c-8ce3-4cbb-b5e3-d8affb276cden@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fe935c09-2810-42c6-8398-5332793de0b0n@googlegroups.com>
Subject: Re: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 07:07:23 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2103
 by: Paul Edwards - Sun, 3 Sep 2023 07:07 UTC

I have isolated the test case.

It is presumably related to the return of structs.

They presumably occupy the same area that I just
did two push rdis to.

But this is the compiler hanging, not the code being compiled.

BFN. Paul.

C:\devel\pdos\pdcc\yyy>type expr.i
typedef struct {
char aaa[9]; /* 9+ hangs, 8 does not */
} zzztype;

static zzztype number_trim(zzztype rrrr, int ppp)
{ return (rrrr);
}

static zzztype append_digit(zzztype num,
int mary,
int john,
int yyy)
{ zzztype result;

result = number_trim(result, yyy);

return (result);
}

C:\devel\pdos\pdcc\yyy>doit

C:\devel\pdos\pdcc\yyy>cc64-fudge -c -out:expr.obj expr.i
Compiling expr.i to expr.obj
Terminate batch job (Y/N)? y

C:\devel\pdos\pdcc\yyy>

Re: cc64 register preservation

<ud1kfo$rv5h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28661&group=comp.lang.c#28661

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: cc64 register preservation
Date: Sun, 3 Sep 2023 10:43:19 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <ud1kfo$rv5h$1@dont-email.me>
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 3 Sep 2023 09:43:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2fe4150ee4242951b511edc7abdd1421";
logging-data="916657"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VFFoQxF4nHxuHCW5rZeotwUDGX/oT/tU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:QSmzGw3x2xitYMET9nMkSiHg2QU=
In-Reply-To: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
 by: Bart - Sun, 3 Sep 2023 09:43 UTC

On 03/09/2023 04:07, Paul Edwards wrote:
> Can anyone spot where this compiler:
>
> https://sourceforge.net/p/pdos/gitcode/ci/master/tree/cc64/cc64.c
>
> is preserving registers?

I very much doubt anyone here could answer that (not even me).

You may have posted on email about this but I don't check that all the time.

There is one big restriction in this compiler that I used to keep
pointing out but maybe you missed it:

It is not fully ABI-compliant. This affects 'callback' functions, which
here means cc64-compiled functions being called from any code that is
not cc64-compiled.

(A simple example is calling qsort() with a pointer to a local function.)

It necessary to mark such functions like this:

$callback int fred(int a, int b) {return a+b;}

or (better as code is then acceptable elsewhere) like this:

#pragma $callback
int fred(int a, int b) {return a+b;}

This will save and restore registers the ABI says are volatile. It
applies to the following function only.

There is also a compiler option -callback which effectively applies this
to every function. But that will slow things down (the register-save
code is not efficient), and is only intended to identify whether a
missing $callback was a problem.

(As I said I'm replacing the code generator.)

The original intention of the bcc project was that most programs would
consist of code compiled with itself, and not statically linked to
externally compiled code. So callbacks applied to only a small number of
functions.

Re: cc64 register preservation

<905b99b3-fc63-4c48-9908-bc1951f020b8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28663&group=comp.lang.c#28663

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:584c:0:b0:412:1318:9d4f with SMTP id h12-20020ac8584c000000b0041213189d4fmr195178qth.2.1693735379466;
Sun, 03 Sep 2023 03:02:59 -0700 (PDT)
X-Received: by 2002:a17:902:f686:b0:1c1:f00a:64d5 with SMTP id
l6-20020a170902f68600b001c1f00a64d5mr2520994plg.4.1693735379189; Sun, 03 Sep
2023 03:02:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 3 Sep 2023 03:02:58 -0700 (PDT)
In-Reply-To: <ud1kfo$rv5h$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com> <ud1kfo$rv5h$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <905b99b3-fc63-4c48-9908-bc1951f020b8n@googlegroups.com>
Subject: Re: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 10:02:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2882
 by: Paul Edwards - Sun, 3 Sep 2023 10:02 UTC

On Sunday, September 3, 2023 at 5:43:35 PM UTC+8, Bart wrote:

> There is one big restriction in this compiler that I used to keep
> pointing out but maybe you missed it:
>
> It is not fully ABI-compliant. This affects 'callback' functions, which
> here means cc64-compiled functions being called from any code that is
> not cc64-compiled.

All code has been compiled with cc64 with the exception
of C90 routines in msvcrt.dll.

However, what I can do is statically link my own C library
(compiled with cc64) to see if that solves the problem.

I only use a handful of kernel32 calls, none of them
involving callbacks as far as I am aware.

> It necessary to mark such functions like this:
>
> $callback int fred(int a, int b) {return a+b;}
>
> or (better as code is then acceptable elsewhere) like this:
>
>
> #pragma $callback
> int fred(int a, int b) {return a+b;}
>
> This will save and restore registers the ABI says are volatile. It
> applies to the following function only.
>
> There is also a compiler option -callback which effectively applies this
> to every function. But that will slow things down (the register-save
> code is not efficient), and is only intended to identify whether a
> missing $callback was a problem.

Actually, I'll try this first - thanks!

> The original intention of the bcc project was that most programs would
> consist of code compiled with itself, and not statically linked to
> externally compiled code. So callbacks applied to only a small number of
> functions.

I'm not sure why you think I have externally compiled code.

BFN. Paul.

Re: cc64 register preservation

<a2bf93b1-7451-4adc-9004-e118d6c8c63an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28665&group=comp.lang.c#28665

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:489b:b0:76f:1450:230 with SMTP id ea27-20020a05620a489b00b0076f14500230mr174049qkb.4.1693736886150;
Sun, 03 Sep 2023 03:28:06 -0700 (PDT)
X-Received: by 2002:a17:903:1c4:b0:1bb:cf58:532f with SMTP id
e4-20020a17090301c400b001bbcf58532fmr2688884plh.0.1693736885958; Sun, 03 Sep
2023 03:28:05 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 3 Sep 2023 03:28:05 -0700 (PDT)
In-Reply-To: <905b99b3-fc63-4c48-9908-bc1951f020b8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
<ud1kfo$rv5h$1@dont-email.me> <905b99b3-fc63-4c48-9908-bc1951f020b8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a2bf93b1-7451-4adc-9004-e118d6c8c63an@googlegroups.com>
Subject: Re: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 10:28:06 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3447
 by: Paul Edwards - Sun, 3 Sep 2023 10:28 UTC

On Sunday, September 3, 2023 at 6:03:06 PM UTC+8, Paul Edwards wrote:

> > There is also a compiler option -callback which effectively applies this
> > to every function. But that will slow things down (the register-save
> > code is not efficient), and is only intended to identify whether a
> > missing $callback was a problem.

> Actually, I'll try this first - thanks!

That created some heap allocation error when I ran
the cc64 built with cc64 with that option.

> However, what I can do is statically link my own C library
> (compiled with cc64) to see if that solves the problem.

Building this (without the rdi fudge), has the same
behavior as the rdi fudge (ie crashes - I previously
incorrectly thought it was hanging rather than
crashing). So I think this problem is unrelated to my
rdi fudge.

C:\devel\pdos\cc64>objdump -x cc64-new.exe | grep -i dll
DllCharacteristics 00000140
vma: Hint Time Forward DLL First
DLL Name: kernel32.dll

C:\devel\pdos\cc64>

C:\devel\pdos\pdcc\yyy>type expr.i
typedef struct {
char aaa[9]; /* 9+ hangs, 8 does not */
} zzztype;

static zzztype number_trim(zzztype rrrr, int ppp)
{ return (rrrr);
}

static zzztype append_digit(zzztype num,
int mary,
int john,
int yyy)
{ zzztype result;

result = number_trim(result, yyy);

return (result);
}

C:\devel\pdos\pdcc\yyy>doit

C:\devel\pdos\pdcc\yyy>del expr.asm
Could Not Find C:\devel\pdos\pdcc\yyy\expr.asm

C:\devel\pdos\pdcc\yyy>rem rem cc64-fudge -c -out:expr.obj expr.i

C:\devel\pdos\pdcc\yyy>rem cc64 -s -out:expr.obj expr.i

C:\devel\pdos\pdcc\yyy>\devel\pdos\cc64\cc64-new -s -out:expr.obj expr.i

C:\devel\pdos\pdcc\yyy>rem \devel\pdos\cc64\cc64-new -callback -s -out:expr..obj expr.i

C:\devel\pdos\pdcc\yyy>rem cc64 -s -out:expr.obj expr.i

C:\devel\pdos\pdcc\yyy>dir expr.asm
Volume in drive C has no label.
Volume Serial Number is 4E58-AF11

Directory of C:\devel\pdos\pdcc\yyy

File Not Found

C:\devel\pdos\pdcc\yyy>

BFN. Paul.

Re: cc64 register preservation

<0326a8ca-a0ce-43a6-93f7-6081fe7c9054n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28667&group=comp.lang.c#28667

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:4b70:0:b0:640:32db:a78b with SMTP id m16-20020ad44b70000000b0064032dba78bmr169714qvx.9.1693738199247;
Sun, 03 Sep 2023 03:49:59 -0700 (PDT)
X-Received: by 2002:a17:90b:3d3:b0:26d:26eb:c577 with SMTP id
go19-20020a17090b03d300b0026d26ebc577mr1689697pjb.6.1693738198986; Sun, 03
Sep 2023 03:49:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 3 Sep 2023 03:49:58 -0700 (PDT)
In-Reply-To: <a2bf93b1-7451-4adc-9004-e118d6c8c63an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
<ud1kfo$rv5h$1@dont-email.me> <905b99b3-fc63-4c48-9908-bc1951f020b8n@googlegroups.com>
<a2bf93b1-7451-4adc-9004-e118d6c8c63an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0326a8ca-a0ce-43a6-93f7-6081fe7c9054n@googlegroups.com>
Subject: Re: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 10:49:59 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1360
 by: Paul Edwards - Sun, 3 Sep 2023 10:49 UTC

Sorry - I stuffed something up.

Let me reevaluate and I'll give an update.

Thanks. Paul.

Re: cc64 register preservation

<c73f83d0-3ff8-496e-b8c6-cbd00eef3f7an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28671&group=comp.lang.c#28671

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:2b47:b0:76f:1450:226 with SMTP id dp7-20020a05620a2b4700b0076f14500226mr178277qkb.10.1693746194568;
Sun, 03 Sep 2023 06:03:14 -0700 (PDT)
X-Received: by 2002:a17:90a:8c91:b0:268:3469:d86e with SMTP id
b17-20020a17090a8c9100b002683469d86emr1852234pjo.1.1693746194001; Sun, 03 Sep
2023 06:03:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 3 Sep 2023 06:03:13 -0700 (PDT)
In-Reply-To: <ud1kfo$rv5h$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com> <ud1kfo$rv5h$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c73f83d0-3ff8-496e-b8c6-cbd00eef3f7an@googlegroups.com>
Subject: Re: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 13:03:14 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1937
 by: Paul Edwards - Sun, 3 Sep 2023 13:03 UTC

On Sunday, September 3, 2023 at 5:43:35 PM UTC+8, Bart wrote:

> (A simple example is calling qsort() with a pointer to a local function.)

You got it exactly right - I was calling atexit() with a function
that hadn't been appropriately marked up.

And my previous test stuffed up because I had some dummy
routines to resolve unresolved external references (from
kernel32) that I thought (correctly, it seems) weren't being used,
and the push and pop had inadvertently got into there.

I have now created proper push/pop routines, similar, but not
identical, to yours (because I found an assembler limitation,
separately reported to the author) and now everything works.

Thanks a lot for your assistance, and sorry for any noise!

BFN. Paul.

Re: cc64 register preservation

<0e9738f1-2fe2-4005-bf48-6c147d6d3246n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28680&group=comp.lang.c#28680

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:19a7:b0:76d:86b1:ece8 with SMTP id bm39-20020a05620a19a700b0076d86b1ece8mr219619qkb.12.1693754342979;
Sun, 03 Sep 2023 08:19:02 -0700 (PDT)
X-Received: by 2002:aa7:8881:0:b0:68a:2c24:57d7 with SMTP id
z1-20020aa78881000000b0068a2c2457d7mr3437614pfe.0.1693754342331; Sun, 03 Sep
2023 08:19:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 3 Sep 2023 08:19:01 -0700 (PDT)
In-Reply-To: <c73f83d0-3ff8-496e-b8c6-cbd00eef3f7an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.158.103.193; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 136.158.103.193
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com>
<ud1kfo$rv5h$1@dont-email.me> <c73f83d0-3ff8-496e-b8c6-cbd00eef3f7an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0e9738f1-2fe2-4005-bf48-6c147d6d3246n@googlegroups.com>
Subject: Re: cc64 register preservation
From: mutazi...@gmail.com (Paul Edwards)
Injection-Date: Sun, 03 Sep 2023 15:19:02 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2339
 by: Paul Edwards - Sun, 3 Sep 2023 15:19 UTC

I have had considerable success.

All the tools were able to be compiled, but:

1. I haven't tested on real hardware.

2. There were a few compiler errors that I bypassed
(meaning a runtime error will occur) rather than fix
immediately.

3. bootx64.efi is still built with mingw64. cc64 can
build it, but I haven't put that in yet.

4. Testing under qemu shows that most things don't
work.

5. Only a minimal number of functions in msvcrt.dll have
been provided so far, so it's only meant to display the help
for each tool.

Anyway, at http://pdos.org there is ucx64.zip. Source can
be found on uc386.zip.

You can do:

pdcc.exe --help
pdas.exe --help doesn't crash, but doesn't do much
pdld.exe --help also doesn't crash or do much

Most other executables seem to crash.

But overall, this looks completely viable. There is no
evidence of something fundamental that will prevent
the bugs from being found and fixed/worked around
with minimal changes to the original source code.

Not a bad result for my second solar cycle.

https://en.wikipedia.org/wiki/Solar_cycle_(calendar)

BFN. Paul.

Re: cc64 register preservation

<ud54oj$m9m$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=28733&group=comp.lang.c#28733

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: cc64 register preservation
Date: Mon, 4 Sep 2023 17:39:31 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <ud54oj$m9m$1@reader2.panix.com>
References: <a088eab5-0341-4474-b820-45876cb8d3ddn@googlegroups.com> <905b99b3-fc63-4c48-9908-bc1951f020b8n@googlegroups.com> <a2bf93b1-7451-4adc-9004-e118d6c8c63an@googlegroups.com> <0326a8ca-a0ce-43a6-93f7-6081fe7c9054n@googlegroups.com>
Injection-Date: Mon, 4 Sep 2023 17:39:31 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="22838"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Mon, 4 Sep 2023 17:39 UTC

In article <0326a8ca-a0ce-43a6-93f7-6081fe7c9054n@googlegroups.com>,
Paul Edwards <mutazilah@gmail.com> wrote:
>Sorry - I stuffed something up.
>
>Let me reevaluate and I'll give an update.

Take it to email? This has little to do with C.

- Dan C.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor