diff options
Diffstat (limited to 'miniany/README.txt')
-rw-r--r-- | miniany/README.txt | 87 |
1 files changed, 58 insertions, 29 deletions
diff --git a/miniany/README.txt b/miniany/README.txt index 1234b4a..d321f72 100644 --- a/miniany/README.txt +++ b/miniany/README.txt @@ -505,6 +505,32 @@ Features and Requirements keyword implementation and with inline assembly in the language library). (TODO) + Function calling conventions + + Implementation status: yes + + Reasoning: + * 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. + * 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. + + Caveats: + * 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. + + Counter arguments: + * thiscall conventions would be handy if we had some limited C++ this + pointer support. + References Compiler construction in general: @@ -521,60 +547,63 @@ References nce_climbing_method * [5]https://en.wikipedia.org/wiki/Strahler_number: justification for register numbers for register alloation (TODO: clarify) + * [6]https://en.wikipedia.org/wiki/X86_calling_conventions: calling + conventions on the IA-32 architecture C4: - * [6]https://github.com/rswier/c4.git, C4 - C in four functions, + * [7]https://github.com/rswier/c4.git, C4 - C in four functions, Robert Swierczek, minimalistic C compiler running on an emulator on the IR, inspiration for this project - * [7]https://github.com/rswier/c4/blob/switch-and-structs/c4.c, c4 + * [8]https://github.com/rswier/c4/blob/switch-and-structs/c4.c, c4 adaptions to provide switch and structs - * [8]https://github.com/EarlGray/c4: a X86 JIT version of c4 - * [9]https://github.com/jserv/amacc: based on C4, JIT or native code, - for ARM, quite well documented, also very nice list of compiler - resources on Github page + * [9]https://github.com/EarlGray/c4: a X86 JIT version of c4 + * [10]https://github.com/jserv/amacc: based on C4, JIT or native + code, for ARM, quite well documented, also very nice list of + compiler resources on Github page Other minimal compilers and systems: - * [10]http://selfie.cs.uni-salzburg.at/: Christoph Kirsch, C* + * [11]http://selfie.cs.uni-salzburg.at/: Christoph Kirsch, C* self-hosting C compiler (also emulator, hypervisor) for RISCV, inspiration for what makes up a minimal C language - * [11]http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complem + * [12]http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complem ents/tinyc.c, Marc Feeley, really easy and much more readable, meant as educational compiler - * [12]https://github.com/rswier/swieros.git: Robert Swierczek, c.c in + * [13]https://github.com/rswier/swieros.git: Robert Swierczek, c.c in swieros - * [13]https://github.com/ras52/boostrap: Richard Smith, bootstrapping + * [14]https://github.com/ras52/boostrap: Richard Smith, bootstrapping experiment - * [14]http://t3x.org/t3x: Nils M Holm, the T3X programming language, + * [15]http://t3x.org/t3x: Nils M Holm, the T3X programming language, especially the bootstrapping version T3X9 Assembly: - * [15]https://github.com/felipensp/assembly/blob/master/x86/itoa.s, + * [16]https://github.com/felipensp/assembly/blob/master/x86/itoa.s, for putint (early debugging keyword) - * [16]https://baptiste-wicht.com/posts/2011/11/print-strings-integers + * [17]https://baptiste-wicht.com/posts/2011/11/print-strings-integers -intel-assembly.htm (early debugging keyword) Documentation: - * [17]http://cowlark.com/wordgrinder/index.html: the fabulous editor + * [18]http://cowlark.com/wordgrinder/index.html: the fabulous editor which just does what it should do - * [18]https://github.com/mity/md4c: markdown to HTML in C + * [19]https://github.com/mity/md4c: markdown to HTML in C References 1. https://github.com/DoctorWkt/acwj 2. https://github.com/lotabout/write-a-C-interpreter/blob/master/tutorial/en/ - 3. https://www.engr.mun.ca/%7Etheo/Misc/exp + 3. https://www.engr.mun.ca/~theo/Misc/exp 4. https://en.wikipedia.org/wiki/Operator-precedence 5. https://en.wikipedia.org/wiki/Strahler - 6. https://github.com/rswier/c4.git - 7. https://github.com/rswier/c4/blob/switch-and-structs/c4.c - 8. https://github.com/EarlGray/c4 - 9. https://github.com/jserv/amacc - 10. http://selfie.cs.uni-salzburg.at/ - 11. http://www.iro.umontreal.ca/%7Efelipe/IFT2030-Automne2002/Complements/tinyc.c - 12. https://github.com/rswier/swieros.git - 13. https://github.com/ras52/boostrap - 14. http://t3x.org/t3x - 15. https://github.com/felipensp/assembly/blob/master/x86/itoa.s - 16. https://baptiste-wicht.com/posts/2011/11/print-strings-integers-intel-assembly.htm - 17. http://cowlark.com/wordgrinder/index.html - 18. https://github.com/mity/md4c + 6. https://en.wikipedia.org/wiki/X86 + 7. https://github.com/rswier/c4.git + 8. https://github.com/rswier/c4/blob/switch-and-structs/c4.c + 9. https://github.com/EarlGray/c4 + 10. https://github.com/jserv/amacc + 11. http://selfie.cs.uni-salzburg.at/ + 12. http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complements/tinyc.c + 13. https://github.com/rswier/swieros.git + 14. https://github.com/ras52/boostrap + 15. http://t3x.org/t3x + 16. https://github.com/felipensp/assembly/blob/master/x86/itoa.s + 17. https://baptiste-wicht.com/posts/2011/11/print-strings-integers-intel-assembly.htm + 18. http://cowlark.com/wordgrinder/index.html + 19. https://github.com/mity/md4c |