; 9 program words..... ; input file as the file to test ; output: counter as the bit position (1-8) or 9 if the file is empty movlw .9 movwf counter tstf file skpnz goto file_is_clear loop: decfsz counter,f rlf file,f skpc goto loop ; counter now shows number of bit positions..... ; but goes to file_is_clear if the file holds zero. ----- Original Message ----- From: "Andrew E. Kalman" To: Sent: Friday, March 02, 2001 3:40 AM Subject: Re: [PIC]: Switch / If Statement revisited > Re: > > > > > > > Hey, would somebody with HI-TECH C try this and see how efficient it is: > >> > > >> > Fred = RB0 ? 20 : 10; > >> > > >> > The compiler should be able to generate: > >> > > >> > > movlw 10 > >> > > btfsc RBO > >> > > movlw 20 > > > > > movwf Fred > > > > > > etc. > > I came across something similar where PIC C was movwf'ing to the same > var over and over again, when it could have simply movlw'd and then > did a single movwf at the end. I passed it on to Clyde, and they're > looking at incorporating it into a future set of optimizations. > > The C source looked like this: > > if ( byte & 0x80 ) var = 8; > if ( byte & 0x40 ) var = 7; > ... > if ( byte & 0x01 ) var = 1; > > It's a very crude find-the-most-significant-set-digit routine ... > > This is the only case (so far) that I've found a really obvious > potential for relatively simple PIC C optimization. > > -- > > ______________________________________ > Andrew E. Kalman, Ph.D. aek@pumpkininc.com > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu