GithubHelp home page GithubHelp logo

misazhu / tinycc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gfwilliams/tinycc

0.0 3.0 0.0 2.68 MB

Property hacked up version of the Tiny C Compiler with basic ARM Thumb output

License: GNU Lesser General Public License v2.1

CMake 0.59% Makefile 0.91% C 92.89% C++ 4.53% Assembly 0.54% Shell 0.03% Python 0.02% Perl 0.41% Batchfile 0.07%

tinycc's Introduction

ARM Thumb output

To use this:

  • Configure it with cross-compilation enabled, then use any ARM target
  • I've been using ./arm-linux-gnueabi-tcc -nostdinc -nostdlib -c test.c -o test.o to compile, and arm-none-eabi-objdump -S test.o to dump the output
  • I was comparing it with what I got from arm-none-eabi-gcc -mlittle-endian -mthumb -mcpu=cortex-m3 -mfix-cortex-m3-ldrd -mfloat-abi=soft -nostdinc -nostdlib -c test.c -o test.o

In terms of implementation:

  • Everything is in arm-gen.c.
  • tcc-gen.c has a single mod, which adds one to the symbol address (signifying that the symbol is Thumb, not ARM). There must be a nicer way of doing this, but hey - proof of concept.
  • I added ot() which outputs a thumb instruction - the original o() would output a 32 bit ARM instruction - so every call to o() needs replacing with a thumb equivalent
  • The function prolog/epilog is hacked up at the moment so only works with very basic stuff (no stack pushing)
  • encbranch/decbranch/gsym_addr do seem to work, but encbranch won't work reliably for conditional branches as these have less bits for the address

Would be nice:

  • Ideally we'd start out with a new thumb-gen.c containing stubs - it would get rid of the RELICENSING issue
  • Find a way to separate ARM and Thumb code gen (ideally separate files), and maybe make TCC respect the -mthumb switch like GCC does (rather than having a separate binary).

test.sh

#!/bin/bash
arm-none-eabi-gcc -mlittle-endian -mthumb -mcpu=cortex-m3  -mfix-cortex-m3-ldrd -mfloat-abi=soft -nostdinc -nostdlib -c test.c -o test.o 
echo ------------------------------------------------
echo   GCC
echo ------------------------------------------------
arm-none-eabi-objdump -S test.o
mv test.o test-gcc.o


./arm-linux-gnueabi-tcc -nostdinc -nostdlib -c test.c -o test.o 
echo ------------------------------------------------
echo   TCC
echo ------------------------------------------------
arm-none-eabi-objdump -S test.o
mv test.o test-tcc.o

test.c

// test.c
int foobar() {
  return 4;
}

Original README

is here

tinycc's People

Contributors

jsoroka avatar robotux avatar xppxppgh avatar s09bq5 avatar susematz avatar navytux avatar mingodad avatar shinh avatar minux avatar akimd avatar vinc17fr avatar mikijov avatar winspool avatar roytam1 avatar timovjl avatar perexg avatar gfwilliams avatar gec75 avatar xcm avatar aldot avatar austin987 avatar iavael avatar lifenjoiner avatar 0lisp avatar bobbl avatar kodawah avatar amanone avatar sergv avatar rfrancoise avatar nmav avatar

Watchers

James Cloos avatar May the source be with you avatar  avatar

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.