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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:32:30+00:00 2026-05-22T01:32:30+00:00

This was a 2 part assignment. first I had to figure out how to

  • 0

This was a 2 part assignment. first I had to figure out how to send a reference parameter to a procedure called pow using the stack which I think I did correctly using push offset result The second part of this assignment has me completely clueless, i’ve read and read in my text but I am still unable to figure out how I can accomplish what I need to do. After sending the reference parameter I need to make the result of the calculations in the pow procedure become stored in the reference parameter so it can be output later in the program. I’ve tried a few different things so far to no avail. The code is commented so those familiar with assembly should understand what i’m trying to do. If anyone could help me out I will greatly appreciate it. thanks

INCLUDE Irvine32.inc
.data
XPrompt BYTE "Enter the value of the base(X):",0
YPrompt BYTE "Enter the value of the exponent(Y):",0
ResultMessage BYTE "X to the power of Y is",0
result DWORD ?

.code
main PROC
    call Clrscr

   ;;;;Prompt for X 
    mov  edx,OFFSET XPrompt
    call WriteString

    call ReadInt
    push eax     ;;;;pass the 1st number to POW
                 ;;;;this will represent the base

   ;;;; Prompt for Y 
    mov  edx,OFFSET YPrompt
    call WriteString

    call ReadInt
    push eax            ;;;;pass the 2nd number to POW
                        ;;;;this will represent the EXPONENT

    push OFFSET result  ;;;;pass the third parameter to pow, using offset makes it a reference parameter                         

    call Pow
                             ;;; Print Result (Assumes the answer is in eax)
    mov  edx,OFFSET ResultMessage
    call WriteString

    ;;;;;;;;;;;;;;;;;NOTE: NEW "POW" MODIFICATIONS HERE;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    mov eax,result     ; If the pow function correctly returns it answer by reference
                       ; then this should be all that's necessary to print
                       ; the answer with the call to "WriteInt"
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                     
    call WriteInt
    call ReadInt             ;;;; screen pause
    exit
main ENDP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Pow PROC
COMMENT !
PUT FUNCTION CODE IN THIS SECTION

This current  pow function returns its answer via register "eax." Modify it as necessary
so that it returns its answer by a reference parameter. In C++ the function interface/prototype
would look like:

 void pow(int base,int exp, int & result)

where "base" is the base and "exp" is the exponent. In other words "pow" should calculate "base" to the
power of "exp," then return the answer via "result."  Let your function return its result via a
3rd REFERENCE parameter "result." Which will be a REFERENCE parameter on the stack. 
 !

 base EQU DWORD PTR [ebp + 12]
 exponent  EQU DWORD PTR [ebp + 8]

 push ebp
 mov ebp, esp
 push ecx  ;<------------ecx must also be preserved since it is modified
           ; by the "loop" instruction.

 mov ecx, exponent ;set ecx as our counter
 mov eax, 1        ; eax will be our multiplier
 L1:
  mul base
  loop L1

pop ecx  ;<------------restore ecx
pop ebp  ;<------------restore ebp

ret 8
Pow ENDP
END main
  • 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-22T01:32:31+00:00Added an answer on May 22, 2026 at 1:32 am

    Ok, since you’re using C-style function prototype, I guess you know C. Now, when you pass a pointer to a function you need to dereference that pointer to access its data. In other words, dereferencing is that asterisk you put before variables name. An example:

    void swap(int *a, int *b)
    {
        int t = *a;
        *a = *b;
        *b = t;
    }
    

    Those asterisk means: “grab the value at address a (or b) instead of a’s (or b’s) value”. This is what you need to do in your program to store the result.
    In assembly there’s a special way to specify “the address of” instead of “the value of”, and it is ……… . Once you know this, you should be ok 😉

    EDIT

    Once you have the result in a register, just load in another register the offset and apply the [] to that register:

    mov eax, pointer
    mov ecx, result
    mov [eax], ecx
    

    or, in C:

    *pointer = result;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is part of my first comp sci assignment, we are writing a C
This is part of a homework assignment. I've got several questions asking find the
(this is indirectly a part of a much larger homework assignment) I have something
The code we're using is straightforward in this part of the search query: myCriteria.Add(
First off, full disclosure: This is going towards a uni assignment, so I don't
I'm using Dev C++ for this programming assignment. I'll try and give a basic
I am working on a homework assignment and I'm trying to figure out a
This is part of an assignment. Everything that's supposed to work, already works, but
This is my first attempt at java problem I have been given as part
So this is a small part of a large assignment I have, I'm just

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.