Giter Site home page Giter Site logo

libcpu / libcpu Goto Github PK

View Code? Open in Web Editor NEW
359.0 359.0 59.0 2.73 MB

"libcpu" is an open source library that emulates several CPU architectures

License: BSD 2-Clause "Simplified" License

Shell 0.06% C++ 56.18% C 38.90% Python 0.12% Visual Basic 0.01% Assembly 0.29% Scala 0.41% CMake 2.11% Makefile 0.03% DIGITAL Command Language 0.01% Objective-C 0.25% Lex 0.21% Yacc 1.43%

libcpu's Introduction

Libcpu

CircleCI

Libcpu logo

"libcpu" is an open source library that emulates several CPU architectures, allowing itself to be used as the CPU core for different kinds of emulator projects. It uses its own frontends for the different CPU types, and uses LLVM for the backend. libcpu is supposed to be able to do user mode and system emulation, and dynamic as well as static recompilation.

Building

CMake version 2.8 or higher is required.

On Ubuntu:

sudo apt-get install flex bison libreadline-dev

On Fedora:

sudo yum install flex bison readline-devel

To build libcpu:

make

Testing

To run the x86 front-end tests:

./test/scripts/8086.sh

License

Copyright (c) 2009-2010, the libcpu developers

Libcpu is distributed under the 2-clause BSD license.

libcpu's People

Contributors

abbeyj avatar danderson avatar glguida avatar john-k avatar mist64 avatar penberg avatar tienex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libcpu's Issues

issue with libcpu & latest llvm

stephen@karma:~/compileZone/libcpu/arch/6502$ cd /home/stephen/compileZone/libcpu/arch/6502 && /usr/bin/c++ -D__STDC_FORMAT_MACROS=1 -I/usr/lib/llvm-3.5/include -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -O2 -fomit-frame-pointer -std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fPIC -Woverloaded-virtual -ffunction-sections -fdata-sections -Wcast-qual -g -I/home/stephen/compileZone/libcpu/libcpu -I/usr/lib/llvm-3.5/include -I/home/stephen/compileZone/libcpu -W -Wall -Wextra -Wno-unused -Wno-unused-parameter -o CMakeFiles/6502.dir/6502_translate.cpp.o -c
/home/stephen/compileZone/libcpu/arch/6502/6502_translate.cpp

In file included from /home/stephen/compileZone/libcpu/arch/6502/6502_translate.cpp:12:0:
/home/stephen/compileZone/libcpu/arch/6502/6502_translate.cpp: In function âllvm::Value* arch_6502_get_operand_lvalue(cpu_t_, addr_t, llvm::BasicBlock_)â:
/home/stephen/compileZone/libcpu/libcpu/frontend.h:58:21: error: incomplete type âllvm::ConstantIntâ used in nested name specifier
#define CONSTs(s,v) ConstantInt::get(getIntegerType(s), v)
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:60:19: note: in expansion of macro âCONSTsâ
#define CONST8(v) CONSTs(8,v)
^
/home/stephen/compileZone/libcpu/arch/6502/6502_translate.cpp:55:18: note: in expansion of macro âCONST8â
new StoreInst(CONST8(OPERAND_8), ptr_temp, bb);
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:58:21: error: incomplete type âllvm::ConstantIntâ used in nested name specifier
#define CONSTs(s,v) ConstantInt::get(getIntegerType(s), v)
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:62:20: note: in expansion of macro âCONSTsâ
#define CONST32(v) CONSTs(32,v)
^
/home/stephen/compileZone/libcpu/arch/6502/6502_translate.cpp:79:14: note: in expansion of macro âCONST32â
Value *ea = CONST32(base);
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:58:21: error: incomplete type âllvm::ConstantIntâ used in nested name specifier
#define CONSTs(s,v) ConstantInt::get(getIntegerType(s), v)
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:95:62: note: in definition of macro âANDâ
#define AND(a,b) BinaryOperator::Create(Instruction::And, a, b, "", bb)
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:62:20: note: in expansion of macro âCONSTsâ
#define CONST32(v) CONSTs(32,v)
^
/home/stephen/compileZone/libcpu/arch/6502/6502_translate.cpp:86:16: note: in expansion of macro âCONST32â
ea = AND(ea, CONST32(0x00FF));
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:58:21: error: incomplete type âllvm::ConstantIntâ used in nested name specifier
#define CONSTs(s,v) ConstantInt::get(getIntegerType(s), v)
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:95:62: note: in definition of macro âANDâ
#define AND(a,b) BinaryOperator::Create(Instruction::And, a, b, "", bb)
^
/home/stephen/compileZone/libcpu/libcpu/frontend.h:62:20: note: in expansion of macro âCONSTsâ
#define CONST32(v) CONSTs(32,v)
^
/home/stephen/compileZone/libcpu/arch/6502/6502_translate.cpp:88:16: note: in expansion of macro âCONST32â
ea = AND(ea, CONST32(0xFFFF));

x86_decode : more efficient nr_bytes determination

Instead of incrementing nr_bytes everywhere, remember pc in starting_pc.
After decoding, calculate nr_bytes using (pc - starting_pc).
This is faster, requires less code and avoids potential mistakes.

Build failure due to non-standard members of struct termios

out->c_ispeed = termios_speed_to_nix_termios_speed(in->c_ispeed);
out->c_ospeed = termios_speed_to_nix_termios_speed(in->c_ospeed);

POSIX doesn't specify these members, some systems use different names, others store the speeds in the flags.

Can't all POSIX systems do like Sun?

#if defined(sun)
out->c_ispeed = cfgetispeed(in);
out->c_ospeed = cfgetospeed(in);
#else
out->c_ispeed = termios_speed_to_nix_termios_speed(in->c_ispeed);
out->c_ospeed = termios_speed_to_nix_termios_speed(in->c_ospeed);
#endif

Same applies to:

#if defined(sun)
cfsetispeed(out, nix_termios_speed_to_termios_speed(in->c_ispeed));
cfsetospeed(out, nix_termios_speed_to_termios_speed(in->c_ospeed));
#else
out->c_ispeed = nix_termios_speed_to_termios_speed(in->c_ispeed);
out->c_ospeed = nix_termios_speed_to_termios_speed(in->c_ospeed);
#endif

This causes it to fail to build against musl libc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.