ON 20110114@9:01:36 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm#40557.376099537 İhsan Volkan Töre[IVT-TORETEK-TAA] See also: /Techref/microchip/math/div/8 bits by the constant 5 ON 20110114@9:12:17 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=1 ON 20110114@9:15:04 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm#40557.385462963 İhsan Volkan Töre[IVT-TORETEK-TAA] Code:
;------------------------------------------------------------------------------- ; U08DIV5 v.20110114 By Ihsan V. TORE ; ; 8 bit unsigned integer divide by 5 ; Result is built by subtracting 160:80:40:20:10: 5 from the byte successively. ; Result additions per loop are 32:16: 8: 4: 2: 1. ; Time : ; Maximum : 77 cycles (160+80+40 > 255, it skips at least once). ; Minimum : 67 cycles (for 0/5 = 0) ; Args : dividend : u08 : dividend ; Retv : result : u08 : x DIV 5 ; dividend : u08 : x MOD 5 ; ; Note : Heavily optimized. ; Legal: This code snippet is presented here as is without warranty of any kind. ; Use at your own risk. ; License: GPL last version whichever. ;------------------------------------------------------------------------------- U08DIV5: clrf result ; prelude :) movlw .160 ; W = subtract = 160 movwf subtract U08DIV5_LOOP: subwf dividend, W ; W = dividend - subtract skpc ; skip if positive (CF == 1) goto U08DIV5_NEXT ; else next (CF == 0) movwf dividend ; dividend = W bsf result, 0 ; set corresponding result bit clrc ; CF = 0 U08DIV5_NEXT: ; CF == 0 here always rrf subtract, F ; subtract /= 2 skpnc ; if carry(..5>>CF)return return rlf result, F ; set result bit position movfw subtract ; W = subtracts goto U08DIV5_LOOP ; loopON 20110114@9:19:32 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm#40557.3885648148 İhsan Volkan Töre[IVT-TORETEK-TAA] Says Now, I can not edit and correct this... ON 20110114@9:23:26 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm#40557.3912731481 İhsan Volkan Töre[IVT-TORETEK-TAA] Says Licence is MIT... Either I am or this server or we both are idiots... can not edit my posting... ON 20110114@4:02:26 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm#40557.3885648148 İhsan Volkan Töre[IVT-TORETEK-TAA] removed post 40557.3885648148 |Delete '0hsan Volkan Töre Says: " Now, I can not edit and correct this... "
' ON 20110114@4:03:44 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=3 ON 20110114@4:04:06 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=4 ON 20110116@2:30:06 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=6 ON 20110116@2:31:01 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] change |Replace: '' with: '' ON 20110116@2:31:15 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] I have agreed to maintain this page. ON 20110116@2:34:49 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] I have agreed to maintain this page. ON 20110116@2:36:08 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\index.htm&version=10 ON 20110116@2:36:19 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] change |Replace: '' with: '' ON 20110116@2:40:57 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm#40559.1117708333 İhsan Volkan Töre[IVT-TORETEK-TAA] Says This might easily be "reinventing the wheel". I have not seen any routine like this before (probably because I did not sought enough) :). But I think this will be wellcome by all lazy coders like me when needed. Cut paste run and have fun... ON 20110116@1:09:48 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# James Newton[JMN-EFP-786] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\index.htm&version=12 ERROR: Can't email. At least one recipient is required, but none were found. ON 20110116@10:56:59 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] I have agreed to maintain this page. ON 20110116@10:58:01 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\index.htm&version=14 ON 20110116@10:58:31 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] change |Replace: '' with: '' ON 20110116@10:59:08 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=10 ON 20110117@12:01:09 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=11 ON 20110117@12:08:31 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=12 ON 20110117@12:12:42 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=13 ON 20110117@1:33:04 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=14 ON 20110117@1:43:56 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=15 ON 20110117@3:01:32 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=16 ON 20110117@3:15:49 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] I have agreed to maintain this page. ON 20110117@3:16:30 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\index.htm&version=17 ON 20110117@3:59:13 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=17 ON 20110117@10:57:06 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=18 ON 20110117@10:58:53 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8byconst3-aw.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] I have agreed to maintain this page. ON 20110117@10:59:29 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8byconst3-aw.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] change |Replace: '' with: '' ON 20110117@11:05:39 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] change |Replace: '' with: '' ON 20110117@11:06:29 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=19 ON 20110117@11:09:38 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm#40560.9650231482 İhsan Volkan Töre[IVT-TORETEK-TAA] Says Yes, digging into piclist, I've found that this is called kenyan method. ON 20110117@11:10:53 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=21 ON 20110117@11:14:11 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=22 ON 20110117@11:22:13 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] change |Replace: '' with: '' ON 20110117@11:30:17 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] I have agreed to maintain this page. ON 20110117@11:36:18 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=25 ON 20110117@11:38:13 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=26 ON 20110117@11:42:41 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/8_bits_by_the_constant_5.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\8_bits_by_the_constant_5.htm&version=27 ON 20110117@11:49:05 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] I have agreed to maintain this page. ON 20110117@11:52:02 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=\Techref\microchip\math\div\index.htm&version=21 ON 20110117@11:52:49 PM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm# İhsan Volkan Töre[IVT-TORETEK-TAA] change |Replace: '' with: '' ON 20110128@4:07:18 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/24by16ad.htm#40571.1717361111 Vinicius Bordinhão Carvalho[VBC-hotmail-] Questions: i would like divide a 16 bits by 16bits and save in 16bits bits the result. Help ON 20110128@4:10:17 AM at page: On a web page you were interested in at: http://www.piclist.com/Techref/microchip/math/div/index.htm#40571.1738078704 Vinicius Bordinhão Carvalho[VBC-hotmail-] Says i would like divide 16bits by 16bits and save the result in 16 bits. help me