# lcc **Repository Path**: leon39_7/lcc ## Basic Information - **Project Name**: lcc - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-06-02 - **Last Updated**: 2024-06-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # lcc This is the source code of *A Retargetable C Compiler: Design and Implementation*. It's a completely implementation for C languange named lcc. I modified some code to make it can be compiled on windows and also write a cmakelists with reference on makefile.nt. If you want to generate the solution, just run build.bat, but the directory build must be created first. I am not sure whether lburg need to be regenerate or not, it is used to generate backend code. Attention here, only 32bits lburg can generate backend code. I also write a cmakelists for lburg, named lburg_CMakeLists.txt. the test command could be as follow: ``` rcc.exe -target=x86/win32 test_case.c ``` the backend is optional: ```shell -target=alpha/osf -target=mips/irix -target=sparc/sun -target=sparc/solaris -target=x86/win32 -target=x86/linux -target=symbolic/osf -target=symbolic/irix -target=symbolic -target=bytecode -target=null ``` example code ```c #include int main(){ int m = 9; int n = 10; int result = m + n; printf("%d\n", result); } ``` the compiled result of the example code ```assembly _TEXT segment _main: push ebx push esi push edi push ebp mov ebp,esp sub esp,12 mov dword ptr (-4)[ebp],9 mov dword ptr (-8)[ebp],10 mov edi,dword ptr (-4)[ebp] mov esi,dword ptr (-8)[ebp] lea edi,[esi][edi] mov dword ptr (-12)[ebp],edi mov edi,dword ptr (-12)[ebp] push edi lea edi,(L2) push edi call _printf add esp,8 mov eax,0 L1: mov esp,ebp pop ebp pop edi pop esi pop ebx ret _TEXT ends ``` [*A Retargetable C Compiler: Design and Implementation* book link](https://pan.baidu.com/s/1_uBAJ2lPaO4EsESXvvGl0g) and withdraw code: ox2l