On Mon, 7 Apr 2014, Chris McSweeny wrote: > On Mon, Apr 7, 2014 at 8:23 PM, cdb wrote: > >> On Mon, 7 Apr 2014 14:27:43 +0100, Chris McSweeny wrote: >> :: ...next? >> >> I should have stated that the language used doesn't have an explicit 'do= ' >> statement. >> > > In which case what is the relevance when we were discussing the use of go= to > in C? My take on this entire thread was that it started by taking about GOTO=20 specific to C but very quickly changed to a discussion of "good vs.=20 evil" use of GOTO in HLLs in general. In which case I really don't see the= =20 point of language relevence. Do you. > > I was also trying to conserve program space. Like my main PIC16 'C' >> compiler negative testing !=3D0 and counting down in FOR loops instead = of up >> saves a number of programming words. >> >> Which I suppose brings us back to knowing how each type of compiler >> implements different code statements. >> > With a decent optimising compiler, it really shouldn't make any differenc= e > testing =3D=3D or !=3D (certainly not when testing a STATUS bit) and if i= t's that > big a deal what the compiler is doing in terms of exactly how many cycles > or instructions you're using, then you should probably be in assembly - y= ou > shouldn't really need to get into how different compilers work as that's > losing the whole point of working in a HLL. Sure for normal apps on big machines I'd agree (well as long as you're not= =20 doing realtime graphics or low level device drivers). But for embedded=20 systems programming I couldn't disagree more. > Though if you want you can > always hand compile the code yourself with the C code in comments. e.g. No, you've really missed the point here. Please re-read what Colin wrote=20 here. He is talking about using !=3D0 in preference to using <0 in ***C***= =20 as a terminator to a FOR loop ***NOT*** for checking the state of the=20 carry bit in the status register using the XCSB programming language. > > asm_start > > //do { > > LSD //Least Significant Digit > addwf units,F > decf tens,F > > //} while ((STATUS & (1< btfss STATUS, C > goto LSD > > asm_end > > Yes I know I have a goto in that code, but as discussed above, that's in > the assembly where you have no choice - the assembly code I've written > there is simply the hand compilation of the C code, and I'd kind of hope > that a good compiler might do that for you. > > I don't think there is any argument that my version of the code has a far > more obvious control flow (I had to think quite a bit to work out what th= e > flow was in the original) is there? That is surely quite an important iss= ue > when writing code which can be tested, documented and maintained. > I know Colin and I think somewhere along the way he got side tracked. I'm=20 sure that given more time he would have streamlined his code=20 significantly. Maybe continuing to use gotos but in a less obsure way. ***FRIENDLY*** Regards Sergio Masci --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .