Closed DoctorWkt closed 5 months ago
Alan, I reworked the runtests script in Fuzemsys to hopefully correct the timing and output ordering issues. There's a weird bug in tests/test032.c which is running the readdir() code. The code around line 62 is copying the filename:
runtests
tests/test032.c
readdir()
strncpy(buf->d_name, (char *) direntry->d_name, 31);
but nothing gets printed out when readdir() returns. However, if I surround this line with:
printf("foo"); strncpy(buf->d_name, (char *) direntry->d_name, 31); printf("foo\n");
then I get the output:
foofoo textfile1.txt foofoo . foofoo ..
with the three expected filenames in the in/ directory.
in/
Question: when I change the source code to print the destination after the strncpy():
strncpy()
strncpy(buf->d_name, (char *) direntry->d_name, 31); printf(buf->d_name);
the 6809 assembly is:
ldd #31 pshs d ldd 2,s addd #2 pshs d tfr u,d addd #10 pshs d lbsr _strncpy+0 leas 6,s ; tfr u,d <==== Assumes U is intact addd #10 pshs d lbsr _printf+0 leas 2,s ;
But at the top of the strncpy() assembly:
_strncpy: leas -2,s ldu 4,s <==== Overwrites U
Perhaps U needs to be invalidated on some function calls? Or get the callee to save/restore U?
Cheers, Warren
Functions using u should indeed be saving/restoring it. I forgot to add that when I added the register stuff in .. oops
Alan, I reworked the
runtests
script in Fuzemsys to hopefully correct the timing and output ordering issues. There's a weird bug intests/test032.c
which is running thereaddir()
code. The code around line 62 is copying the filename:but nothing gets printed out when
readdir()
returns. However, if I surround this line with:then I get the output:
with the three expected filenames in the
in/
directory.Question: when I change the source code to print the destination after the
strncpy()
:the 6809 assembly is:
But at the top of the
strncpy()
assembly:Perhaps U needs to be invalidated on some function calls? Or get the callee to save/restore U?
Cheers, Warren