• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Nested subroutines calls processs

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
Just come across the subroutines processors mechanism using CALL and RETURN instructions.
My problem is that I don't understand this stacking process when this will apply to nested subroutines,
what will be the return address of a subroutine when the CALL instruction will be executed?
what is the logic chain between CALL and RETURN here?. Any help will be much appreciated.
Thank you.
Marius
 
Saloon Keeper
Posts: 24295
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Marcus!

When a function is called, several things happen. Generally, working storage items in machine registers will be saved in memory, a block of new working storage sufficient to hold the subroutine's defined local variables is allocated, and the address of the next instruction following the call instruction is saved in memory.

In older machines, these units of storage had to be manually reserved by the compiler-generated code, but most modern-day CPUs are stack-oriented, so they can easily be allocated in an area called the "stack" (or call stack, program stack, etc.) as a unit called a frame woith a single instruction.

You might want to lookup stack frame where you'll probably be able to see graphic visualizations of this process.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic