Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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:
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

This error will also occur if your program has more 'returns' than 'calls' [gosubs]
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top