Hi, I thought of something like this solution (which COULD work in SOME special circumstances). This one uses Wouter idea about stop bit, but stores bits in reverse order to be able to use DECFSZ to check if only stop bit is in the byte. It is also 12 instruction solution, so not even smaller than previous codes but maybe somebody could get another idea how to shrink it further - for example leaving out the return :-) morse_output: movwf tmp loop: bcf STATUS,C ; make sure no 1 is in C rrf tmp, f ; 0 or 1 to C call comp_portb0 ; set portb,0 to high and wait 1 or 3 dots call comp_portb0 ; set low and wait 1 dot decfsz tmp, w ; check if tmp is zero and skip if it is goto loop return ;!!!! ; we may can leave it out as it does not hurt ; if it waits an extra dot after the letter... comp_portb0: rlf dit_count,f ; first of all save C into count variable (C=1 if dash) bsf STATUS,C ; this one is for replacing incf dit_count rlf dit_count,f ; multiplying dash to length 3 or dot to 1 ; now C is 0 for sure so next time comp_portb0 ; gets called it will wait only 1 dot... comp portb, 0 ; instr 12 dit_delay: clrf inner_count ; set up inner loop count dit_inner_loop: decfsz inner_count goto dit_inner_loop decfsz dit_count,f goto dit_delay return Tamas On 3/19/07, 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 > -- unPIC -- The PIC Disassembler http://unpic.sourceforge.net -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist