;by John Payson
clrf DstH clr DstM clr DstL mov W, SrcL and W, #$0F sb Src.4 add DstM, W rr DstM rr DstL sb Src.5 add DstM, W rr DstM rr DstL sb Src.6 add DstM, W rr DstM rr DstL sb Src.7 add DstM, W call Sqr4 add DstL, W swap SrcL and W, #$0F call Sqr4 add DstM, W ; At this point, 16-bit result is in DstM:DstH ; 25 words of code prior to this point (plus a ; 17-word table-lookup). Total execution time: ; 35 cycles up to this point. sb SrcH.0 jmp NoBit8 mov W, SrcL snb C inc DstH add DstM, W snb C inc DstH inc DstH ; Another 9 words for bit 8; 3 or 9 cycles to exec. NoBit8: sb SrcH.1 jmp NoBit9 mov W, #4 sb SrcH.0 mov W, #8 add DstH, W mov W, <<SrcL snb C inc DstH snb C inc DstH add DstM, W snb C inc DstH add DstM, W snb C inc DstH ; Another 17 words for bit 9; 3 or 17 cycles to execute ; Total worst-case time: 35+26 = 61 cycles. NoBit9: retw #0 ; All done! Sqr4: add PC, W db 0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225
See also:
file: /Techref/scenix/lib/math/sq/10b_sx.htm, 2KB, , updated: 2004/6/10 13:40, local time: 2024/11/29 17:20,
3.128.200.165:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://ecomorder.com/Techref/scenix/lib/math/sq/10b_sx.htm"> PIC Microcontroller Math Method Square 10 bits </A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.