Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Desert Leo said:"goto" is stupid command. Use "call" instead. This is required fron the "good practice" in programming.
bmcculla said:In C every if/else and case statement generates a goto (jump) assembly instruction. In case statements the break statement coresponds to a jump/goto instruction. Function calls generate a Call instruction.
The goto instruction is used to direct the flow of the program.
XORLW 0x32
BTFSS STATUS , Z
GOTO Label_0027
GOTO Label_0029
Label_0029 GOTO Duration_32
Label_0027 GOTO Label_002B
Label_002B GOTO Try_Dur_16
Duration_32 MOVLW 0x20
Nigel Goodwin said:Here's a section of PIC code generated by a C compiler, you will see what I mean about the poor code produced by compilers!. This five goto's in a meaningless row is the worst example, but the code is littered with goto's jumping just to the next line
samcheetah said:Nigel Goodwin said:Here's a section of PIC code generated by a C compiler, you will see what I mean about the poor code produced by compilers!. This five goto's in a meaningless row is the worst example, but the code is littered with goto's jumping just to the next line
which C compiler generated this code????
samcheetah said:oh so you are working on that ringtone generator which is based on a 16F877
are you going to write a tutorial about this or not????
bmcculla said:Turning off the optimisations can make it easier to debug code. Compiler optimisations will also remove software delay loops and rearange sections of code that can make optimising a bit confusing for beginers. Also be careful to use the volatile keyword when nessesary - one of my professors in school spent 4-5 hours trying to debug code that was being optimised out because he forgot to make a variable volatile. The down side to turning off the optimiser is that the compiler generates really bone-headed code.
bmcculla said:I think the answer is lazy developers - if it works and you have enough flash why bother to make your code good. Of course this sort of thinking will come back and bite you when you try to add features or maintain the code.
Make sure you're careful when turning on optimisations because they can break bad code.
dak246 said:This is exactly what I used to do when i wrote C programs for the PC. Poor memory management and lazy techniques. Programming pics has taught me alot.