AVR200 - Division routines incomplete

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Trying to understand ASM division routines for a project I turned to Atmel's AVR200: Multiply and Divide Routines, dated 1997.

In viewing the provided code, three of the division routines seem to be incomplete in not calculating the result. This is for both speed and code size optimized routines.

Zipped code: http://www.atmel.com/Images/AVR200.zip
AVR200 Document: http://www.atmel.com/Images/doc0936.pdf

Code snippets:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;* "div8u" - 8/8 Bit Unsigned Division
.def dres8u =r16 ;result

--> dres8u NOT USED IN CODE

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;* "div8s" - 8/8 Bit Signed Division --------- (no speed optimized version)
.def dres8s =r16 ;result

neg dres8s ; change sign of result --------- THE SINGLE USE IN CODE

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;* "div16u" - 16/16 Bit Unsigned Division
;* The result is placed in "dres16uH:dres16uL"
.def dres16uL=r16
.def dres16uH=r17

--> dres16uL/dres16uH ARE NOT USED IN CODE

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Perhaps some editing was done after the development and debugging in 1997?

Stan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

In viewing the provided code, three of the division routines seem to be incomplete in not calculating the result. This is for both speed and code size optimized routines.

https://www.avrfreaks.net/index.p...
Back in 2001, Jack Tidwell referenced the "working" version of the 16-bit divide. In that same thread, other "improved" routines were presented.

"Corrections" also mentioned here:
https://www.avrfreaks.net/index.p...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
These completely wrong with the theme of the library, the library is not incomplete, eally is perfect, and the reason that dres8u result does not appear it is because it uses the same record as dd8u r16 in value reaches this record through the register r15, if you check the function rol you will ditch that affects the next record, in conclusion the library is not incomplete, this perfect and I have used it and it works perfectly.