Bill Cornutt wrote: > And a right shift of the 200 value gives a 100 value. The same > shifting 80 to get the next compare/subtraction value... > Is a shift quicker than a load? If the value is in a file register and the carry is already clear, yes. This is particularly useful if you extend this procedure to multi- byte values. > Also if the 'test for 80' is true, then no need to 'test for 40' Well, Osama ALASSIRY suggested code: > Improving the method discussed earlier: > taking X=byte and converting to BCD digits H,T,U > > H=0 > T=0 > U=X > if U>=200 then H=H+2: U=U-200: Goto Check40 'NUMBER WILL BE <=55 > if U>=100 then H=H+1: U=U-100 > if U>=80 then T=T+8: U=U-80: Goto Check10 'NUMBER WILL BE <=19 > Check40: > if U>=40 then T=T+4: U=U-40 > if U>=20 then T=T+2: U=U-20 > Check10: > if U>=10 then T=T+1: U=U-10 If you are using fixed subtractions rather than shifts, and since each "IF" is coded () then the one-instruction-less optimisation of the above is: H=0: T=0: U=X C200: if U=>200 goto CG200 C100: if U<100 goto C80 H=H+1: U=U-100 C80: if U<80 goto C40 T=T+8: U=U-80 goto C10 CG200: H=H+2: U=U-200 C40: if U<40 goto C20 T=T+4: U=U-40 C20: if U<20 goto C10 T=T+2: U=U-20 C10: if U<10 goto C00 T=T+1: U=U-10 C00: FWIW! Cheers, Paul B.