Daniel Serpell wrote: > This is a really good idea, the code is really smaller this way. > > But, you overwrote W at beginning, I fixed it this way: Oops! (proves the code wasn't tested) > bin2ascii > ; Input: reg. W > ; Output: d2 / d1 / d0 (assumed in the same bank) > ; Remember to do: banksel d0 > ; Used 32 instructions / 35 cycles (counting CALL/RETURN) > > CLRF d1 > CLRF d2 > > ADDLW .256-.200 ;Try subtracting 200 > RLF d2,F ;Pick up the result from the carry > BTFSS d2,0 ;If less than 200 > ADDLW .200 ;we guessed wrong, so add 200 back > > ADDLW .256-.100 > RLF d2,F > BTFSS d2,0 > ADDLW .100 > > ADDLW .256-.80 > RLF d1,F > BTFSS d1,0 > ADDLW .80 > > ADDLW .256-.40 > RLF d1,F > BTFSS d1,0 > ADDLW .40 > > ADDLW .256-.20 > RLF d1,F > BTFSS d1,0 > ADDLW .20 > > ADDLW .256-.10 > RLF d1,F > BTFSS d1,0 > ADDLW .10 > > MOVWF d0 ;least significant digit > > ; Convert result to ASCII > MOVLW '0' > IORWF d0 > IORWF d1 > IORWF d2 > > RETURN I don't see a way to make it faster. I'll ask Dmitriy to take a look at it just to be sure though. Scott -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist