Code Monkey home page Code Monkey logo

x86-control-unit's Introduction

Description

As part of a homework assignment for my Computer Architecture course, I was asked to develop a small control unit simulator capable of running some self-created assembly language. I started it up with a GAS inspired syntax and later decided to build a full parser around it.

Features

  • 7 registers: "eax", "ebp", "esp", "eip", "edx", "ebx" and "ecx";
  • 20 opcodes: "addl", "andl", "leave", "movl", "pushl", "ret", "subl", "cmpl", "incl", "jg", "jle", "jmp", "leal", "call", "sall", "decl", "imull", "nop", "jl", "jge";
  • Dumping of stack (memory) and register to .txt files by the end of execution;
  • Counting of the number of cycles.

How to run it

You must have cmake and a C++ compiler installed. cd into the folder that contains this cloned repository and run the following command on a terminal:

$ cmake .

How to get generate compatible assembly

Although some examples are to be found on the samples folder, you can easily use some piece of C code and a C compiler (like GCC) to generate some assembly that will (most likely) run on this simulator. For a file named input.c, this can be done through the following command:

gcc -S -m32 -fno-leading-underscore input.c

-m32 generates code with only x86 opcodes and -fno-leading-underscore will remove underscore from the beginning of directives and labels (some compilers may have it turned on by default).


Have fun!

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.