ncb85 / smallc-85 Goto Github PK
View Code? Open in Web Editor NEWRon Cain's Small C public domain compiler revived after 30 years.
License: Other
Ron Cain's Small C public domain compiler revived after 30 years.
License: Other
Revived version of SmallC based on Chris Lewis' port to UNIX V. I have mainly rewritten code to use structures and to make it compile using GCC silently without warnigns. Support for one line comments from C99 specification was added as well as capability to handle Windows EOLs. Initialisation of global variables is also possible. When not initialised global var is assigned zero at compile time. Furthermore support for ANSI style method declaration, support for unsigned types, support for undocumented 8085 istructions LHLX, SHLX, LDSI, ARHL and support for structs and unions have been added. Generated code is suitable for ASXXXX assembler/linker. SmallC compiled for win32 can be downloaded here: https://drive.google.com/file/d/0B2TmWnRjWCj2alRqZHM1VEgwNFE/edit?usp=sharing -------------------------- original posting ------------------------------ Small C version C3.0R1.1 (SCC3) Chris Lewis This directory contains the source for a version of Ron Cain's Small C compiler that I have heavily modified - beyond the Small-C V2.0 later published in Dr. Dobbs. This compiler generates assembler source code that needs to be assembled and linked to make a running program. Small C is a public domain compiler for a subset of C. The main things lacking are "#if", structs/unions, doubles/floats/longs and more than one level of indirection. Even so, it's powerful enough to be able to compile itself. It's also lots of fun to play around with. It could use lots of more work (eg: a real scanner), but what the heck... Retargetting the compiler requires only relinking the frontend with a new code generator. Code generators for 6809 (MIT UNIX-like assembler), M68K (Motorola V/68 UNIX assembler), VAX (BSD 4.1 assembler), and 8080 (RMAC assembler) are provided. Users having access to System V make should be able to use the Makefile without any modification except for INCDIR and LIBDIR (where you'd like to put the compiler itself). Users not having access to System V will probably have to rewrite the Makefile. [ I have provided a Makefile that seems to work with bsd systems - mod] WARNING: you will probably see a great deal of compilation warnings when you compile this compiler with a "real" UNIX C. Don't worry - this is *perfectly* normal - Small C is a subset of real C, and in order to keep the compiler in this subset you have to bend the rules somewhat. The only time where this might cause a problem is where pointers are "different" from ints (ie: different length or on non-byte-addressible machines). Small C assumes that ints are the same as pointers. Invocation: scc<6809|vax|m68k|8080> filename There are other options available - see main.c for details. The code generated by these compilers need a run-time support library for two things: operations that are "hard" on a particular processor (eg: 16 bit multiply on an 8080), or O/S interface (vax is BSD 4.1, 6809 is FLEX, 8080 is CPM, never had one for M68k). Status: the 6809, VAX and 8080 versions work last I checked - a problem or two may have crept in during the implementation of the compile/assemble/and link code for machines that support it. The M68k version has never been tested. I don't have a Pyramid version because Pyrcorp seems reluctant to publish instruction set information. So you want to write a new coder do you? Well, it's easy - read the comments in one of the coders. You should not have to modify *any* of the existing files, just write a new codexxx.c file. Please contact me if you run into trouble. I would be greatly interested in any new coders or bug reports in the compilers. As far as I am aware, the major restriction on porting this thing for different targets is that pointers and integers *must* be the same length, alignment, and be interchangeable.
Is this compiler used inside any tool-chain? Any example of a project that uses it to build a runnable binary?
Is it usable with ACK tools (Amsterdam compiler for I8080 and other CPUs)?
Which linkers, which assemblers can be used?
Has it be used to build Cp/m-80 binaries or other 8080/8085-based systems?
Sorry to be raising this in an issue. With all the changes I was working through in my silence-warnings branch, it was only after I did my massive merge that I remembered a single line bug I wanted to report and fix.
Line 485 of expr.c reads:
if ((ch () != '+') & (ch () != '-') | nch() == '=')
I'm pretty sure the intent is not to perform bit masking, but to perform comparison. So the line should read:
if ((ch () != '+') && (ch () != '-') || nch() == '=')
It is well known that SmallC throws up a lot of compiler warnings. Root cause is the wide and diverse
couplings and dependencies among the modules.
I've made changes in my own fork that silences the warnings that Mac clang raises. (The fork is still local. I'll be pushing it to github very It required touching every source file, and creating a new include file extern.h that allows all the modules to
see clean forward declarations of all the procedures they need.
Before I make a pull request that touches every file in the tree, I figured I should open an Issue to discuss.
Feel free to review code in my fork.
If primary generates an error it generates an immediate 0, but does not set lval->symbol and lval->indirect to 0, which causes a memory scribble and can crash.
Also symname should only copy NAMEMAX bytes then discard the remainder
And fix_include_name() should use strncat/strlcat
The top one is an annoying bug, the others are more of an amusement but do mean I can feed scc8080 source code that forks a shell and executes arbitrary code!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.