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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:43:22+00:00 2026-05-26T15:43:22+00:00

This section has me thoroughly confused. I have an example problem that I am

  • 0

This section has me thoroughly confused. I have an example problem that I am hoping someone can break down into steps for me so that I may absorb how it is done to apply to other problems.

mc:   call subr
mr:   mov  [val],ax
subr: push ax
      push bx
      push cx
      add  ax,dx
      pop  ax
      pop bx
      pop cx
      ret

The book asks what the hex value in the sp and ax register will be for when the code returns from the subroutine and reaches the instruction mr: mov [val],ax. sp=0100 ax=0002, but I have no clue as to how to arrive at these answers.

The instruction mc: call subr saves the address of the next sequential instruction mr: mov [val],ax on the stack so the subroutine can correctly return. The absolute address in memory where the return address is saved is 1120E. Can anyone please elaborate on this as well?

registers given:
ax = 0000  bx = 0001  cx = 0002  dx = 0004
si = 0000  di = FFFF  bp = 0080  sp = 0100
cs = 1000  ds = 1100  es = 1110  ss = 1111
  • 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-26T15:43:23+00:00Added an answer on May 26, 2026 at 3:43 pm

    The call at mc: will save the current address, so when the subr: returns, control will start again at mr:.

    Since subr: pushes ax, bx, and cx in that order. It then pops ax, bx, and cx in that order, so what was pushed from cx gets popped into ax (and vice versa). The effect of these is to swap ax and cx. The add ax, dx has no real effect on the result produced, because immediately after adding dx to ax, it pops ax off the stack. The add does affect the flags, but nothing here does anything based on the flags, so at least in the code you’ve shown, that doesn’t mean much either.

    After control returns to mr:, it writes the value in ax to memory, and then flows back into subr:, thus swapping ax and cx back to where they started.

    IOW, the whole this is a very slow, roundabout way of achieving roughly the same effect as:

    mc: mov [val], cx
        ret
    

    As far as the absolute address goes, there’s not much to say. In particular, chances are pretty good that if you run the same code again, it may be loaded at a different address, o the address saved on the stack may be entirely different.

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

Sidebar

Related Questions

I have a section of makefile that has this sort of structure: bob: ifdef
I have a form on which I use validation. This form has a section
I have a utility class that has been thoroughly tested, and I do not
Im have a xml config file called solrconfig.xml, it has this section in the
This is something that has always bothered me about PHP and I have never
I have a tableview with four sections first section has 7 rows in that
I'm getting a javascript error. It has to do with this section of code:
I've read this book section about git branches. I have create a branch called
I have been trying to get this one section of my UI to immediatly
Have HTML pages with many sections and each section has a section title displayed

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.