Oshonsoft Stack underflow?

ericgibbs

Joined Jan 29, 2010
18,610
Hi,
It means you are popping more data off the Stack more than have you pushed on.

Check the number of Calls equals the number of Returns

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,641
Hi,
It means you are popping more data off the Stack more than have you pushed on.

Check the number of Calls equals the number of Returns

E
Hi E,
I've not come across this before.
There are some gotos, gosubs and calls, that I know I have to tidy up, so that's next, thanks.
C
 

Papabravo

Joined Feb 24, 2006
20,978
Arrgghh.. That'll be the reason.. A goto can miss the return. Please try not to use them.
Hard to avoid. BASIC allows them and provides no real tools or defense against the side effects. Depending on how much time and effort it takes to solve, the TS may want to reexamine the choice of this environment. There is probably no shortage of detractors.
 

Ian Rogers

Joined Dec 12, 2012
1,136
Hard to avoid. BASIC allows them and provides no real tools or defense against the side effects. Depending on how much time and effort it takes to solve, the TS may want to reexamine the choice of this environment. There is probably no shortage of detractors.
I used to use Oshonsoft Basic.. There is no software stack only the 16 level hardware stack ( I think its 16 on the pic18 ) I never used goto once. Mainly because I normally write in C and have learnt not to.. Vladimir have several looping mechanisms, he also implemented EXIT FUNCTION and EXIT SUB, so there should be sufficient tools not to. I think there is also CONTINUE to get out of the loops.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,641
Hi all,
As I can't really CODE, I rely on the generosity of forums members, this section has the gosubs, and once I get it hobbling along, it will then be tidied up and the jumping around reduced.
Thanks,
C
 

jjw

Joined Dec 24, 2013
819
Which program?
On the other thread there are two programs, 18F4k20... which is hex listing and 18F4431... basic program.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,641
Which program?
On the other thread there are two programs, 18F4k20... which is hex listing and 18F4431... basic program.
Hi J, 18F46K20
I'm not sure which other thread, but I looked at one posted program and it was HEX?
Anyway I have posted the latest full program in one thread (I can re-post or search for it if required), which is nearly working apart from the SPI and the UART, that have small errors.

I'm addressing the UART first, and following the program in #328, I am modifying that.
Since that program, there have been changes in the PCB, and the SWITCH removed, and now only UART is received via the TX pin. Once working properly, I'll integrated it into the FULL program.

Here is the #328 cut down program, which errors 'stack underflow'
C
 

Attachments

Last edited:

MrChips

Joined Oct 2, 2009
30,414
Also, don't goto into a subroutine.
You must not GOTO a subroutine.

'======================================================================
main_loop: '/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

waitBuf:
If robi_fill_state = 1 Then 'If got A sentence, parse it
Goto do_parse
Endif

If ms05_RXguard = 0 Then 'If timeout, change channels
'Gosub next_channel
'Gosub setuartchannel
Gosub IRQinitBuf '<<<<<<<<<<<<<<<<<<<<<<<<<¦
Endif

'Other processing here
Goto waitBuf 'loop until something happens

'-------------- SENTENCE PROCESSING COMPLETE ---------------
'Done receiving, parsing and processing ONE sentence.
Goto main_loop

End 'don't really need this as main stays in a loop
'=====================================================================
 

Thread Starter

camerart

Joined Feb 25, 2013
3,641
Don’t GOTO to a line outside of a subroutine.
Also, don't goto into a subroutine.
Hi P and MrC,
Don't goto inside or outside of a subroutine?

Ok.
I removed sections of unused CODE, which left an incorrect skeleton.
Does a PROCEDURE have the same affect?

EDIT: If anyone wants to simulate this prog use [ $ROBI,025,4,75,W ] in HARDWARE UART
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,641
You must not GOTO a subroutine.

'======================================================================
main_loop: '/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

waitBuf:
If robi_fill_state = 1 Then 'If got A sentence, parse it
Goto do_parse
Endif

If ms05_RXguard = 0 Then 'If timeout, change channels
'Gosub next_channel
'Gosub setuartchannel
Gosub IRQinitBuf '<<<<<<<<<<<<<<<<<<<<<<<<<¦
Endif

'Other processing here
Goto waitBuf 'loop until something happens

'-------------- SENTENCE PROCESSING COMPLETE ---------------
'Done receiving, parsing and processing ONE sentence.
Goto main_loop

End 'don't really need this as main stays in a loop
'=====================================================================
Hi MrC,
Changed GOTO to GOSUB and it's now working.
Now to tidy up!
Thanks all.
 
Top