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 6972639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:59:44+00:00 2026-05-27T16:59:44+00:00

I’m really confused as to how stack pointers and byte pointers work. Here is

  • 0

I’m really confused as to how stack pointers and byte pointers work. Here is the segment of code the problem is referencing:

    .data
v1  db  'AB'
v2  db  'CD'
v3  db  'EF

    .code
start:
     mov  ax,@data
     mov  ds,ax
     mov  sp,0100h

;call the subroutine
     mov  ax,offset v1
     push ax
     mov  ax,offset v2
     push ax
     call subr
retsub:

The subroutine is:

subr:
     push bp
     mov  bp,sp
     mov  si,[bp+6]
     add  si,1
     mov  dl,[si]
     mov  ah,2
     int  21h
     pop  bp
     ret

The three review questions associated with this problem have these answers:
1. After mov bp,sp in the subroutine, the value of the hex value in bp is 00F8.
2. The subroutine writes a single ASCII character to the standard output. It writes B.
3. The hex value in the sp register after the subroutine returns to the main program at the instruction at the label retsub is 00FC.

Can anyone walk me through the steps so that I can understand this process a little better?

The offset data table that I have is:

offset  00  01  02  03  04  05
data    41  42  43  44  45  46

The way that I approach this problem in my head is:

mov  sp,0100h      ;sp = 0100
mov  ax,offset v1  ;ax = 4142
push ax            ;4142 is pushed onto the stack
mov  ax,offset v2  ;ax = 4344
push ax            ;4344 is pushed onto the stack
call subr

stack
------
|4344|
------
|4142|
------

This is as far as I understand and I’m sure I’m not even doing this part right. If you can, please break it down with what bp and sp is with each step so that I can follow along and hopefully apply this to another review problem.

  • 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-27T16:59:45+00:00Added an answer on May 27, 2026 at 4:59 pm

    Every push decrements sp by the size of the pushed element. Every pop increments sp similarly.

    So, you begin with sp = 100h, then you

    1. subtract 2 with push ax
    2. subtract 2 with push ax
    3. subtract 2 with call subr because call pushes the return address and it’s 16-bit here
    4. subtract 2 with push bp and arrive at sp = 0F8h
    5. add 2 with pop bp
    6. add 2 with ret and remove the 16-bit return address and arrive at sp = 0FCh
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I want to construct a data frame in an Rcpp function, but when I
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.