GithubHelp home page GithubHelp logo

rweather / berkeley-softfloat-3-6502 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ucb-bar/berkeley-softfloat-3

2.0 1.0 1.0 834 KB

SoftFloat release 3 for 6502 microprocessors

Home Page: http://www.jhauser.us/arithmetic/SoftFloat.html

License: Other

C 93.39% Makefile 5.21% Assembly 1.41%

berkeley-softfloat-3-6502's Introduction

Berkeley SoftFloat Release 3e for 6502 Microprocessors

This repository contains an experimental floating-point implementation for 6502 microprocessors based on Berkeley SoftFloat. It is designed to be compiled using LLVM-MOS.

Building

First, install the LLVM-MOS SDK and make sure that you have the bin directory of the SDK on the front of your PATH. In particular, the following binaries must be available to compile and test the code:

  • mos-common-clang
  • mos-sim-clang
  • mos-sim
  • llvm-ar (the LLVM-MOS version, not the generic LLVM version)

You will also need GNU make to process the Makefile's for the project.

The following commands will build the SoftFloat library with mos-common-clang and install it into the mos-platform/common/include and mos-platform/common/lib directories:

cd build/llvm-mos
make
make install

Using

The library uses types with names like float32_t and float64_t instead of float and double. To perform arithmetic you need to use functions like f32_add(), f32_mul(), and so on. These are declared in the softfloat.h header file.

The following example computes ((1 + 2) * 3) with an expected result of 9:

#include <stdio.h>
#include <softfloat.h>

int main(void)
{
    float32_t one = i32_to_f32(1);
    float32_t two = i32_to_f32(2);
    float32_t three = i32_to_f32(3);
    float32_t sum = f32_add(one, two);
    float32_t product = f32_mul(sum, three);
    long result = f32_to_i32_r_minMag(product, false);
    printf("(1 + 2) * 3 = %ld\n", result);
    return 0;
}

Compile and run the example as follows:

mos-sim-clang -o example example.c -lbsoftfloat
mos-sim example

As can be seen, it is a little awkward to use the floating-point routines without compiler support. Compiler support is in progress.

There are some more examples in the examples directory.

Original README

John R. Hauser
2018 January 20

Berkeley SoftFloat is a software implementation of binary floating-point that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat is distributed in the form of C source code. Building the SoftFloat sources generates a library file (typically softfloat.a or libsoftfloat.a) containing the floating-point subroutines.

The SoftFloat package is documented in the following files in the doc subdirectory:

Other files in the package comprise the source code for SoftFloat.

berkeley-softfloat-3-6502's People

Contributors

jhauser-ucberkeley avatar kijimad avatar rweather avatar sbeamer avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

bcr

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.