Skip to content

serid/cplastane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPlastane

CPlastane, is a cool C compiler designed with standard compatibility in mind.

Implemented features:

  • x86/64 assembler (no linker yet)

Planned features:

  • C parser
  • LLVM frontend, middleend, backend

Example

auto main() -> int {
    string s = "mov DWORD eax, 100\n"
               "mov BYTE ah, [eax + ebx * 2 + 128]\n"
               "push DWORD [eax]\n"
               "ret\n";

    // Parse assembly code into a list of syntax structures
    vector<mnemo_t> mnemos = assembly::parse::parse(s);

    // Assemble syntax into actual x86/64 bytecode
    vector<u8> bytes = assembly::assemble(mnemos);
    
    // Execute bytecode from a bytes vector
    int n = jit::eval_mc(bytes.data(), bytes.size());
    
    std::cout << n << "\n";
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published