At 11:32 AM 30/05/01 -0700, you wrote: >Roman Black wrote: > >> > If you don't need it to be fast (and if you can put the code in >> > the lower half of a page), you can do this: >> > >> > MOVF COUNT,W >> > ADDWF PC >> > XORLW A ^ (B ^ 1) ;When COUNT = 0, W = A >> > XORLW B ^ 1 ^ (C ^ 2) ;When COUNT = 1, W = B >> > XORLW C ^ 2 ^ (D ^ 3) ;When COUNT = 2, W = C >> > XORLW D ^ 3 ;When COUNT = 3, W = D >> >> Hi Andy, yes I had seen that clever system the >> last time it was mentioned here. (Was that you?) > > Roman: > > It may have been me, although I usually post it with ADDLWs > rather than XORLWs. If you saw it with XORLWs before, it was > probably someone else. I posted my bit banged, variable baud rate, RS232 routines for a 16C57 that used this method but it was a l-o-n-g time ago. Maybe that is what you saw? Here's an extract: ;5=57600 4=38400 3=28800 2=19200 1=9600 0=4800 movlw 07 andwf baud,w ;Remove control bits in upper nibble. addwf pc xorlw 5eh ;4800 -1 xorlw 10h ;9600 -1 xorlw 0bh ;19200 -1 xorlw 5 ;28800 34 xorlw 6 ;38400 +4 xorlw 7 ;57600 -.3 movwf temp decfsz temp goto $-1 When I changed to 14-bit core parts I also when for the ADDLW's as they are easier to calculate! ;-) -Jim > >> Unfortunately I can't use the bottom half of >> a page, as there is no room left there. > > Oh, ok... I thought that maybe you just couldn't spare a stack > level for a CALL. > > If you have to locate the code in the upper half of a page, use > Bob Ammerman's "DECFSZ" code. > > -Andy > NEWFOUND ELECTRONICS mailto:newfound@pipeline.com.au http://www.new-elect.com MPLAB compatible PIC programmers. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu