The first C compiler made to work under modern GCC

Overview

first-cc-gcc

A port of the earliest C compiler to modern GCC. The compiler outputs PDP-11 assembly code that can be compiled and run on a PDP-11 emulator. The compiler runs only in 32 bit mode as the original code assumes that the pointer size and word size are the same.

Usage

To compile the compiler and run it simply do:

make
./cc examples/fizzbuzz.c > fizzbuzz.s

Note: if you get errors on missing "bits/libc-header-start.h" headers make sure you have the 32bit libc installed.

Emulator

The hard part is to set up an emulator, transfer the file to it(!) and run the assembler. A very early UNIX implementation based on SIMH is available. For Windows, there is also a pre-built binary

I could not get the tape emulators working so ended up with a hacky solution to transfer files. The simulator lets you to log in via telnet, so the files are copied by starting up a text editor on the simulator and streaming the characters into it and then saving and closing the file.

Also, if you close the connection the session is lost, so it is important to keep the connection to the simulator alive with a hack using ncat.

# Start emulator
pdp11 simh.cfg
# Open a pipe to the simulator
# If you use the prebuilt Windows simulator, use port 12323
ncat -lk -p 5556 | ncat localhost 5555

# send login username to emulator
echo root | emulator/emucat
# copy file over by typing it into ed
emulator/cpfile fizzbuzz.s /fizzbz.s 
# call assembler and linker
emulator/emucc /fizzbz.s 
# execute the compiled program
echo a.out | emulator/emucat

Note that the file is called fizzbz.s on the emulator. This is because the UNIX used here handles 8 character long filenames only!

Old C features

This version of C is from around 1972. While the general syntax is pretty much the same as today, there are tons of missing features:

  • no preprocessor, no for loops
  • even though there is a keyword for float and double, floating point calculations are not implemented, you can not even write a floating point literal
  • the type system is very weak: pointers, chars, ints can be freely converted into one another
  • types of the function parameters are not checked, anything can be passed to any function
  • compound assignment operators are reversed, they are =+, =*
  • only integer global variables can be defined, and the syntax is strange (see helloworld example)
  • variable names can be of any length but only the first 8 characters are used; i.e. deadbeef1 and deadbeef2 are effectively the same variables

Interestingly, some features that were already existing in this early version:

  • function pointers
  • the ABI is nearly the same as today's 32 bit ABI
  • a[b] is implemented as *(a+b)
Issues
  • Build error with CMake under ubuntu v18

    Build error with CMake under ubuntu v18

    cmake version 3.10.2 Hi there,

    It could not be built under my ubuntu server as:

    cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release CMake Error: The source directory "/home/henry/Study/FunFromGithub/avium/build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.

    Thanks

    opened by HenryXin 1
A modern day direct port of BOOM 2.02 for modern times. Aiming to tastefully continue the development of BOOM, in the style of TeamTNT.

ReBOOM ReBOOM is a continuation of the BOOM source port, version 2.02. what is it ReBOOM is a source port, directly ported from BOOM 2.02 with additio

Gibbon 12 Jul 27, 2022
C implementation of Random Depth-first search algorithm with back tracking

Maze Generating Algorithm This is an implementation of Randomized depth-first search algorithm. It creates a maze by taking a random valid path and co

Jonas STIRNEMANN 2 May 2, 2022
Get the ability to use variable argument lists in C++ without requiring the first parameter! Meant to support a WG14 proposal to fix up not having empty argument lists.

Vargs Alright, it's time to commit code crimes for the greater good! What if you did not need to pass an initial parameter to your C++ ... functions?

Shepherd's Oasis 3 Dec 2, 2021
Rajesh Kumar Sah 1 Nov 20, 2021
cartographer work space with detailed comments

cartographer 超详细注释 基于2021.04.20日在github上下载的master的代码的注释版本, 会增加更规范、详细的注释, 包括: 1、增加关键地方的公式推导 2、难理解部分代码画图展示原理 3、原作者代码本身疑似/确定bug的说明 by lixiang 注释多数在 .cc 文

xiangli 338 Aug 5, 2022
Class containing Anti-RE, Anti-Debug and Anti-Hook methods. Made for C++/CLI

Umium Class containing Anti-RE, Anti-Debug and Anti-Hook methods. Easy to use and easy to implement. Disclaimer This code has been made and optimized

null 38 Aug 1, 2022
Allocator Aware Containers Made Easy

Custom Allocator Aware containers made easy with "wit" Have you ever looked at the allocator specification and thought about how hard it would be to

Darth Rubik 4 Sep 25, 2021
"Wireless Made Easy!" - Microchip MRF MiWi package is MiWi P2P and Star Stacks for MRF24J40 and MRF89XA transceivers running on MPLAB X IDE

MRF-MiWi "Wireless Made Easy!" - Microchip MiWi P2P and Star Stack Opened for MRF24J40 and MRF89XA transceiver running on MPLAB X IDE Devices: | MRF24

Microchip Technology 2 Dec 28, 2021
FEMTIC is a 3-D magnetotelluric inversion code. FEMTIC is made by object-oriented programming with C++.

FEMTIC FEMTIC is a 3-D magnetotelluric inversion code based on the following studies. FEMTIC was made using object-oriented programming with C++. FEMT

Yoshiya Usui 14 Jul 29, 2022
A simple repo with different data structure programs made in C.

Hacktoberfest 2021 - Expert This is an intermediate-level project to help you get started with your [hacktoberfest] (https://hacktoberfest.digitalocea

null 14 Jun 1, 2022
Data Structures And Algorithms Made Easy

Data Structures And Algorithms Made Easy Copyright (c) August 28, 2016 CareerMonk Publications and others. E-Mail : [email protected] Last modificat

Narasimha Karumanchi 377 Aug 5, 2022
C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types, continuous memory storage, and no pointers are involved

C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types, continuous memory storage, and no pointers are involved

Hossein Moein 1.5k Aug 4, 2022
Simple-MySQL-API is a free and easy API to manipulate MySQL with C99 and GCC compiler under GNU/Linux OS.

Simple-MySQL-API is a free and easy API to manipulate MySQL with C99 and GCC compiler under GNU/Linux OS.

Neptune 7 Apr 24, 2022
✔️The smallest header-only GUI library(4 KLOC) for all platforms

Welcome to GUI-lite The smallest header-only GUI library (4 KLOC) for all platforms. 中文 Lightweight ✂️ Small: 4,000+ lines of C++ code, zero dependenc

null 6.3k Jul 31, 2022
Minimal C++17 project using the GCC compiler and is checked by Travis CI

travis_gcc_cpp17 Branch Status master develop This GitHub is part of the Travis C++ Tutorial. The goal of this project is to have a clean Travis CI bu

Richel Bilderbeek 22 Jul 22, 2021
A modern-day Boss Key software tool. Switch instantly from work to play & play to work with Bosky.

Bosky By: Seanpm2001, Bosky-dev Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrika

Sean P. Myrick V19.1.7.2 1 Nov 11, 2021
Orca - Advanced Malware with multifeatures written in ASM/C/C++ , work on all windows versions ! (some features still under developing and not stable)

About Orca Orca is an Advanced Malware with multifeatures written in ASM/C/C++ features Run in Background (Hidden Mode) Records keystrokes and saves t

anas 166 Aug 3, 2022
gcc-poison

gcc-poison gcc-poison is a simple header file for developers to ban unsafe C/C++ functions from applications. It uses the #pragma GCC poison directive

LeafSR 182 Jul 13, 2022
Easing the task of comparing code generated by cc65, vbcc, and 6502-gcc

6502 C compilers benchmark Easing the way to compare code generated by cc65, 6502-gcc, vbcc, and KickC. This repository contains scripts to: Compile t

Sylvain Gadrat 16 Dec 15, 2021
Some GCC plugins useful for OI training/judging.

gcc-plugin-for-oi Some GCC plugins useful for OI training/judging. Currently, only one plugin no_opt_attr_plugin is included. Build Simply make all. O

Xidian University Programming Contest Training Base 3 Mar 14, 2022
Porting RT-Thread for Gowin GW1NSR-4C Soc GCC version

Porting RT-Thread for Gowin GW1NSR-4C Soc GCC version Hello everyone, this project based on RT-THREAD NANO 3.1.5 and GOWIN GW1NSR-4C Soc chip. The com

Ray 3 Apr 23, 2022
Visual Studio and GCC precompiled header macro for CMake

cmake-precompiled-header Precompiled header setup for CMake. Supported CMake generators: Visual Studio NMake Makefiles Unix Makefiles (GCC) MinGW Make

Lars Christensen 157 Jul 26, 2022
An implementation of memcpy for amd64 with clang/gcc

memcpy-amd64 A memcpy library for amd64 platforms. Parameters void memcpy_<set/get>_erms_threshold(size_t) (default 2048): threshold to use rep movsb

Schrodinger ZHU Yifan 13 Feb 5, 2022
GCC/gcov code coverage data extraction from the actual embedded system, without requiring a file system, or an operating system, or standard C libraries.

GCC/gcov code coverage data extraction from the actual embedded system, without requiring a file system, or an operating system, or standard C libraries.

NASA Jet Propulsion Laboratory 88 Jul 22, 2022
Take your first step in writing a compiler.

first-step Take your first step in writing a compiler. Building from Source Before building first-step, please make sure you have installed the follow

PKU Compiler Course 27 Jul 22, 2022
Colang - Programming language and compiler —WORK IN PROGRESS—

Co programming language Building Initial setup: ./init.sh will install the following into deps/: ckit build tool and rbase library ckit-jemalloc memor

Rasmus 70 Jul 24, 2022
This was the first ever Computer Science project that I made back in Class XII (2016). I thought I should upload it on GitHub so that it does not get lost. :)

First Ever Project This was the first ever Computer Science project that I made back in Class XII (2016). I thought I should upload it on github so th

Kshitiz Srivastava 3 Jun 7, 2021
First Growtopia Private Server made with ENet

GrowtopiaServer First Growtopia Private Server made with ENet. This project has been compiled with Visual Studio 2015 (Visual Studio 2013 or older won

Lyte 10 Oct 21, 2021
My first Game was made by C++

Project_GallowsGame My first Game was made by C++ The game is created for a one-time launch a Hangman game) 1)File ".gitignore.txt" help dont see Game

null 3 Feb 4, 2022