cdecl: parameters right to left on the stack, caller places parameters and removes parameters. gcc uses this.

stdcall: similar to cdecl, but callee removes function parameters from the stack when finished. Advantage, clean up code doesn’t need to be rewritten for each function. disadvantage, unknown number of parameters are impossible (printf) Microsoft compilers use this

fastcall stdcall, but uses two parameters in cpu registers (ecx and then edx)

c++ ‘this’ is passed in ecx (ms visual c++) or passed as first parameter (g++)

Introduction

RAMEL is a programming language written using Lex, Yacc, and C by yours truly with (a lot of) guidence from Dan Tappan in the CS Department at ISU. This is probably the most difficult program I’ve ever written. It runs on a Java virtual program. RAMEL is more or less useless, but it did help clear up how a compiler can actually work.

Syntax – Lex

Lex is a tool for parsing regular expressions. RAMEL is similar to C, so it is parsed similarly. The syntax of Lex is fairly straightforward, but it helps to look over the documentation. Regular expressions are a subset of context free languages which can be generated using YACC.

Some things, such as strings, are passed modified using some code (such as stripping off the quotes).

Semantics – Yacc and C

The Yacc was a bit more complicated than the Lex. It takes care of the semantics of declaring variables, algebra operations, symbol tables, etc. It also keeps track of all sorts of rules like a string cannot be added to an integer.

Analysis

The reasons RAMEL is not practical – just to name a few:

It is extremely slow. It relies on something like 13 passes to generate target code. It basically goes through all this trouble just to write java code that is interpreted and realistically has to be interpreted down to your machine from there.

It does nothing new. There is nothing RAMEL gives that has not already been done – much better.

The code seems a little buggy. Although it seems to work ok on my laptop, it had an error running on the school’s machines. This bug was fixed. However, RAMEL has never really been tested, so if it were ever to be really used (which it probably never should be other than for educational purposes) some debugging may be necessary.

No one uses it so it doesn’t have any libraries – so even the most trivial tasks can be difficult.

Despite these disadvantages, there are, believe it or not, advantages. At least I think there are:

RAMEL is extremely simple as far as compilers go. Compilers are complicated devices, and this lets the observer see how one could realistically work.

RAMEL is easy to read due to simplicity, so it should be fairly familiar.