Multibyte arithmetic on a PIC microcontroller

Oct 08, 2008 9 Replies

Hello,



A word of warning - shameless plug follows below. If you are not interested in PIC microcontrollers, please ignore this.



Thing is, I couldn't find a microcontroller-only group and I'm positively itching to get some feedback on something... Ok, here it comes...



On the remote chance that somebody else beside me finds madness such as multibyte long division in assembly language useful, I just put a simple page with an assembly code generator for doing some basic math with Microchip PIC microcontrollers:



formatting link



The lib has addition, subtraction, multiplication, division, modulus, logical operations with arbitrary (well, depends on how much memory you have to spare) precision. On the page there is a form where you set the precision, tell it what operations you need, press a button and get the code. Or an error message.



Any feedback, comments, suggestions, flames, killing threats, etc. are welcome.



Thanks,


- Alex


formatting link

Dave.

comp.arch.embedded.

Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html

and

Thanks Dave and Tim,

- Alex

Square root function (32-bit input, 16-bit output on an 8-bit controller)

formatting link

Frank

On a sunny day (Tue, 7 Oct 2008 17:47:46 -0700 (PDT)) it happened Alexander Avtanski wrote in :

Nice, thank you.

On a sunny day (Tue, 7 Oct 2008 22:10:15 -0700 (PDT)) it happened Frank Raffaeli wrote in :

One remark, I did use some routines 'from the internet' in the past. However some gave really weird results for some special cases, this one is probably OK, but you better always double check the code.

Here are some MPASM macros I wrote that generate arbitrary width mult and div on pic18f chips:

formatting link

One of the weirdest macro languages I've ever seen!

Ben Jackson AD7GD http://www.ben.com/

I'm sure that

formatting link
would love to have your code to post in the techref section. It's a pretty large community (>2000).

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required