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

  • SEARCH
  • Home
  • 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 6973113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:04:00+00:00 2026-05-27T17:04:00+00:00

for my homework I need to write a very little virtual 16 bit Assembler-Interpreter

  • 0

for my homework I need to write a very little virtual 16 bit Assembler-Interpreter in C#.
It simulates the RAM with a byte-array (64k) and the registers with Variables (A,B,C,…).
Now I need a way to save local variables, google says that they are allocated on the Stack.

But the thing thats unclear to me is, when they are allocated on the Stack (with push…), how is the Interpreter accessing them when they are used later?

See the following 2 lines:

pi INT 3
mov A, pi

In the first line, pi is allocated on the stack, in the second line, pi is used, but how should the Interpreter know where pi is in the stack to access its data? (my Stack is a byte-array too with 2 helper-functions (push, pop), there is also a pointer to the top of the 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-27T17:04:01+00:00Added an answer on May 27, 2026 at 5:04 pm

    Typically there is no separate stack memory, instead the stack is in the regular RAM, so you only have the stack pointer that keeps track of it.

    Also typically, local variables are allocated at the beginning of a subroutine by copying the stack pointer to another register, then moving the stack pointer to make room for the variables:

    mov bp, sp ;copy stack pointer
    sub sp, 4 ;make room for two integer variables
    

    Accessing local variables is done using the copy of the stack pointer:

    mov A, [bp-2] ;get first integer
    mov B, [bp] ;get second integer
    

    When you leave the subroutine, you restore the stack pointer to deallocate the local variables:

    mov sp, bp ;restore stack
    ret ;exit from subroutine
    

    The syntax that you use in the question is usually used to declare global variables, not local variables:

    .data
    pi int 3 ;declare a label and allocate room for an int in the program
    .code
    mov A, pi ;use the address of the label to access the int
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with my CS homework. I need to write a sorting
I use latex to write up homework assignments. I need to include both charts
There is a homework I should do and I need help. I should write
I need to write a compiler. It's homework at the univ. The teacher told
As a homework i need to make a webapp that will play an mp3
For homework, I need to build a small java application.The main goal is to
I have a homework assignment where I need to take input from a file
I understand that I need to figure out my own homework, but seeing that
This is not homework, I need this for my program :) I ask this
Am about to do a homework, and i need to store quite a lot

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.