Hi Bob, Using your dit_delay_plus_1 cheat, this routine is 12 instructions with no restriction on delay corrupting W. start: movwf tmp loop: movf tmp,w addwf tmp,f ;shift left x2 skpnz return ;quit if we got 0 rlf dit_count,f ;carry was set after addwf rlf dit_count,f bsf portb,5 call delay_dit_times_plus_1 bcf portb,5 call delay_dit_times_plus_1 goto loop regards, Reggie Robert Ammerman wrote: > Here is another flavor that really does get down to 12 instructions, but > with the restriction that the delay routine cannot modify W > > morse_output: > movwf morse_bits > addwf morse_bits,w > skpnz > return > skpnc > bsf dit_count,1 > bsf portb,0 > call dit_delay_plus_1 > bcf portb,0 > call dit_delay_plus_1 > bra more_output > > ; This delay routine must preserve W. > > dit_delay_plus_1: > incf dit_count,f ; instruction number 12 > > dit_delay: > clrf inner_count ; set up inner loop count > ; bsf inner_count,? ; alternate set up (assumes zero to start) > dit_inner_loop: > decfsz inner_count > goto dit_inner_loop > decfsz dit_count,f > goto dit_delay > return > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist