Post by Alexei A. FrounzePost by ***@gmail.com"Smaller C" does that, and only with 80386
instructions, and I don't think it is C90-compliant
yet.
I'm thinking of making some improvements w.r.t. compliance,
but I'm not planning to support every single thing that's in the
standard (anywhere between ANSI C and C99). For example,
I'm not going to ever support functions with what's known as
identifier-list (as opposed to parameter-type-list), which is
already absent from C2020.
I think it would be good to change the C90 standard
to whatever YOU are actually willing to support. This
is the real limit, tested by real world exercise.
I would like to adjust to you.
Post by Alexei A. FrounzeVLAs is another questionable feature, which the latest standards
(again, C2020 in particular) make optional.
Complex types are OK, but low priority.
Ok, I'm not sure what that actually is.
Post by Alexei A. FrounzeSome math functions are low priority as well.
Wide characters / Unicode is going to be incomplete too.
Likely the same with time zones, "saving" and leap seconds.
Those things are the C library. I have no interest in that.
Post by Alexei A. FrounzeC2020 adds alignment, atomics, threads, attributes, etc. None
of that is in the plans. Though, anonymous unions are.
Ok, I don't know if I need any of that. I'm not sure
what they are.
Here we go ...
I downloaded your latest Smaller C from here:
https://github.com/alexfru/SmallerC
I checked the license and it looks very liberal
to me, thankyou.
I found the largest .c file and compiled it with
bcc32. I was shocked that it compiled out of
the box.
But would it run?
It did, but just welcomed me with:
C:\devel\pdos\pdpclib>smlrc
Error in "" (1:1)
Input file not specified
I tried --help, -h, -?, nothing would give me usage.
I checked the source file to find out what the help
string was, and didn't find a mention of 8086 or
something like that that would have helped me.
I did of course figure out:
smlrc world.c world.s
which worked, but I can't recognize the assembler,
so didn't know what format it was producing.
I went looking for documentation and found what
looked like what I wanted - "-huge".
I wasn't that concerned about what happened with
the assembler at that point, I wanted to see if it
would choke on PDPCLIB.
It didn't like this:
-#if defined(__CMS__) || defined(__MVS__) || defined(__VSE__)
+#ifdef JUNK___ /* defined(__CMS__) || defined(__MVS__) || defined(__VSE__) */
I use that heavily, so it was disappointing. But I persevered
and found other things it choked on, such as:
-#if ('\x80' < 0)
+#if 1 || ('\x80' < 0)
+ return (0.0);
+#ifdef JUNK___
return (x >= y) ?
(x >= -y ? atan(y/x) : -pi/2 - atan(x/y))
:
(x >= -y ? pi/2 - atan(x/y)
: (y >= 0) ? pi + atan(y/x)
: -pi + atan(y/x));
+#endif
i = (long)value;
- value -= i;
+ /* value -= i; */
-#define offsetof(x, y) (size_t)&(((x *)0)->y)
+/*#define offsetof(x, y) (size_t)&(((x *)0)->y)*/
And I managed to get a clean compile.
Next thing was to see if I could get my version
of nasm to accept it. I didn't have any examples
of how to run nasm in my own code. nasm -h
gave usage, but not what I was looking for, ie
how to do an assembly only. I went back to your
documentation to see if you mentioned how to
run nasm, which you did. I tried that, but nasm
didn't like -f bin on your assembler output. But
the "-f" gave me a hint that I needed "-f" and I
was wondering why I didn't see that in the usage.
I found it in the first line:
usage: nasm [-@ response file] [-o outfile] [-f format] [-l listfile]
but that is useless. I needed something like this:
-t assemble in SciTech TASM compatible mode
They should have put "-f" before "-t" with a description.
It took a while, but I finally figured out this cryptic message:
For a list of valid output formats, use -hf.
For a list of debug formats, use -f <form> -y.
I tried nasm -hf
and got close to what I needed.
I latched on to this:
aout Linux a.out object files
and since I was familiar with a.out, I gave that a go,
but it didn't like your assembler code either.
Then I noticed:
obj MS-DOS 16-bit/32-bit OMF object files
And yay, I got what I wanted, a clean assemble!
So we're in business.
For some reason I went back to your documentation
and noticed this:
* most of the _preprocessor_. The core compiler (smlrc) relies on an
external preprocessor (smlrpp (which is a version of ucpp adapted for use
with Smaller C) or gcc).
But I couldn't find a source file with that name.
I went back to the documentation, but didn't
find that.
But I had noticed a smlrpp.md so I tried looking in
that and found:
gcc -Wall -O2 -o smlrpp -DSTAND_ALONE -DUCPP_CONFIG arith.c assert.c cpp.c eval.c lexer.c macro.c mem.c nhash.c
I tried using that exact command where I found
the source code, and it worked with no warnings
or anything.
A few attempts and I found:
smlrpp -h
This led me to try:
smlrpp -zI -I . -o math.e math.c
and I was surprised that it ran without error. I checked
math.e and it looked reasonable.
So now to put my code back.
It worked! I no longer had preprocessor problems.
Compilation errors were mainly involving floating
point, but I don't care about that.
+#if !defined(__SMALLERC__)
fpval*=10.;
+#endif
This is the only one I care about:
+#if !defined(__SMALLERC__)
tms.tm_wday = dow(tms.tm_year + 1900, mo, da);
+#endif
Why is it choking on that?
smlrc -huge -I . time.e time.s
Error in "time.c" (310:322)
Expression too long
Oh, I know why. It's a huge macro.
#define dow(y,m,d) \
((((((m)+9)%12+1)<<4)%27 + (d) + 1 + \
((y)%400+400) + ((y)%400+400)/4 - ((y)%400+400)/100 + \
(((m)<=2) ? ( \
(((((y)%4)==0) && (((y)%100)!=0)) || (((y)%400)==0)) \
? 5 : 6) : 0)) % 7)
That's not very neat to work around. I need to
provide a function instead. I have one of those
too, but is there a reason why there is a limit on
this valid C code?
I'm happy to just return random dow's for now.
Now for what counts - pdos.c
smlrc -huge -I . pdos.e pdos.s
Error in "fat.h" (84:27)
Identifier table exhausted
I don't know why it's complaining about that:
/*Structure for Directory Entry */
typedef struct {
unsigned char file_name[8]; /*Short file name (0x00)*/
unsigned char file_ext[3]; /*Short file extension (0x08)*/
unsigned char file_attr; /*file attributes (0x0B)*/
unsigned char extra_attributes; /*extra attributes (0x0C)*/
I can't progress without that.
All code can be found here:
https://sourceforge.net/p/pdos/gitcode/ci/master/tree/
My Smaller C mods have been committed.
Thanks for the great product!!! Any idea about that fat.h?
I may be able to produce a heaps better PDOS/86 that
does proper memory allocation.
BFN. Paul.