Code Monkey home page Code Monkey logo

bin-translator's Introduction

bin-translator

It is the last project of first course of university. This project is JIT-compiler for my assembler from first semestr. (Assembler was changed because it does not worked on Linux).

This project has several goals

  • Discover structure of elf file and create own minimum elf file for x86-64
  • Compare speed of working of processor emulator from first semestr and real processor running program
  • Make optimizations for Processor

Making ELF file

We started with minimum ElF file. The purpose is to create ecxecutable fast - working program. So there is no debugging information in this ELF file. Structure of ELF was taken from this repository.

https://github.com/alpocnito/Create-elf-in-10-minuts

Creating model of command translation

https://github.com/Krym4s/bin-translator/blob/main/screens/no_optimization.png

  1. As we use our assembler from first semester we work mostly with stack. Our assembler let us work with double presicion numbers so I performed replacement of general-purpose registers to xmm registers. As in my assembler there are only general-purpose registers we will not lose opportunities of our assembler using this replacement.

  2. Math operations work with stack, so we need temporary registers to work with math operations.

Summarising this two ideas I have made decision to make xmm0 and xmm1 as temporary register for calculatings and xmm2 as rax, xmm3 as rbx, xmm4 as rcx and xmm5 as rdx.

Also to set same conditions for our processor emulator and real processor we have replaced second stack for addresses of returns rfom functions.

Comparison of processor emulator and ELF file

So we executed counting of factorial on our emulator and compared it with execution on real processor.

Processor emulator was compiled with O3 flag and all verifications was taken away.

The average working time of emulator is 3.431 seconds.

The average working time of programm runned on real processor is 0.011 seconds.

To summarise, our bin tranlator gives about 343 percents growth in productivity.

Implementation optimizations

The simpliest way to optomise our ELF file is to take away unnecessary Pops and Pushes. To implement this optimization we should remember relative address of every command and recalculate it before counting difference between addresses of labels and addresses of commands.

After removing all unnecessary pushes and pops we can see the results.

Growth in speed is 10%.

bin-translator's People

Contributors

krym4s avatar

Watchers

 avatar

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.