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
.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
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
exit
main ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Pow PROC
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