https://github.com/igor-240340/float32avr
Floating-Point Routines for AVR MCUs
https://github.com/igor-240340/float32avr
assembly-language atmega avr binary-arithmetic floating-point ieee-754
Last synced: 2 months ago
JSON representation
Floating-Point Routines for AVR MCUs
- Host: GitHub
- URL: https://github.com/igor-240340/float32avr
- Owner: igor-240340
- Created: 2024-05-08T22:29:38.000Z (about 1 year ago)
- Default Branch: en
- Last Pushed: 2024-10-24T03:48:27.000Z (7 months ago)
- Last Synced: 2024-10-24T21:09:46.560Z (7 months ago)
- Topics: assembly-language, atmega, avr, binary-arithmetic, floating-point, ieee-754
- Language: Assembly
- Homepage:
- Size: 1.95 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Float32AVR
Original Russian version is located in [dev](https://github.com/igor-240340/Float32AVR/tree/dev) branch.## Overview
This library provides floating-point routines with single precision for AVR microcontrollers. It has been built entirely from the ground up, with all floating-point algorithms developed based on fundamental binary arithmetic principles.
The main goal of this library is not for production use but rather for educational purposes, allowing users to understand and experiment with floating-point arithmetic. This library can be easily ported to any microcontroller.
It is used in the "Hardware Calculator From Scratch" project, which can be found in [this](https://github.com/igor-240340/HardwareCalculatorFromScratch) repository.
## IEEE 754 Compliance
- Only one rounding mode: to nearest/ties to even.
- No subnormals: if underflows, it flushes to zero.
- No special values: inf, nan.
- Only positive zero.## Research and Proofs
Some of the research notes can be found [here](https://drive.google.com/open?id=17ViZAw4rgcqFg06v3ZrvuvWtl1nly2Ic&usp=drive_fs).
A formal proof for the division algorithm with an immovable divisor can be found [here](https://drive.google.com/open?id=10WZpMqTUmbDx7oKYT3m1wm0OJeUH0PQj&usp=drive_fs). (I couldn't find a good one, so I had to write it myself.)
## Testing
An auxiliary repository with test examples is available [here](https://github.com/igor-240340/Float32AVRTest). Each test example in this library has a desktop equivalent in that repository. The primary goal is to ensure that our floating-point library produces the same results as hardware floating-point operations in a desktop environment (excluding behaviors for subnormals and inf/nan, which we do not support).
## Features
- **FADD32/FSUB32**: Addition/subtraction.
- **FMUL32**: Multiplication.
- **FDIV32**: Division.
- **FTOAN**: Converts float to ASCII string (supports only normalized decimal numbers, uses a simple algorithm that does not generally provide the best approximation).
- **FTOAE**: Converts float to ASCII string in exponential format (it depends on FTOAN).
- **ATOF**: Converts ASCII string to float (uses a simple algorithm that does not generally provide the best approximation).
- **FTOI**: Converts from float to int (intended for internal use by the library only, currently limited to integers with a size of 1 byte).
- **ITOF**: Converts from int to float (intended for internal use by the library only, currently limited to integers with a size of 1 byte).## Flowcharts
### FADD32

### FMUL32

### FDIV32

### FTOAN

### FTOAE

### ATOF
