Also:
Code:
I have a lookup table with 4-bit numbers m=0..15. A value t should be scaled according to theese numbers, so that
s = t * m/16
Rather than using 16-bit multiplication followed by s>>4, I found a much faster code. As can be seen, the code can be carried out for e.g. 7-bit m-values as well.
-------------------- clrf s movf t, W bcf STATUS, C btfsc m, 0 addwf s, F rrf s, F bcf STATUS, C btfsc m, 1 addwf s, F rrf s, F bcf STATUS, C btfsc m, 2 addwf s, F rrf s, F bcf STATUS, C btfsc m, 3 addwf s, F rrf s, F btfsc STATUS, C incf s, F ;nearest value -----------------------
Regards, Anders Jansson +
Comments:
file: /Techref/microchip/math/scale/index.htm, 2KB, , updated: 2007/2/8 11:42, local time: 2024/10/13 19:18,
44.192.95.161:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©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://www.piclist.com/techref/microchip/math/scale/index.htm"> PIC Microcontoller Basic Math Scaleing Methods</A> |
Did you find what you needed? |
PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
Welcome to www.piclist.com! |
.