Search code examples
assemblyfloating-pointavratmega

Assembly: 32 bit floating point instructions on an 8 bit chip


I was trying to help a friend doing some assembly code on an 8 bit AVR chip (The Atmega8535) but my assembly knowledge is quite slim and mostly centered around modern day chips and not some obsolete fossil.

So it boils down to the question of how to add two 32 bit floating points in an 8 bit architecture that doesn't even support floating point specific instruction sets such as FADD...

; 3.1415926 (pi) is given by 0x40 0x49 0x0F 0xDA
; 2.7182818 (e)  is given by 0x40 0x2D 0xF8 0x54

For the interested here is a datasheet for the chip in question. The instruction set starts at page 301.


Solution

  • i think you have the following options:

    • look at the avr-libc for implementation details
    • write your program in c.
      I bet that avr-gcc writes better (in terms of efficiency and correctness) assembly code than you
    • use an easier number format. eg:

    Also a good source for basic understanding is the following book:

    "Software Manual for the Elementary Functions" by William J. Cody, William Waite

    It shows how to implement various (also basic) operations and algorithms only with integer based arithmetics.