2 ms·
The ROM floating point routines in Microsoft BASIC on the Apple ][ (and similar) took on the order of 4 ms for a single precision multiply. BASICA on an IBM PC
by brucehoult 2y ago
The ROM floating point routines in Microsoft BASIC on the Apple ][ (and similar) took on the order of 4 ms for a single precision multiply. BASICA on an IBM PC was only slightly faster.
The FP routines in the Arduino library take about 5 µs for a multiply on an AVR (e.g. Uno).
That's 1000 times faster.
Factors in that include:
- 16x faster clock speed
- typically 1 cycle per instruction vs 3
- 32 8-bit registers can easily hold all the data for operands and result and temporary values, vs Zero-page on the 6502
- single-cycle register to register 8 bit arithmetic vs three instructions needed per 8 bits on 6502
So that's a factor of around 1633 = 144x combined.
All the above apply equally to add/sub and multiply, but also:
- AVR has 2-cycle 8x8 -> 16 multiply instructions, for signed, unsigned, or mixed operands, and for fixed point 1.7 format as well. That's hundreds of clock cycles on 6502 or z80.
Also, the Microsoft BASIC interpreters used a 40 bit floating point format (32 bits of mantissa) instead of 32 bit. That's another factor of 16/9 for multiply.
The 8080/z80 and 8086 have more registers than the 6502, but not enough to implement soft FP keeping values in registers like AVR can.
- kragen 2y agoYes, excellent points! But you don't have to do floating-point math to interpret G-code or generate motor control waveforms. You could probably do it on an 8051 fast enough to run a 3-D printer entirely in floating point, but you can also do the math in integers, only going beyond 8-bit precision when necessary.