In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Coriolis wrote: Nick, Bookmark this page: [url=http://www.sxlist.com/techref/scenix/constdivmul_help.htm]http://www.sxlist.com/techref/scenix/constdivmul_help.htm[/url] It is a web form to generate code to multiply a variable by a constant value (in your case 0.15625). It was designed before the advent of SX/B so the code it spits out is in assembler, but it shouldn't require to much effort to convert. For your example it generated the following code: [code] ; ACC = ACC * 0.15625 ; Temp = TEMP ; ACC size = 8 bits ; Error = 0.5 % ; Bytes order = little endian ; Round = no ; ALGORITHM: ; Clear accumulator ; Add input / 8 to accumulator ; Add input / 32 to accumulator ; Move accumulator to result ; ; Approximated constant: 0.15625, Error: 0 % ; Input: ACC0, 8 bits ; Output: ACC0, 6 bits ; Code size: 11 instructions ACC0 DS 1 ;copy accumulator to temporary mov w, ACC0 ;shift accumulator right 2 times clc rr ACC0 clc rr ACC0 ;add temporary to accumulator add ACC0, w ;shift accumulator right 3 times rr ACC0 clc rr ACC0 clc rr ACC0 [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=83746#m83758 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)