stack underflow

Status
Not open for further replies.

sayed88

New Member
hi there
im working on pic16f84a and make an assembly program with delay subroutine on MPLAB and when i take the .hex file and go to simulate it on Proteus i get the message 'stack underflow executing return instruction' when i searched for it on the web i found that this message means that the assembler found a "return" instruction before a "call" instruction . and i put the delay subroutine on the beginning of the program because if i put it after the end of the program the MPLAB execute an error that the "label" of delay subroutine not previously defined . what can i do ? and does the message of the Proteus mean it ?
thx
 
Place your subroutine before the directive 'end of program' and it should compile fine:

ORG 0x000
start
;main code loop here
stop
goto start ; Or goto stop
;place delay subroutine here.
END
 
Last edited:

This error will also occur if your program has more 'returns' than 'calls' [gosubs]
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…