Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6752209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:01:04+00:00 2026-05-26T13:01:04+00:00

I am creating a simulator for an 8 bit processor in Java. It’s architecture

  • 0

I am creating a simulator for an 8 bit processor in Java. It’s architecture is really simple, just an 4 byte register and 256 byte main memory. I have already implemented a “hardware” stack, so the processor supports PUSH, POP and GET. The stack is filled backward from the last memory cell, so “normal” memory usage should start at cell 0. You don’t have to reserve memory, the program is able to use the full 256 byte by default.

I am also creating a compiler for this processor which compiles from a simple language I invented. At the moment, every variable defined (I’m just supporting one 8-bit integer type) is assigned to one memory cell, starting with 0 and increasing. So I have a maximum of 256 (if the stack is empty) variables. Currently, I don’t want to change this.

My next goal is to add the ability to use parameterless procedures without return type. Variables declared in the function should be freed before returning automatically. So where should I store the variables? I would create a “software” stack between my variables at the beginning and the “hardware” stack at the end of the memory. I first had the idea to use the hardware stack for this, but I want to use it for the calls and returns of methods itself. Is there a better solution than creating a second “software” stack?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:01:05+00:00Added an answer on May 26, 2026 at 1:01 pm

    Each function, when you call it, should create an activation frame/call stack on the stack, which includes space for the return address, any parameters, and any local variables that are created within the function. At the very least, an activation frame in your situation should contain the return address of the calling code. The extra data that comes into play is based on whether your function accepts parameters, and/or if it creates any variables that are local to the function. Your stack might look like this:

    +------------------+
    |  Return address  |
    +------------------+
    |   Parameter 0    |
    +------------------+
    |       ...        |
    +------------------+
    |   Parameter N    |
    +------------------+
    |   Local Var 0    |
    +------------------+
    |       ...        |
    +------------------+
    |   Local Var N    |   <--- Top of Stack
    +------------------+
    

    Since you already are using main memory for the stack, this is where the activation frame will also live. I’m assuming that your processor has a stack pointer which points to the top of the stack?

    You could create two stacks but then you would need to decide where to put this stack and how much memory it should consume. Do you want to use half of main memory for the hardware stack and the other half for the software stack? This also means that you are limiting the number of nested calls (or even recursive) calls that you can make. Instead there is another method you can use to conserve memory usage. The way to do this is to include the parameters to your function after the call to the function (your assembler will have to do this):

    +--------------+
    |   JMP FUNC   | Call the function
    +--------------+
    |  Parameter 0 | <--- return address points here
    +--------------+
    |     ...      |
    +--------------+
    |  Parameter N |
    +--------------+
    | (other code) | <--- after function call, return address should be fixed to point here
    +--------------+
    

    This means that you will have to do a little more work inside the function to load up the parameters. If you recall, the return address is the first value on the stack. You can load this value and then index off that value to load up your parameters. Once you’re done loading your parameters, you will need to adjust the value of your return address so that it points to code that starts after the parameters that you have defined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating iPhone apps in simulator, I sometimes see messages like Springboard failed to
I'm creating some temporary files in the iPad simulator. To test my file creation,
I just downloaded the code from http://cocoadevblog.com/iphone-tutorial-creating-a-rss-feed-reader to see how to implement rss feeder
I'm creating a Boolean logic simulator. I've posted a question regarding the organization and
I'm creating a simulator coded in python and based on ODE (Open Dynamics Engine).
I am creating Database it runs perfectly. I can access database on simulator but
I'm creating a simple blackberry application for testing purposes and my custom buttons do
i'm new at C # and i'm creating a racetrack simulator, but i'm currently
I'm creating a GUI for a python simulator. The GUI provides tools to set
I'm creating an organism simulator for Android, so I guess the algorithm would ideally

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.