I am trying to figure out how to make the return type of a procedure a reference parameter. Can anyone help me out? I am a complete noob so if you could try and explain things as best you can I would really appreciate it and would help. My code is commented pretty well. Thanks!

TITLE MASM Template                                             (main.asm)
INCLUDE Irvine32.inc
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 ? 
main PROC
        call Clrscr
        mov  edx,OFFSET XPrompt ;;;;Prompt for X 
        call WriteString
        call ReadInt
        push eax     ;;;;pass the 1st number to POW
                     ;;;;this will represent the base 
        mov  edx,OFFSET YPrompt ;;;; Prompt for Y
        call WriteString
        call ReadInt
        push eax            ;;;;pass the 2nd number to POW
                            ;;;;this will represent the EXPONENT
        push OFFSET result ; 3rd parameter passed to POW only OFFSET makes it a reference
                           ; parameter so it can be used as the return value
        call Pow
                                 ;;; Print Result (Assumes the answer is in eax)
        mov      edx,OFFSET ResultMessage
        call WriteString
        mov eax, result     
        call WriteInt
        call ReadInt             ;;;; Just to pause the screen
main ENDP
 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
  mul base
  loop L1
pop ecx  ;<------------restore ecx
pop ebp  ;<------------restore ebp
ret 8
END main

Reference parameter just means that you are returning the address of a variable, rather than the value of a variable. So to return the variable varname by reference you would just do something like:

lea eax, varname

Then you could access the variable by doing something like:

mov edx, [eax]

This article has been dead for over six months. Start a new discussion instead.