On Sat, 8 Jun 2002, cdb wrote: > With FED C I noticed the difference in code length caused by just a > simple change to the syntax. > > There was only one compiler that managed a two line code however the > professional version is quite expensive. That was ByteCraft. I think it's clear you get what you pay for in this case. > Code Follows. > > //Program to solve X-> 2X +1 > > //shortest assembler version by Dmitriy A. Kiryashov > //comf X,W > //subwf X,W ;or ,F > //************************* > //OR THIS > // > //set c > //rlf x,F > > > CDB 6/5/2002 > unsigned char N=3; > > void main() > { > N=(N*2)+1; // movfw N > > // movwf ACC > // clrc > // rlf ACC > // incf ACC > // movfw ACC > > // movwf N > // 7 instructions > *********************************** > N=3; > N*=2; // movlw 37 > N+=1; // movwf ACC > // clrf 14 > // call PushA > // movwf FSR > // movfw 0 > > // movwf ACC > //movlw 3 > //movwf ACC2 > // call MulUSA > // call Pop2A > //call SavePACC2A > // incf N > // 13 instructions plus the routine calls > } I don't mean to sound too critical, but that second snippet is really bad. One would hope that if you (the programmer) do part of the job for the compiler (by breaking the expression down into easily managable pieces) that the assembly code would be better. I verified with SDCC that this is indeed the case: ;#CSRC c.c 81 ; achar0 *= 2; MOVF _achar0,W ;key=003,flow seq=001 ADDWF _achar0,F ;key=004,flow seq=001 ;#CSRC c.c 82 ; achar0 += 1; INCF _achar0,F ;key=005,flow seq=001 Scott -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body