Never seen PICBasic, but..
Never done any pic programming, but a little basic back in the 80s - so might be completely off the mark here..
Following the code from the top, it displays the menu, then drops through the options - because no valid key has been pressed.
The code then eventually lands on bad: because there is no end point for main:
main:
'code
goto getinput
'there is no end statement here
getinput:
serin2 PORTC.7, $BC,[dec1 cmd] 'does this need to be told how many bytes to wait for? What does dec1 actually do?
'the code should do a return here
bad:
'this code section is executed no matter what happens
return
It appears that the program is returning to the last gosub statement it executed (ie none), perhaps filling the PC register with garbage? Or zeroes? or possibly the address of the program start point from the stack?
Am I right in assuming also that the command in getinput:
serin2 PORTC.7, $BC,[dec1 cmd] does not wait for an input? Instead it only checks the port and continues execution? If it is not told how many bytes to read, does the program assume that no bytes are acceptable input (or a byte value of 0, which is different from "0")?
Try to avoid the use of GOTO statements unless absolutely necessary, and never use them to jump elsewhere in the program - it causes no end of grief.. Try to limit their use for loops that are designed to execute indefinitely. Use the GOSUB, IF/THEN, or BRANCH to jump around, it is much less hassle to debug.
Try this fix - it is ugly, as it still uses a GOTO to continually loop for the check for input, but might be worth trying.
Make these changes:
{move}
Serout2 PORTC.6, $BC,["Choose your Option",10,13]
{up to the line before}
goto getinput
{..Then put a new label eg- checkser: BETWEEN those two lines}
{Change}
goto getinput
{into}
gosub getinput
{then add a new GOTO after that}
goto checkser
getinput:
if cmd = "4" Then
GOSUB dispname
endif
{add the following line, so the program can go back and check for input}
return
Your changed code should look something like this:
main:
'menu options
Serout2 PORTC.6, $BC,["Choose your Option",10,13]
goto getinput
checkser:
gosub getinput
goto checkser
getinput:
'code to check choices
return
Hope this helps.