I wrote this little bit of code to experiment with this thread its interesting to note that to */ method fails when your percentage goes past 1600 in lieu of 50
but the div32 method is quit sound up until the result exceeds 2^16 (65535 )
you need to remember that */ is the middle 16 bits and if you overflow that your still in trouble
Code:
****************************************************************
'*  Name    : UNTITLED.BAS                                      *
'*  Author  : [select VIEW...EDITOR OPTIONS]                    *
'*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 7/2/2014                                          *
'*  Version : 1.0                                               *
'*  Notes   : 16f684                                                  *
'*          :                                                   *
'****************************************************************
  
#CONFIG
     __config _INTRC_OSC_NOCLKOUT & _CP_OFF & _WDT_ON  &  _PWRTE_ON  &  _MCLRE_OFF 
#ENDCONFIG
 include "alldigital.pbp"
 
 
 
 
 
 
              OPTION_REG.7=0
              trisa = %11111110
             
              DEFINE OSC 4
              so var porta.0
              dq var portc.1
              Nposn var word
              ss var word
              s2 var word    
              s1 var word
              
               
    high so         
    ss=4095 
    s1=1600
    s2=100      
         
    pause 4000       
    serout2 so,84,[ "ready ",13,10] 
    lop: 
    pause 2000
    nposn=s1*ss
    nposn = div32 s2          
    serout2 so,84,["1 " ,#Nposn,13,10   ]   
    nposn=1600*4095/100          ; you need to adjust this line too
    serout2 so,84,["2 " ,#Nposn,13,10   ]
    nposn =  s1  */ 10484
    serout2 so,84,["3 ", #Nposn,13,10   ]
    nposn=s1*ss/100
    serout2 so,84,["4 ", #Nposn,13,10   ] 
    
    goto lop