Let's Make Robots!

Conquer the Divide - Faster Integer Division

Conquer the Divide - Faster Integer Division

Introduction

How to implement C-style integer division on a microcontroller that doesn't provide appropriate instructions? In school we learn how to divide long nunmbers [1]. Wikipedia tells us that we can do better in certain cases [2]. However, these algorithm are only better for numbers longer than a certain limit. For C operations they don't give any advantage. This article presents an algorithm based on piecewise polynomial approximation to implement this operation.

QSM - Quarter Square Multiplication, 8 x 8 -> 16 Speed Record on Extended Baseline PIC!

QSM - Quarter Square Multiplication, Speed Record on Extended Baseline PIC!

I'm a great fan of PIC10F / PIC12F / PIC16F controllers. They are inexpensive, they offer verstalie peripherals, and they are absoulely energy efficient which is becoming extremely important in the era of IoT. However, they don't provide mulitplication hardware. There are several code snippets for software multiplication around, but there is still the challenge of doing it better. I've taken it! And here we go with the fastest 8 x 8 -> 16 multiplication I know on extended baseline PIC.

4x4to8MTL - 4 x 4 -> 8 Multiplication by Table Lookup

The challenge

On piclist.com we find lots of basic arithmetic routines including multiplication of two 4 bit numbers giving an 8 bit result [1]. It gives detailed derivation of his code which is small and fast, indeed.

But we can do better! Since this article was published Microchip has brought the enhanced baseline PIC to market which has competitive price, larger instruction set, and more special function registers with increased functionality. This gives the option of simple and fast table lookup in program memory.

CSVPOVD - Charlieplexing Saccadic Valentine's Persostence of Vision Display

Happy Valentine with this strangely named new device!

CSVPOVD in action