EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
45 stars 11 forks source link

6809: commit 47fa411 breaks a test #67

Closed DoctorWkt closed 5 months ago

DoctorWkt commented 5 months ago

Commit 47fa411 breaks test029 in Fuzemsys. It's this line:

printf("Character %c\n", 'w');

Now, the letter w isn't being printed out. The problem isn't in the code above, but somewhere in the stdio library.

DoctorWkt commented 5 months ago

It's definitely vfprintf.s. I built libc.a from commits 81573045 and 47fa411, then extracted the vfprintf.o from both.

$ ar vr /opt/fcc/lib/6809/libc.a 47fa/vfprintf.o
<fails>
$ ar vr /opt/fcc/lib/6809/libc.a 8157/vfprintf.o
<works>

We have:

*** 8157/vfprintf.s     2024-05-09 09:36:22.590483543 +1000
--- 47fa/vfprintf.s     2024-05-09 09:37:54.858561082 +1000
***************
*** 680,686 ****
        tfr u,d
        stb [17,s]
  ;
!       clr 1,s
  ;
        ldb 16,s
        lbsr __boolc
--- 680,686 ----
        tfr u,d
        stb [17,s]
  ;
!       clr [17,s]  <== Doesn't look right, given we just stb'd here.
  ;
        ldb 16,s
        lbsr __boolc

I'm going to surmise that it's this code:

                       case 'c':       /* Character */
                                i = va_arg(ap, int);
                              Chr:ptmp[0] =
                                    i;
                                ptmp[1] = '\0';   <==== perhaps
                                if (hash) {
                                        pad = *ptmp;
                                        goto chrpad;
                                }
                                goto nopad;

And replacing the '\0' with 15 we get:

        tfr u,d
        stb [17,s]
;
        ldb #15
        ldx 17,s
        stb 1,x
DoctorWkt commented 5 months ago

I also added test037 to Fuzemsys which tickles the same issue.