Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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: 23441
159
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.
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic