Giter VIP home page Giter VIP logo

i8087-compiler's Introduction

i8087-compiler

Компилятор инфиксных выражений в ассемблерный код для сопроцессора i8087.

Использование

Клонируем репозиторий:

git clone https://github.com/kiraind/i8087-compiler
cd i8087-compiler

Редактируем файл source.txt:

code source.txt

Задаем в нем параметры по образцу:

x:float, a:int         # переменные-аргументы: float32/int16
y                      # переменная-результат: float32
sqrt ( 2*a * sin (x) ) # инфиксное выражение

Запускаем скрипт:

node index.js source.txt

Код модуля с функцией помещается в module.asm:

.model small, C ; модель сегментации памяти 'small'
.stack 100h  ; выделение памяти на стек
.486

.data ; начало описания сегмента данных
    ; внешние переменные
    Extrn C x:dword
    Extrn C a:word
    ; константы
    constant0 dd 40000000h ; 2
    
.code  ; начало описания сегмента кода

public C calc
calc proc
    ; вычисление выражения: sqrt(2*a*sin(x))
    ; с помощью постфиксного выражения: 2 a * x sin * sqrt

    finit
    fld constant0
    fild a
    fmulp
    fld x
    fsin
    fmulp
    fsqrt
    fst y

    ret
calc endp
end

В stack.csv помещается таблица состояний стека после каждой команды:

команда;        st0;                     st1;     st2; st3; st4; st5; st6; st7
finit
fld constant0;  2
fild a;         2;                       a
fmulp;          (2 * a)
fld x;          (2 * a);                 x
fsin;           (2 * a);                 sin(x)
fmulp;          ((2 * a) * sin(x))
fsqrt;          sqrt(((2 * a) * sin(x)))
fst y

Полезные ссылки:

  1. Описания команд сопроцессора

i8087-compiler's People

Contributors

kiraind avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.