To many RET in callsub?

pittom

Active Member
I have been using this program for a year with no problems. I just look at how many RET in 1 callsub,is this bad?
 
 
KTIME_ON:
                TSTEQ OP1 1  
                 RET    
 
                 TSTGE CH VAR3  
                 TSTGE CH VAR4  
                  RET    
 
                 CALLSUB TIME_KON   
                 RET    
 
TIME_KON:
               SET RAM5 1  
               TSTLT T1 RAM8  
               SET OP5 1  
               TSTGT T1 VAR1  
               SET OP5 0  
               RET  
 
No, that is not a problem, since most those RET actually are behind conditional branch after the TST commands.  They don't get executed unless condition met.
 
Personal preference. It is not the "perfect code" method but I find it fairly clean and readable. It also gives a blank line in the code for clarity.
 
If I was writing the code I would use more labels to identify ideas and document the code.
 
-----------------------------
KTIME_ON:
                TSTEQ OP1 1 
                 RET  (or GOTO KTIME_X)
  
KTIME_??:
                 TSTGE CH VAR3 
                 TSTGE CH VAR4 
                  RET (or GOTO KTIME_X)
   
KTIME_XX:
                 CALLSUB TIME_KON  
                 RET (or GOTO KTIME_X)
  
TIME_KON:
               SET RAM5 1 
               TSTLT T1 RAM8 
               SET OP5 1 
               TSTGT T1 VAR1 
               SET OP5 0 
KTIME_X:
               RET 
 
If you update the firmware to the new one, you can save a copy of your code with comment, then it may help you remember what  did you want each RET doing.
 
LarrylLix  i was thinking of using the GOTO instead on RET thanks
 
CAI_Support i will have to update,code with comment will help thanks
 
LarrylLix i was thinking of using the GOTO instead on RET thanks


CAI_Support i will have to update,code with comment will help thanks


A common exit can help if you want to add more closing code that is common to all cases.
 
Commenting only works if you edit elsewhere. The WC8 removes  all comments and formatting and the process makes it cumbersome to run trial code testing.
 
Back
Top