summaryrefslogtreecommitdiff
path: root/miniany/README.html
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2024-01-14 19:46:20 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2024-01-14 19:46:20 +0100
commit41568587eaee36488b70e6e76b2f9ea68890471e (patch)
tree87bf362dd5bad006d96983f6848bb3c878b59a2e /miniany/README.html
parent7bde6411b1b82cafd997df8ac222e82280a6e786 (diff)
downloadcompilertests-41568587eaee36488b70e6e76b2f9ea68890471e.tar.gz
compilertests-41568587eaee36488b70e6e76b2f9ea68890471e.tar.bz2
updated todos and documentation
Diffstat (limited to 'miniany/README.html')
-rw-r--r--miniany/README.html29
1 files changed, 27 insertions, 2 deletions
diff --git a/miniany/README.html b/miniany/README.html
index ab8a828..e53cdb9 100644
--- a/miniany/README.html
+++ b/miniany/README.html
@@ -1,3 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CC - a self-hosting, bootstrappable, minimal C compiler</title>
+<meta name="generator" content="md2html">
+</head>
+<body>
<h1>CC - a self-hosting, bootstrappable, minimal C compiler</h1>
<h2>Introduction</h2>
<p>On the never-ending quest of a minimal system I found Swieros and C4 (the C compiler in 4 functions). Inspired and intrigued I started to implement my own.</p>
@@ -320,6 +327,21 @@ cat c4.c4 EOF c4.c EOF cc.c EOF hello.c | ./c4
<ul>
<li>Avoid code duplication (inline assembly in the compiler for the keyword implementation and with inline assembly in the language library). (<b>TODO</b>)</li>
</ul>
+<h3>Function calling conventions</h3>
+<p>Implementation status: yes</p>
+<p>Reasoning:</p>
+<ul>
+<li>Calling conventions, EAX for int or pointer returns, stack as in Pascal in calling order (otherwise we need an AST of the parameters if we want to push them in reverse order). Reverse order is there so that the first parameter is on top of the stack and we now the start of the stack frame, this helps implementing varargs, which we don't want to support.</li>
+<li>Currently we only have ints, chars and pointers, which should fit nicely into simple memory models where pointers and integers are not completely different. char/byte arguments can be pushed as 4-bytes, we could do some stack alignment to simplify things.</li>
+</ul>
+<p>Caveats:</p>
+<ul>
+<li>Operating syscalls follow the EAX, EBX, ECX, EDX, .. int 80h calls on the 32-bit host. There might be our own operating syscalls we want to support later. The compiler should not know about that and a thin layer in the standard library can do the conversion.</li>
+</ul>
+<p>Counter arguments:</p>
+<ul>
+<li>thiscall conventions would be handy if we had some limited C++ this pointer support.</li>
+</ul>
<h2>References</h2>
<p>Compiler construction in general:</p>
<ul>
@@ -329,8 +351,9 @@ cat c4.c4 EOF c4.c EOF cc.c EOF hello.c | ./c4
</ul>
<p>Some special compiler building topics:</p>
<ul>
-<li><a href="https://www.engr.mun.ca/%7Etheo/Misc/exp">https://www.engr.mun.ca/~theo/Misc/exp</a>_parsing.htm#climbing, <a href="https://en.wikipedia.org/wiki/Operator-precedence">https://en.wikipedia.org/wiki/Operator-precedence</a>_parser#Precedence_climbing_method</li>
+<li><a href="https://www.engr.mun.ca/~theo/Misc/exp">https://www.engr.mun.ca/~theo/Misc/exp</a>_parsing.htm#climbing, <a href="https://en.wikipedia.org/wiki/Operator-precedence">https://en.wikipedia.org/wiki/Operator-precedence</a>_parser#Precedence_climbing_method</li>
<li><a href="https://en.wikipedia.org/wiki/Strahler">https://en.wikipedia.org/wiki/Strahler</a>_number: justification for register numbers for register alloation (<b>TODO: </b><b>clarify</b>)</li>
+<li><a href="https://en.wikipedia.org/wiki/X86">https://en.wikipedia.org/wiki/X86</a>_calling_conventions: calling conventions on the IA-32 architecture</li>
</ul>
<p>C4:</p>
<ul>
@@ -342,7 +365,7 @@ cat c4.c4 EOF c4.c EOF cc.c EOF hello.c | ./c4
<p>Other minimal compilers and systems:</p>
<ul>
<li><a href="http://selfie.cs.uni-salzburg.at/">http://selfie.cs.uni-salzburg.at/</a>: <i>Christoph </i><i>Kirsch</i>, C* self-hosting C compiler (also emulator, hypervisor) for RISCV, inspiration for what makes up a minimal C language</li>
-<li><a href="http://www.iro.umontreal.ca/%7Efelipe/IFT2030-Automne2002/Complements/tinyc.c">http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complements/tinyc.c</a>, <i>Marc </i><i>Feeley</i>, really easy and much more readable, meant as educational compiler</li>
+<li><a href="http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complements/tinyc.c">http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complements/tinyc.c</a>, <i>Marc </i><i>Feeley</i>, really easy and much more readable, meant as educational compiler</li>
<li><a href="https://github.com/rswier/swieros.git">https://github.com/rswier/swieros.git</a>: <i>Robert </i><i>Swierczek</i>, c.c in swieros</li>
<li><a href="https://github.com/ras52/boostrap">https://github.com/ras52/boostrap</a>: <i>Richard </i><i>Smith</i>, bootstrapping experiment</li>
<li><a href="http://t3x.org/t3x">http://t3x.org/t3x</a>: <i>Nils </i><i>M </i><i>Holm</i>, the T3X programming language, especially the bootstrapping version T3X9</li>
@@ -357,3 +380,5 @@ cat c4.c4 EOF c4.c EOF cc.c EOF hello.c | ./c4
<li><a href="http://cowlark.com/wordgrinder/index.html">http://cowlark.com/wordgrinder/index.html</a>: the fabulous editor which just does what it should do</li>
<li><a href="https://github.com/mity/md4c">https://github.com/mity/md4c</a>: markdown to HTML in C</li>
</ul>
+</body>
+</html>