Skip to content

evertonse/tinycc-poxim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny C Compiler

This project tries to extend tiny c compiler to support Poxim Architecture

Requirements

  • C++14 capable compiler
  • C99 capable compiler
  • Linux (Only)
  • Make
  • Posix Shell (we're using shell in poxim.mak)

Compiling TCC with Poxim Backend

$ ./configure --cpu=poxim --cc=gcc

$ make run CXX=clang++

Feel free to change the CXX variable to another C++14 capable compiler. Same goes for --cc option.

This will compile tcc with Poxim Backend and run it on the examples/main.c file that produces examples/bin/main.bin binary file. By default it also runs the other examples.

Now inspect the examples/out/ folder. You'll see both interp and dump folder that contains the output of interpretation and dumping of examples/bin/main.bin file respectively.

If you just want to compile the tcc-poxim you can run the below instead.

$ make all

To see Poxim Terminal output generated by examples/main.c run:

$ make display

Running Minimal Example

You can edit the file examples/minimal.c that already includes the minimal setup

To compile and interpret the same way as the other examples run:

$ make examples

This will generate

  • examples/out/bin/minimal.bin, examples/out/bin/minimal.hex
  • examples/out/interp/minimal.interp, examples/out/interp/minimal.term
  • examples/out/bin/minimal.poxim.dump

Compiling your own input.c

$ ./tcc input.c -o output.bin

Important

The output is raw binary poxim machine code with no runtime, statically linked, with no libc, you have to define _start function/label yourself, also for copying array and struct (in argument passing for example) you need to define memset and memmove as well, see examples/_start.h to see how it can be done.

Memory Dump

$ ./poxim-dump --bin input.bin output.dump

Execution

Execute the bytes, the machine code.

$ ./poxim-interp --bin input.bin output.interp

This will create two files called output.interp and output.term.

The output.term has the output of poxim terminal. The other one has both the tracing and terminal. This is done because it might be slow to open output.interp.


Playground Replit

Open Replit link below and press the Run button to compile the C compiler tcc-poxim (executable is named only tcc), compile all .c files in the examples folder using tcc-poxim, dump and interpret these files in the examples/out/dump/ and examples/out/interp/ respectively.

This will load the Enviroment, run and show the output on a console right in the middle

To edit the files you can fork it such as this (has to be logged on replit):

Then you'll have access to anything you wanna change, just edit any file .c under examples folder and it will be compiled and interpret when you press the Run button on Replit

Docs

Look folder docs there will have 3 pdfs and 1 video

PDFs:

  • 2023-10-02-IHS-Apresentacao.pdf, this one is my real life presentation of the project
  • Poxim-Instruction-Set.pdf, this is the instruction set for the Poxim Architecture
  • Poxim-Backend-Details.pdf, this pdf shows how tcc-poxim works internally, what are the limitations and features implemented.

Video:

  • TCC-Compile,Dump,Interpret.mkv, this is a video of me compiling and running tcc-poxim

Resources Used

Tips

If you're cross compiling for i386 pacman -S lib32-glibc is necessary. This might be useful for comparing outputs

Releases

No releases published

Packages

No packages published

Languages

  • C 94.6%
  • C++ 2.5%
  • Assembly 1.2%
  • Makefile 1.0%
  • Perl 0.3%
  • Shell 0.3%
  • Batchfile 0.1%