Removing rust my mind on Propeller Assembly subroutine call and ret
Timothy D. Swieter
Posts: 1,613
Hi guys -
Long time since I've been around here. Still love the Propeller, just not many projects recently with it so my Propeller assembly part of my mind has rusted over, I think.
I'm patching and updating code that I created for a client. Below is the snippet. Up till now one case was handled for processing data and it was inline with the whole program. But there are now two cases, so I thought it best to break it out to two subroutines. You can see in my example below the general structure of the program. What I am going for is either 'call #Case1Process' or ''call #Case2Process' is executed and when done it returns to ':Addone' line. The structure I have, I believe, doesn't exactly accomplish this, true? That and c and z aren't preserved through sub-routine calls.
When 'call #Case1Process' is executed, the ret is then to the 'call #Case2Process', correct?
I'm looking for suggestions to how this should be structured such that at the end of Case1Process or Case2Process it returns to the same point in the program.
Thanks - Tim
Long time since I've been around here. Still love the Propeller, just not many projects recently with it so my Propeller assembly part of my mind has rusted over, I think.
I'm patching and updating code that I created for a client. Below is the snippet. Up till now one case was handled for processing data and it was inline with the whole program. But there are now two cases, so I thought it best to break it out to two subroutines. You can see in my example below the general structure of the program. What I am going for is either 'call #Case1Process' or ''call #Case2Process' is executed and when done it returns to ':Addone' line. The structure I have, I believe, doesn't exactly accomplish this, true? That and c and z aren't preserved through sub-routine calls.
When 'call #Case1Process' is executed, the ret is then to the 'call #Case2Process', correct?
I'm looking for suggestions to how this should be structured such that at the end of Case1Process or Case2Process it returns to the same point in the program.
Thanks - Tim
........... 'Two cases of on/off pairs are handled. ' Case 1 - on value is less than or equal to off value ' Case 2 - on value is greater than off value cmp cdON, cdOFF wc, wz if_c_or_z call #Case1Process if_nc_and_nz call #Case2Process :AddOne add COGtbl, #1 'Add one to the COG table location (long) ........ theroutine_ret ret 'Sub-routine complete '----------------------------------------------------------------------------------------------------- 'Sub-routine to process Case 1 of on/off pair. On <= Off. '----------------------------------------------------------------------------------------------------- Case1Process ........ Case1Process_ret ret 'Sub-routine execution complete '----------------------------------------------------------------------------------------------------- 'Sub-routine to process Case 2 of on/off pair. On > Off. '----------------------------------------------------------------------------------------------------- Case2Process ............. Case2Process_ret ret 'Sub-routine execution complete
Comments
I appreciate all the responses. It was helping my mind get back into PASM mode. localroger's response makes complete sense to me now that I've reviewed those sections of the PASM manual.