Giter Site home page Giter Site logo

smallc-85's Introduction

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.

smallc-85's People

Contributors

ncb85 avatar lcgamboa avatar edwardwawrzynek avatar gip-gip avatar poetnerd avatar

Stargazers

 avatar zu2 avatar  avatar Bill Jones avatar Immanuel Daviel A. Garcia avatar Humberto Costa avatar  avatar Sven Michael Klose avatar Sebastian Hack avatar  avatar bluestar_ avatar mohamad hani janaty avatar  avatar igor avatar molety avatar Leonard Mosescu avatar  avatar Tomi Häsä avatar PtrMan avatar  avatar Annamalai avatar G.M. Rimakis avatar Wandeson Ricardo avatar Abdulselam Karahan avatar Nikita Kalaganov avatar Nathan Barta avatar  avatar  avatar edo avatar Peter Yoon avatar Jaldhar H. Vyas avatar Madgarden avatar Douglas Quagliana avatar  avatar Artem Mironov avatar Michael Richmond avatar  avatar Christopher Reed avatar Bruce Morgan avatar Backwoods Bob avatar Bobble the Clown avatar Peter Jakubčo avatar Bocke avatar Galip Usta avatar Álvaro Torralba avatar chad royal avatar Zak Fenton avatar Fábio Souza avatar  avatar  avatar Дмитрий Цветков avatar Jeffrey H. Johnson avatar Grigore Stefan avatar Stan Nash avatar Doj avatar Hèctor Marquès avatar Sara Tasche avatar UnderratedDev avatar Jevin Sweval avatar Marcin Chwedczuk avatar  avatar Johnson ZHUANG avatar  avatar Paweł Pyrek avatar Haroldo de Oliveira Pinheiro avatar Mykola Konyk avatar Mahyar Koshkouei avatar Sergey Makeev avatar Wynter Woods avatar Hans Koch avatar Alexander Jobling avatar Nikos Papadopoulos avatar Neo_Chen (BU4AK) avatar Vitor Hugo avatar Skidder avatar David Ralph avatar David Capello avatar xhe avatar lolisamurai avatar  avatar chris west avatar MiguelVis avatar  avatar Andrea Pascal avatar Maki Kato avatar mdmx avatar Ethan Durrant avatar Yaotian Feng avatar  avatar Ruslan V. Uss avatar Midnoclose avatar  avatar Jett avatar  avatar  avatar  avatar  avatar Alexander Troosh avatar Lion avatar Jon Mayo avatar

Watchers

Eleanor McHugh avatar Jevin Sweval avatar Brian Holman avatar  avatar Kenn avatar  avatar MiguelVis avatar  avatar Bill Jones avatar Galip Usta avatar  avatar Zachary Napier avatar G.M. Rimakis avatar  avatar

smallc-85's Issues

[Question] Any suggested linker and toolchain? Any example?

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?

expr.c line 485 is assigning not testing.

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() == '=')

Known issue: Lots of compiler warnings. I propose a solution.

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.

Crash caused by missing lvalue initializer / Exploitable buffer overruns

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.